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

Commit 1f2dbbf

Browse files
authored
Merge pull request #22 from microsoftgraph/chore/run_codegen
Update generated code
2 parents 5cc39d6 + 023c183 commit 1f2dbbf

File tree

7,081 files changed

+143570
-291687
lines changed

Some content is hidden

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

7,081 files changed

+143570
-291687
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"request": "launch",
3535
"preLaunchTask": "build",
3636
"program": "${workspaceFolder}/src/bin/Debug/net6.0/mgc.dll",
37-
"args": ["me", "get"],
37+
"args": ["me", "get", "--output", "TABLE"],
3838
"cwd": "${workspaceFolder}/src",
3939
"envFile": "${workspaceFolder}/src/.env",
4040
"console": "internalConsole",

src/Program.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
using Microsoft.Graph.Cli.Core.Configuration;
99
using Microsoft.Graph.Cli.Core.IO;
1010
using Microsoft.Graph.Cli.Core.Utils;
11+
using Microsoft.Kiota.Abstractions;
1112
using Microsoft.Kiota.Authentication.Azure;
13+
using Microsoft.Kiota.Cli.Commons.IO;
1214
using Microsoft.Kiota.Http.HttpClientLibrary;
1315
using Microsoft.Kiota.Http.HttpClientLibrary.Middleware;
1416
using Microsoft.Kiota.Http.HttpClientLibrary.Middleware.Options;
@@ -43,7 +45,7 @@ static async Task<int> Main(string[] args)
4345
var authStrategy = AuthenticationStrategy.DeviceCode;
4446

4547
var credential = await authServiceFactory.GetTokenCredentialAsync(authStrategy, authSettings?.TenantId, authSettings?.ClientId);
46-
var authProvider = new AzureIdentityAuthenticationProvider(credential);
48+
var authProvider = new AzureIdentityAuthenticationProvider(credential, new string[] {"graph.microsoft.com"});
4749
var defaultHandlers = KiotaClientFactory.CreateDefaultHandlers();
4850

4951
var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;
@@ -67,8 +69,6 @@ static async Task<int> Main(string[] args)
6769
using var httpClient = KiotaClientFactory.Create(finalHandler);
6870
var core = new HttpClientRequestAdapter(authProvider, httpClient: httpClient);
6971
var client = new GraphClient(core);
70-
var rootCommand = client.BuildCommand();
71-
rootCommand.Description = "Microsoft Graph CLI";
7272

7373
var commands = new List<Command>();
7474
var loginCommand = new LoginCommand(authServiceFactory);
@@ -77,7 +77,12 @@ static async Task<int> Main(string[] args)
7777
var logoutCommand = new LogoutCommand(new LogoutService());
7878
commands.Add(logoutCommand.Build());
7979

80-
var builder = BuildCommandLine(client, commands).UseDefaults();
80+
var builder = BuildCommandLine(client, commands).UseDefaults().UseHost(CreateHostBuilder);
81+
builder.AddMiddleware((invocation) => {
82+
var host = invocation.GetHost();
83+
var outputFormatterFactory = host.Services.GetRequiredService<IOutputFormatterFactory>();
84+
invocation.BindingContext.AddService<IOutputFormatterFactory>(_ => outputFormatterFactory);
85+
});
8186
builder.UseExceptionHandler((ex, context) => {
8287
if (ex is AuthenticationRequiredException) {
8388
Console.ResetColor();
@@ -87,14 +92,14 @@ static async Task<int> Main(string[] args)
8792
}
8893
});
8994

90-
var parser = builder.UseHost(CreateHostBuilder).Build();
95+
var parser = builder.Build();
9196

9297
return await parser.InvokeAsync(args);
9398
}
9499

95100
static CommandLineBuilder BuildCommandLine(GraphClient client, IEnumerable<Command> commands)
96101
{
97-
var rootCommand = client.BuildCommand();
102+
var rootCommand = client.BuildRootCommand();
98103
rootCommand.Description = "Microsoft Graph CLI";
99104

100105
foreach (var command in commands) {
@@ -113,6 +118,7 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
113118
var authSection = ctx.Configuration.GetSection(Constants.AuthenticationSection);
114119
services.Configure<AuthenticationOptions>(authSection);
115120
services.AddSingleton<IPathUtility, PathUtility>();
121+
services.AddSingleton<IOutputFormatterFactory, OutputFormatterFactory>();
116122
});
117123

