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

Commit 4469cdb

Browse files
committed
Add generated code
1 parent 8437ae9 commit 4469cdb

File tree

10,078 files changed

+1051987
-3
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,078 files changed

+1051987
-3
lines changed

src/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.CommandLine;
2+
using System.Threading.Tasks;
23

34
namespace Microsoft.Graph.Cli
45
{
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
using ApiSdk.Admin.ServiceAnnouncement;
2+
using ApiSdk.Models.Microsoft.Graph;
3+
using Microsoft.Kiota.Abstractions;
4+
using Microsoft.Kiota.Abstractions.Serialization;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.CommandLine;
8+
using System.CommandLine.Invocation;
9+
using System.IO;
10+
using System.Linq;
11+
using System.Text;
12+
using System.Threading.Tasks;
13+
namespace ApiSdk.Admin {
14+
/// <summary>Builds and executes requests for operations under \admin</summary>
15+
public class AdminRequestBuilder {
16+
/// <summary>Path parameters for the request</summary>
17+
private Dictionary<string, object> PathParameters { get; set; }
18+
/// <summary>The request adapter to use to execute the requests.</summary>
19+
private IRequestAdapter RequestAdapter { get; set; }
20+
/// <summary>Url template to use to build the URL for the current request builder</summary>
21+
private string UrlTemplate { get; set; }
22+
/// <summary>
23+
/// Get admin
24+
/// </summary>
25+
public Command BuildGetCommand() {
26+
var command = new Command("get");
27+
// Create options for all the parameters
28+
command.AddOption(new Option<object>("--select", description: "Select properties to be returned"));
29+
command.AddOption(new Option<object>("--expand", description: "Expand related entities"));
30+
command.Handler = CommandHandler.Create<object, object>(async (select, expand) => {
31+
var requestInfo = CreateGetRequestInformation();
32+
requestInfo.QueryParameters.Add("select", select);
33+
requestInfo.QueryParameters.Add("expand", expand);
34+
var result = await RequestAdapter.SendAsync<ApiSdk.Models.Microsoft.Graph.Admin>(requestInfo);
35+
// Print request output. What if the request has no return?
36+
using var serializer = RequestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json");
37+
serializer.WriteObjectValue(null, result);
38+
using var content = serializer.GetSerializedContent();
39+
using var reader = new StreamReader(content);
40+
var strContent = await reader.ReadToEndAsync();
41+
Console.Write(strContent + "\n");
42+
});
43+
return command;
44+
}
45+
/// <summary>
46+
/// Update admin
47+
/// </summary>
48+
public Command BuildPatchCommand() {
49+
var command = new Command("patch");
50+
// Create options for all the parameters
51+
command.AddOption(new Option<string>("--body"));
52+
command.Handler = CommandHandler.Create<string>(async (body) => {
53+
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body));
54+
var parseNode = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream);
55+
var model = parseNode.GetObjectValue<ApiSdk.Models.Microsoft.Graph.Admin>();
56+
var requestInfo = CreatePatchRequestInformation(model);
57+
await RequestAdapter.SendNoContentAsync(requestInfo);
58+
// Print request output. What if the request has no return?
59+
Console.WriteLine("Success");
60+
});
61+
return command;
62+
}
63+
public Command BuildServiceAnnouncementCommand() {
64+
var command = new Command("service-announcement");
65+
var builder = new ApiSdk.Admin.ServiceAnnouncement.ServiceAnnouncementRequestBuilder(PathParameters, RequestAdapter);
66+
command.AddCommand(builder.BuildIssuesCommand());
67+
command.AddCommand(builder.BuildHealthOverviewsCommand());
68+
command.AddCommand(builder.BuildPatchCommand());
69+
command.AddCommand(builder.BuildGetCommand());
70+
command.AddCommand(builder.BuildMessagesCommand());
71+
command.AddCommand(builder.BuildDeleteCommand());
72+
return command;
73+
}
74+
/// <summary>
75+
/// Instantiates a new AdminRequestBuilder and sets the default values.
76+
/// <param name="pathParameters">Path parameters for the request</param>
77+
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
78+
/// </summary>
79+
public AdminRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) {
80+
_ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters));
81+
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
82+
UrlTemplate = "{+baseurl}/admin{?select,expand}";
83+
var urlTplParams = new Dictionary<string, object>(pathParameters);
84+
PathParameters = urlTplParams;
85+
RequestAdapter = requestAdapter;
86+
}
87+
/// <summary>
88+
/// Get admin
89+
/// <param name="h">Request headers</param>
90+
/// <param name="o">Request options</param>
91+
/// <param name="q">Request query parameters</param>
92+
/// </summary>
93+
public RequestInformation CreateGetRequestInformation(Action<GetQueryParameters> q = default, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default) {
94+
var requestInfo = new RequestInformation {
95+
HttpMethod = HttpMethod.GET,
96+
UrlTemplate = UrlTemplate,
97+
PathParameters = PathParameters,
98+
};
99+
if (q != null) {
100+
var qParams = new GetQueryParameters();
101+
q.Invoke(qParams);
102+
qParams.AddQueryParameters(requestInfo.QueryParameters);
103+
}
104+
h?.Invoke(requestInfo.Headers);
105+
requestInfo.AddRequestOptions(o?.ToArray());
106+
return requestInfo;
107+
}
108+
/// <summary>
109+
/// Update admin
110+
/// <param name="body"></param>
111+
/// <param name="h">Request headers</param>
112+
/// <param name="o">Request options</param>
113+
/// </summary>
114+
public RequestInformation CreatePatchRequestInformation(ApiSdk.Models.Microsoft.Graph.Admin body, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default) {
115+
_ = body ?? throw new ArgumentNullException(nameof(body));
116+
var requestInfo = new RequestInformation {
117+
HttpMethod = HttpMethod.PATCH,
118+
UrlTemplate = UrlTemplate,
119+
PathParameters = PathParameters,
120+
};
121+
requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
122+
h?.Invoke(requestInfo.Headers);
123+
requestInfo.AddRequestOptions(o?.ToArray());
124+
return requestInfo;
125+
}
126+
/// <summary>
127+
/// Get admin
128+
/// <param name="h">Request headers</param>
129+
/// <param name="o">Request options</param>
130+
/// <param name="q">Request query parameters</param>
131+
/// <param name="responseHandler">Response handler to use in place of the default response handling provided by the core service</param>
132+
/// </summary>
133+
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) {
134+
var requestInfo = CreateGetRequestInformation(q, h, o);
135+
return await RequestAdapter.SendAsync<ApiSdk.Models.Microsoft.Graph.Admin>(requestInfo, responseHandler);
136+
}
137+
/// <summary>
138+
/// Update admin
139+
/// <param name="h">Request headers</param>
140+
/// <param name="model"></param>
141+
/// <param name="o">Request options</param>
142+
/// <param name="responseHandler">Response handler to use in place of the default response handling provided by the core service</param>
143+
/// </summary>
144+
public async Task PatchAsync(ApiSdk.Models.Microsoft.Graph.Admin model, Action<IDictionary<string, string>> h = default, IEnumerable<IRequestOption> o = default, IResponseHandler responseHandler = default) {
145+
_ = model ?? throw new ArgumentNullException(nameof(model));
146+
var requestInfo = CreatePatchRequestInformation(model, h, o);
147+
await RequestAdapter.SendNoContentAsync(requestInfo, responseHandler);
148+
}
149+
/// <summary>Get admin</summary>
150+
public class GetQueryParameters : QueryParametersBase {
151+
/// <summary>Expand related entities</summary>
152+
public string[] Expand { get; set; }
153+
/// <summary>Select properties to be returned</summary>
154+
public string[] Select { get; set; }
155+
}
156+
}
157+
}

0 commit comments

Comments
 (0)