Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit f9ca37d

Browse files
authored
Update generated code. (#139)
* Update generated code. Schema version: microsoftgraph/msgraph-metadata@1df5dcf3 Generator version: microsoft/kiota@92a87411 * Register paging service
1 parent 496dfc3 commit f9ca37d

File tree

10,181 files changed

+395348
-170715
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

10,181 files changed

+395348
-170715
lines changed

src/Program.cs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ static async Task<int> Main(string[] args)
3939
var authStrategy = AuthenticationStrategy.DeviceCode;
4040

4141
var credential = await authServiceFactory.GetTokenCredentialAsync(authStrategy, authSettings?.TenantId, authSettings?.ClientId);
42-
var authProvider = new AzureIdentityAuthenticationProvider(credential, new string[] {"graph.microsoft.com"});
42+
var authProvider = new AzureIdentityAuthenticationProvider(credential, new string[] { "graph.microsoft.com" });
4343

4444
var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;
45-
var options = new GraphClientOptions {
45+
var options = new GraphClientOptions
46+
{
4647
GraphProductPrefix = "graph-cli",
4748
GraphServiceLibraryClientVersion = $"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}",
4849
GraphServiceTargetVersion = "1.0"
@@ -59,20 +60,27 @@ static async Task<int> Main(string[] args)
5960
commands.Add(logoutCommand.Build());
6061

6162
var builder = BuildCommandLine(client, commands).UseDefaults().UseHost(CreateHostBuilder);
62-
builder.AddMiddleware((invocation) => {
63+
builder.AddMiddleware((invocation) =>
64+
{
6365
var host = invocation.GetHost();
6466
var outputFilter = host.Services.GetRequiredService<IOutputFilter>();
6567
var outputFormatterFactory = host.Services.GetRequiredService<IOutputFormatterFactory>();
66-
invocation.BindingContext.AddService<IOutputFilter>(_ => outputFilter);
67-
invocation.BindingContext.AddService<IOutputFormatterFactory>(_ => outputFormatterFactory);
68+
var pagingService = host.Services.GetRequiredService<IPagingService>();
69+
invocation.BindingContext.AddService(_ => outputFilter);
70+
invocation.BindingContext.AddService(_ => outputFormatterFactory);
71+
invocation.BindingContext.AddService(_ => pagingService);
6872
});
69-
builder.UseExceptionHandler((ex, context) => {
70-
if (ex is AuthenticationRequiredException) {
73+
builder.UseExceptionHandler((ex, context) =>
74+
{
75+
if (ex is AuthenticationRequiredException)
76+
{
7177
Console.ResetColor();
7278
Console.ForegroundColor = ConsoleColor.Red;
7379
context.Console.Error.WriteLine("Token acquisition failed. Run mgc login command first to get an access token.");
7480
Console.ResetColor();
75-
} else {
81+
}
82+
else
83+
{
7684
Console.ResetColor();
7785
Console.ForegroundColor = ConsoleColor.Red;
7886
context.Console.Error.WriteLine(ex.Message);
@@ -91,29 +99,35 @@ static CommandLineBuilder BuildCommandLine(GraphClient client, IEnumerable<Comma
9199
var rootCommand = client.BuildRootCommand();
92100
rootCommand.Description = "Microsoft Graph CLI";
93101

94-
foreach (var command in commands) {
102+
foreach (var command in commands)
103+
{
95104
rootCommand.AddCommand(command);
96105
}
97106

98107
return new CommandLineBuilder(rootCommand);
99108
}
100109

101110
static IHostBuilder CreateHostBuilder(string[] args) =>
102-
Host.CreateDefaultBuilder().ConfigureHostConfiguration((configHost) => {
111+
Host.CreateDefaultBuilder().ConfigureHostConfiguration((configHost) =>
112+
{
103113
configHost.SetBasePath(Directory.GetCurrentDirectory());
104-
}).ConfigureAppConfiguration((ctx, config) => {
114+
}).ConfigureAppConfiguration((ctx, config) =>
115+
{
105116
ConfigureAppConfiguration(config);
106-
}).ConfigureServices((ctx, services) => {
117+
}).ConfigureServices((ctx, services) =>
118+
{
107119
var authSection = ctx.Configuration.GetSection(nameof(AuthenticationOptions));
108120
services.Configure<AuthenticationOptions>(authSection);
109121
services.AddSingleton<IPathUtility, PathUtility>();
110122
services.AddSingleton<IAuthenticationCacheUtility, AuthenticationCacheUtility>();
111123
services.AddSingleton<IOutputFilter, JmesPathOutputFilter>();
112124
services.AddSingleton<JmesPath>();
113125
services.AddSingleton<IOutputFormatterFactory, OutputFormatterFactory>();
126+
services.AddSingleton<IPagingService, GraphODataPagingService>();
114127
});
115-
116-
static void ConfigureAppConfiguration(IConfigurationBuilder builder) {
128+
129+
static void ConfigureAppConfiguration(IConfigurationBuilder builder)
130+
{
117131
builder.Sources.Clear();
118132
builder.AddJsonFile(Path.Combine(System.AppContext.BaseDirectory, "app-settings.json"), optional: true);
119133
var pathUtil = new PathUtility();

src/generated/Admin/AdminRequestBuilder.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using ApiSdk.Admin.ServiceAnnouncement;
22
using ApiSdk.Models;
33
using ApiSdk.Models.ODataErrors;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.Extensions.Hosting;
46
using Microsoft.Kiota.Abstractions;
57
using Microsoft.Kiota.Abstractions.Serialization;
6-
using Microsoft.Kiota.Cli.Commons.Binding;
78
using Microsoft.Kiota.Cli.Commons.IO;
89
using System;
910
using System.Collections.Generic;
@@ -52,15 +53,15 @@ public Command BuildGetCommand() {
5253
return true;
5354
}, description: "Disable indentation for the JSON output formatter.");
5455
command.AddOption(jsonNoIndentOption);
55-
command.SetHandler(async (object[] parameters) => {
56-
var select = (string[]) parameters[0];
57-
var expand = (string[]) parameters[1];
58-
var output = (FormatterType) parameters[2];
59-
var query = (string) parameters[3];
60-
var jsonNoIndent = (bool) parameters[4];
61-
var outputFilter = (IOutputFilter) parameters[5];
62-
var outputFormatterFactory = (IOutputFormatterFactory) parameters[6];
63-
var cancellationToken = (CancellationToken) parameters[7];
56+
command.SetHandler(async (invocationContext) => {
57+
var select = invocationContext.ParseResult.GetValueForOption(selectOption);
58+
var expand = invocationContext.ParseResult.GetValueForOption(expandOption);
59+
var output = invocationContext.ParseResult.GetValueForOption(outputOption);
60+
var query = invocationContext.ParseResult.GetValueForOption(queryOption);
61+
var jsonNoIndent = invocationContext.ParseResult.GetValueForOption(jsonNoIndentOption);
62+
var outputFilter = invocationContext.BindingContext.GetRequiredService<IOutputFilter>();
63+
var outputFormatterFactory = invocationContext.BindingContext.GetRequiredService<IOutputFormatterFactory>();
64+
var cancellationToken = invocationContext.GetCancellationToken();
6465
var requestInfo = CreateGetRequestInformation(q => {
6566
q.QueryParameters.Select = select;
6667
q.QueryParameters.Expand = expand;
@@ -74,7 +75,7 @@ public Command BuildGetCommand() {
7475
var formatterOptions = output.GetOutputFormatterOptions(new FormatterOptionsModel(!jsonNoIndent));
7576
var formatter = outputFormatterFactory.GetFormatter(output);
7677
await formatter.WriteOutputAsync(response, formatterOptions, cancellationToken);
77-
}, new CollectionBinding(selectOption, expandOption, outputOption, queryOption, jsonNoIndentOption, new TypeBinding(typeof(IOutputFilter)), new TypeBinding(typeof(IOutputFormatterFactory)), new TypeBinding(typeof(CancellationToken))));
78+
});
7879
return command;
7980
}
8081
/// <summary>
@@ -88,9 +89,9 @@ public Command BuildPatchCommand() {
8889
};
8990
bodyOption.IsRequired = true;
9091
command.AddOption(bodyOption);
91-
command.SetHandler(async (object[] parameters) => {
92-
var body = (string) parameters[0];
93-
var cancellationToken = (CancellationToken) parameters[1];
92+
command.SetHandler(async (invocationContext) => {
93+
var body = invocationContext.ParseResult.GetValueForOption(bodyOption);
94+
var cancellationToken = invocationContext.GetCancellationToken();
9495
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body));
9596
var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream);
9697
var model = parseNode.GetObjectValue<ApiSdk.Models.Admin>(ApiSdk.Models.Admin.CreateFromDiscriminatorValue);
@@ -102,7 +103,7 @@ public Command BuildPatchCommand() {
102103
};
103104
await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: errorMapping, cancellationToken: cancellationToken);
104105
Console.WriteLine("Success");
105-
}, new CollectionBinding(bodyOption, new TypeBinding(typeof(CancellationToken))));
106+
});
106107
return command;
107108
}
108109
public Command BuildServiceAnnouncementCommand() {
@@ -139,6 +140,7 @@ public RequestInformation CreateGetRequestInformation(Action<AdminRequestBuilder
139140
UrlTemplate = UrlTemplate,
140141
PathParameters = PathParameters,
141142
};
143+
requestInfo.Headers.Add("Accept", "application/json");
142144
if (requestConfiguration != null) {
143145
var requestConfig = new AdminRequestBuilderGetRequestConfiguration();
144146
requestConfiguration.Invoke(requestConfig);

src/generated/Admin/ServiceAnnouncement/HealthOverviews/Count/CountRequestBuilder.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using ApiSdk.Models.ODataErrors;
2+
using Microsoft.Extensions.DependencyInjection;
3+
using Microsoft.Extensions.Hosting;
24
using Microsoft.Kiota.Abstractions;
35
using Microsoft.Kiota.Abstractions.Serialization;
4-
using Microsoft.Kiota.Cli.Commons.Binding;
56
using Microsoft.Kiota.Cli.Commons.IO;
67
using System;
78
using System.Collections.Generic;
@@ -27,9 +28,9 @@ public Command BuildGetCommand() {
2728
var command = new Command("get");
2829
command.Description = "Get the number of the resource";
2930
// Create options for all the parameters
30-
command.SetHandler(async (object[] parameters) => {
31-
var outputFormatterFactory = (IOutputFormatterFactory) parameters[0];
32-
var cancellationToken = (CancellationToken) parameters[1];
31+
command.SetHandler(async (invocationContext) => {
32+
var outputFormatterFactory = invocationContext.BindingContext.GetRequiredService<IOutputFormatterFactory>();
33+
var cancellationToken = invocationContext.GetCancellationToken();
3334
var requestInfo = CreateGetRequestInformation(q => {
3435
});
3536
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
@@ -39,7 +40,7 @@ public Command BuildGetCommand() {
3940
var response = await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping: errorMapping, cancellationToken: cancellationToken);
4041
var formatter = outputFormatterFactory.GetFormatter(FormatterType.TEXT);
4142
await formatter.WriteOutputAsync(response, null, cancellationToken);
42-
}, new CollectionBinding(new TypeBinding(typeof(IOutputFormatterFactory)), new TypeBinding(typeof(CancellationToken))));
43+
});
4344
return command;
4445
}
4546
/// <summary>
@@ -65,6 +66,7 @@ public RequestInformation CreateGetRequestInformation(Action<CountRequestBuilder
6566
UrlTemplate = UrlTemplate,
6667
PathParameters = PathParameters,
6768
};
69+
requestInfo.Headers.Add("Accept", "text/plain");
6870
if (requestConfiguration != null) {
6971
var requestConfig = new CountRequestBuilderGetRequestConfiguration();
7072
requestConfiguration.Invoke(requestConfig);

0 commit comments

Comments
 (0)