118124
static void ConfigureAppConfiguration(IConfigurationBuilder builder) {

src/generated/Admin/AdminRequestBuilder.cs

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
using ApiSdk.Models.Microsoft.Graph;
33
using Microsoft.Kiota.Abstractions;
44
using Microsoft.Kiota.Abstractions.Serialization;
5+
using Microsoft.Kiota.Cli.Commons.IO;
56
using System;
67
using System.Collections.Generic;
78
using System.CommandLine;
8-
using System.CommandLine.Invocation;
99
using System.IO;
1010
using System.Linq;
1111
using System.Text;
@@ -37,20 +37,19 @@ public Command BuildGetCommand() {
3737
};
3838
expandOption.IsRequired = false;
3939
command.AddOption(expandOption);
40-
command.SetHandler(async (string[] select, string[] expand) => {
40+
var outputOption = new Option<FormatterType>("--output", () => FormatterType.JSON){
41+
IsRequired = true
42+
};
43+
command.AddOption(outputOption);
44+
command.SetHandler(async (string[] select, string[] expand, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => {
4145
var requestInfo = CreateGetRequestInformation(q => {
4246
q.Select = select;
4347
q.Expand = expand;
4448
});
45-
var result = await RequestAdapter.SendAsync<ApiSdk.Models.Microsoft.Graph.Admin>(requestInfo);
46-
// Print request output. What if the request has no return?
47-
using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json");
48-
serializer.WriteObjectValue(null, result);
49-
using var content = serializer.GetSerializedContent();
50-
using var reader = new StreamReader(content);
51-
var strContent = await reader.ReadToEndAsync();
52-
Console.Write(strContent + "\n");
53-
}, selectOption, expandOption);
49+
var response = await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping: default, cancellationToken: cancellationToken);
50+
var formatter = outputFormatterFactory.GetFormatter(output);
51+
formatter.WriteOutput(response);
52+
}, selectOption, expandOption, outputOption);
5453
return command;
5554
}
5655
/// <summary>
@@ -64,14 +63,13 @@ public Command BuildPatchCommand() {
6463
};
6564
bodyOption.IsRequired = true;
6665
command.AddOption(bodyOption);
67-
command.SetHandler(async (string body) => {
66+
command.SetHandler(async (string body, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => {
6867
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body));
6968
var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream);
7069
var model = parseNode.GetObjectValue<ApiSdk.Models.Microsoft.Graph.Admin>();
7170
var requestInfo = CreatePatchRequestInformation(model, q => {
7271
});
73-
await RequestAdapter.SendNoContentAsync(requestInfo);
74-
// Print request output. What if the request has no return?
72+
await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping: default, cancellationToken: cancellationToken);
7573
Console.WriteLine("Success");
7674
}, bodyOption);
7775
return command;
@@ -139,31 +137,6 @@ public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.
139137
requestInfo.AddRequestOptions(o?.ToArray());
140138
return requestInfo;
141139
}
142-
/// <summary>
143-
/// Get admin
144-
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
145-
/// <param name="h">Request headers</param>
146-
/// <param name="o">Request options</param>
147-
/// <param name="q">Request query parameters</param>
148-
/// <param name="responseHandler">Response handler to use in place of the default response handling provided by the core service</param>
149-
/// </summary>
150-
public async Task<ApiSdk.Models.Microsoft.Graph.Admin> GetAsync(Action<GetQueryParameters> q = default, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) {
151-
var requestInfo = CreateGetRequestInformation(q, h, o);
152-
return await RequestAdapter.SendAsync<ApiSdk.Models.Microsoft.Graph.Admin>(requestInfo, responseHandler, cancellationToken);
153-
}
154-
/// <summary>
155-
/// Update admin
156-
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
157-
/// <param name="h">Request headers</param>
158-
/// <param name="model"></param>
159-
/// <param name="o">Request options</param>
160-
/// <param name="responseHandler">Response handler to use in place of the default response handling provided by the core service</param>
161-
/// </summary>
162-
public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Admin model, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) {
163-
_ = model ?? throw new ArgumentNullException(nameof(model));
164-
var requestInfo = CreatePatchRequestInformation(model, h, o);
165-
await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler, cancellationToken);
166-
}
167140
/// <summary>Get admin</summary>
168141
public class GetQueryParameters : QueryParametersBase {
169142
/// <summary>Expand related entities</summary>

src/generated/Admin/ServiceAnnouncement/HealthOverviews/HealthOverviewsRequestBuilder.cs

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
using ApiSdk.Models.Microsoft.Graph;
33
using Microsoft.Kiota.Abstractions;
44
using Microsoft.Kiota.Abstractions.Serialization;
5+
using Microsoft.Kiota.Cli.Commons.IO;
56
using System;
67
using System.Collections.Generic;
78
using System.CommandLine;
8-
using System.CommandLine.Invocation;
99
using System.IO;
1010
using System.Linq;
1111
using System.Text;
@@ -22,12 +22,11 @@ public class HealthOverviewsRequestBuilder {
2222
private string UrlTemplate { get; set; }
2323
public List<Command> BuildCommand() {
2424
var builder = new ServiceHealthRequestBuilder(PathParameters, RequestAdapter);
25-
var commands = new List<Command> {
26-
builder.BuildDeleteCommand(),
27-
builder.BuildGetCommand(),
28-
builder.BuildIssuesCommand(),
29-
builder.BuildPatchCommand(),
30-
};
25+
var commands = new List<Command>();
26+
commands.Add(builder.BuildDeleteCommand());
27+
commands.Add(builder.BuildGetCommand());
28+
commands.Add(builder.BuildIssuesCommand());
29+
commands.Add(builder.BuildPatchCommand());
3130
return commands;
3231
}
3332
/// <summary>
@@ -41,21 +40,20 @@ public Command BuildCreateCommand() {
4140
};
4241
bodyOption.IsRequired = true;
4342
command.AddOption(bodyOption);
44-
command.SetHandler(async (string body) => {
43+
var outputOption = new Option<FormatterType>("--output", () => FormatterType.JSON){
44+
IsRequired = true
45+
};
46+
command.AddOption(outputOption);
47+
command.SetHandler(async (string body, FormatterType output, IOutputFormatterFactory outputFormatterFactory, CancellationToken cancellationToken) => {
4548
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body));
4649
var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream);
4750
var model = parseNode.GetObjectValue<ServiceHealth>();
4851
var requestInfo = CreatePostRequestInformation(model, q => {
4952
});
50-
var result = await RequestAdapter.SendAsync<ServiceHealth>(requestInfo);
51-
// Print request output. What if the request has no return?
52-
using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json");
53-
serializer.WriteObjectValue(null, result);
54-
using var content = serializer.GetSerializedContent();
55-
using var reader = new StreamReader(content);
56-
var strContent = await reader.ReadToEndAsync();
57-
Console.Write(strContent + "\n");
58-
}, bodyOption);
53+
var response = await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping: default, cancellationToken: cancellationToken);
54+
var formatter = outputFormatterFactory.GetFormatter(output);
55+
formatter.WriteOutput(response);
56+
}, bodyOption, outputOption);
5957
return command;
6058
}
6159
/// <summary>
@@ -100,7 +98,11 @@ public Command BuildListCommand() {
10098
};
10199
expandOption.IsRequired = false;
102100
command.AddOption(expandOption);
103-
command.SetHandler(async (int? top, int? skip, string search, string filter, bool? count, string[] orderby, string[] select, string[] expand) => {
101+
var outputOption = new Option<FormatterType>("--output", () => FormatterType.JSON){
102+
IsRequired = true
103+
};
104+
command.AddOption(outputOption);
105+
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) => {
104106
var requestInfo = CreateGetRequestInformation(q => {
105107
q.Top = top;
106108
q.Skip = skip;
@@ -111,15 +113,10 @@ public Command BuildListCommand() {
111113
q.Select = select;
112114
q.Expand = expand;
113115
});
114-
var result = await RequestAdapter.SendAsync<HealthOverviewsResponse>(requestInfo);
115-
// Print request output. What if the request has no return?
116-
using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json");
117-
serializer.WriteObjectValue(null, result);
118-
using var content = serializer.GetSerializedContent();
119-
using var reader = new StreamReader(content);
120-
var strContent = await reader.ReadToEndAsync();
121-
Console.Write(strContent + "\n");
122-
}, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption);
116+
var response = await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping: default, cancellationToken: cancellationToken);
117+
var formatter = outputFormatterFactory.GetFormatter(output);
118+
formatter.WriteOutput(response);
119+
}, topOption, skipOption, searchOption, filterOption, countOption, orderbyOption, selectOption, expandOption, outputOption);
123120
return command;
124121
}
125122
/// <summary>
@@ -174,31 +171,6 @@ public RequestInformation CreatePostRequestInformation(ServiceHealth body, Actio
174171
requestInfo.AddRequestOptions(o?.ToArray());
175172
return requestInfo;
176173
}
177-
/// <summary>
178-
/// A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly.
179-
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
180-
/// <param name="h">Request headers</param>
181-
/// <param name="o">Request options</param>
182-
/// <param name="q">Request query parameters</param>
183-
/// <param name="responseHandler">Response handler to use in place of the default response handling provided by the core service</param>
184-
/// </summary>
185-
public async Task<HealthOverviewsResponse> GetAsync(Action<GetQueryParameters> q = default, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) {
186-
var requestInfo = CreateGetRequestInformation(q, h, o);
187-
return await RequestAdapter.SendAsync<HealthOverviewsResponse>(requestInfo, responseHandler, cancellationToken);
188-
}
189-
/// <summary>
190-
/// A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly.
191-
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
192-
/// <param name="h">Request headers</param>
193-
/// <param name="model"></param>
194-
/// <param name="o">Request options</param>
195-
/// <param name="responseHandler">Response handler to use in place of the default response handling provided by the core service</param>
196-
/// </summary>
197-
public async Task<ServiceHealth> PostAsync(ServiceHealth model, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default, IResponseHandler responseHandler = default, CancellationToken cancellationToken = default) {
198-
_ = model ?? throw new ArgumentNullException(nameof(model));
199-
var requestInfo = CreatePostRequestInformation(model, h, o);
200-
return await RequestAdapter.SendAsync<ServiceHealth>(requestInfo, responseHandler, cancellationToken);
201-
}
202174
/// <summary>A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly.</summary>
203175
public class GetQueryParameters : QueryParametersBase {
204176
/// <summary>Include count of items</summary>

0 commit comments

Comments
 (0)