This repository was archived by the owner on Aug 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathEdgeRequestBuilder.cs
More file actions
275 lines (275 loc) · 14.7 KB
/
EdgeRequestBuilder.cs
File metadata and controls
275 lines (275 loc) · 14.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
// <auto-generated/>
#pragma warning disable CS0618
using ApiSdk.Admin.Edge.InternetExplorerMode;
using ApiSdk.Models.ODataErrors;
using ApiSdk.Models;
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions.Serialization;
using Microsoft.Kiota.Abstractions;
using Microsoft.Kiota.Cli.Commons.Extensions;
using Microsoft.Kiota.Cli.Commons.IO;
using Microsoft.Kiota.Cli.Commons;
using System.Collections.Generic;
using System.CommandLine;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System;
namespace ApiSdk.Admin.Edge
{
/// <summary>
/// Provides operations to manage the edge property of the microsoft.graph.admin entity.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
public partial class EdgeRequestBuilder : BaseCliRequestBuilder
{
/// <summary>
/// Delete navigation property edge for admin
/// </summary>
/// <returns>A <see cref="Command"/></returns>
public Command BuildDeleteCommand()
{
var command = new Command("delete");
command.Description = "Delete navigation property edge for admin";
var ifMatchOption = new Option<string[]>("--if-match", description: "ETag") {
Arity = ArgumentArity.ZeroOrMore
};
ifMatchOption.IsRequired = false;
command.AddOption(ifMatchOption);
command.SetHandler(async (invocationContext) => {
var ifMatch = invocationContext.ParseResult.GetValueForOption(ifMatchOption);
var cancellationToken = invocationContext.GetCancellationToken();
var reqAdapter = invocationContext.GetRequestAdapter();
var requestInfo = ToDeleteRequestInformation(q => {
});
if (ifMatch is not null) requestInfo.Headers.Add("If-Match", ifMatch);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"4XX", ODataError.CreateFromDiscriminatorValue},
{"5XX", ODataError.CreateFromDiscriminatorValue},
};
await reqAdapter.SendNoContentAsync(requestInfo, errorMapping: errorMapping, cancellationToken: cancellationToken);
Console.WriteLine("Success");
});
return command;
}
/// <summary>
/// A container for Microsoft Edge resources. Read-only.
/// </summary>
/// <returns>A <see cref="Command"/></returns>
public Command BuildGetCommand()
{
var command = new Command("get");
command.Description = "A container for Microsoft Edge resources. Read-only.";
var selectOption = new Option<string[]>("--select", description: "Select properties to be returned") {
Arity = ArgumentArity.ZeroOrMore
};
selectOption.IsRequired = false;
command.AddOption(selectOption);
var expandOption = new Option<string[]>("--expand", description: "Expand related entities") {
Arity = ArgumentArity.ZeroOrMore
};
expandOption.IsRequired = false;
command.AddOption(expandOption);
var outputOption = new Option<FormatterType>("--output", () => FormatterType.JSON);
command.AddOption(outputOption);
var queryOption = new Option<string>("--query");
command.AddOption(queryOption);
command.SetHandler(async (invocationContext) => {
var select = invocationContext.ParseResult.GetValueForOption(selectOption);
var expand = invocationContext.ParseResult.GetValueForOption(expandOption);
var output = invocationContext.ParseResult.GetValueForOption(outputOption);
var query = invocationContext.ParseResult.GetValueForOption(queryOption);
IOutputFilter outputFilter = invocationContext.BindingContext.GetService(typeof(IOutputFilter)) as IOutputFilter ?? throw new ArgumentNullException("outputFilter");
IOutputFormatterFactory outputFormatterFactory = invocationContext.BindingContext.GetService(typeof(IOutputFormatterFactory)) as IOutputFormatterFactory ?? throw new ArgumentNullException("outputFormatterFactory");
var cancellationToken = invocationContext.GetCancellationToken();
var reqAdapter = invocationContext.GetRequestAdapter();
var requestInfo = ToGetRequestInformation(q => {
q.QueryParameters.Select = select;
q.QueryParameters.Expand = expand;
});
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"4XX", ODataError.CreateFromDiscriminatorValue},
{"5XX", ODataError.CreateFromDiscriminatorValue},
};
var response = await reqAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping: errorMapping, cancellationToken: cancellationToken) ?? Stream.Null;
response = (response != Stream.Null) ? await outputFilter.FilterOutputAsync(response, query, cancellationToken) : response;
var formatter = outputFormatterFactory.GetFormatter(output);
await formatter.WriteOutputAsync(response, cancellationToken);
});
return command;
}
/// <summary>
/// Provides operations to manage the internetExplorerMode property of the microsoft.graph.edge entity.
/// </summary>
/// <returns>A <see cref="Command"/></returns>
public Command BuildInternetExplorerModeNavCommand()
{
var command = new Command("internet-explorer-mode");
command.Description = "Provides operations to manage the internetExplorerMode property of the microsoft.graph.edge entity.";
var builder = new global::ApiSdk.Admin.Edge.InternetExplorerMode.InternetExplorerModeRequestBuilder(PathParameters);
var execCommands = new List<Command>();
var nonExecCommands = new List<Command>();
execCommands.Add(builder.BuildDeleteCommand());
execCommands.Add(builder.BuildGetCommand());
execCommands.Add(builder.BuildPatchCommand());
nonExecCommands.Add(builder.BuildSiteListsNavCommand());
foreach (var cmd in execCommands)
{
command.AddCommand(cmd);
}
foreach (var cmd in nonExecCommands)
{
command.AddCommand(cmd);
}
return command;
}
/// <summary>
/// Update the navigation property edge in admin
/// </summary>
/// <returns>A <see cref="Command"/></returns>
public Command BuildPatchCommand()
{
var command = new Command("patch");
command.Description = "Update the navigation property edge in admin";
var bodyOption = new Option<string>("--body", description: "The request body") {
};
bodyOption.IsRequired = true;
command.AddOption(bodyOption);
var outputOption = new Option<FormatterType>("--output", () => FormatterType.JSON);
command.AddOption(outputOption);
var queryOption = new Option<string>("--query");
command.AddOption(queryOption);
command.SetHandler(async (invocationContext) => {
var body = invocationContext.ParseResult.GetValueForOption(bodyOption) ?? string.Empty;
var output = invocationContext.ParseResult.GetValueForOption(outputOption);
var query = invocationContext.ParseResult.GetValueForOption(queryOption);
IOutputFilter outputFilter = invocationContext.BindingContext.GetService(typeof(IOutputFilter)) as IOutputFilter ?? throw new ArgumentNullException("outputFilter");
IOutputFormatterFactory outputFormatterFactory = invocationContext.BindingContext.GetService(typeof(IOutputFormatterFactory)) as IOutputFormatterFactory ?? throw new ArgumentNullException("outputFormatterFactory");
var cancellationToken = invocationContext.GetCancellationToken();
var reqAdapter = invocationContext.GetRequestAdapter();
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(body));
var parseNode = await ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNodeAsync("application/json", stream, cancellationToken);
var model = parseNode.GetObjectValue<global::ApiSdk.Models.Edge>(global::ApiSdk.Models.Edge.CreateFromDiscriminatorValue);
if (model is null) {
Console.Error.WriteLine("No model data to send.");
return;
}
var requestInfo = ToPatchRequestInformation(model, q => {
});
requestInfo.SetContentFromParsable(reqAdapter, "application/json", model);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"4XX", ODataError.CreateFromDiscriminatorValue},
{"5XX", ODataError.CreateFromDiscriminatorValue},
};
var response = await reqAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping: errorMapping, cancellationToken: cancellationToken) ?? Stream.Null;
response = (response != Stream.Null) ? await outputFilter.FilterOutputAsync(response, query, cancellationToken) : response;
var formatter = outputFormatterFactory.GetFormatter(output);
await formatter.WriteOutputAsync(response, cancellationToken);
});
return command;
}
/// <summary>
/// Instantiates a new <see cref="global::ApiSdk.Admin.Edge.EdgeRequestBuilder"/> and sets the default values.
/// </summary>
/// <param name="pathParameters">Path parameters for the request</param>
public EdgeRequestBuilder(Dictionary<string, object> pathParameters) : base("{+baseurl}/admin/edge{?%24expand,%24select}", pathParameters)
{
}
/// <summary>
/// Instantiates a new <see cref="global::ApiSdk.Admin.Edge.EdgeRequestBuilder"/> and sets the default values.
/// </summary>
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
public EdgeRequestBuilder(string rawUrl) : base("{+baseurl}/admin/edge{?%24expand,%24select}", rawUrl)
{
}
/// <summary>
/// Delete navigation property edge for admin
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public RequestInformation ToDeleteRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default)
{
#nullable restore
#else
public RequestInformation ToDeleteRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default)
{
#endif
var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters);
requestInfo.Configure(requestConfiguration);
requestInfo.Headers.TryAdd("Accept", "application/json");
return requestInfo;
}
/// <summary>
/// A container for Microsoft Edge resources. Read-only.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<global::ApiSdk.Admin.Edge.EdgeRequestBuilder.EdgeRequestBuilderGetQueryParameters>>? requestConfiguration = default)
{
#nullable restore
#else
public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<global::ApiSdk.Admin.Edge.EdgeRequestBuilder.EdgeRequestBuilderGetQueryParameters>> requestConfiguration = default)
{
#endif
var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters);
requestInfo.Configure(requestConfiguration);
requestInfo.Headers.TryAdd("Accept", "application/json");
return requestInfo;
}
/// <summary>
/// Update the navigation property edge in admin
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <param name="body">The request body</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public RequestInformation ToPatchRequestInformation(global::ApiSdk.Models.Edge body, Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default)
{
#nullable restore
#else
public RequestInformation ToPatchRequestInformation(global::ApiSdk.Models.Edge body, Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default)
{
#endif
_ = body ?? throw new ArgumentNullException(nameof(body));
var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters);
requestInfo.Configure(requestConfiguration);
requestInfo.Headers.TryAdd("Accept", "application/json");
return requestInfo;
}
/// <summary>
/// A container for Microsoft Edge resources. Read-only.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
public partial class EdgeRequestBuilderGetQueryParameters
{
/// <summary>Expand related entities</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
[QueryParameter("%24expand")]
public string[]? Expand { get; set; }
#nullable restore
#else
[QueryParameter("%24expand")]
public string[] Expand { get; set; }
#endif
/// <summary>Select properties to be returned</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
[QueryParameter("%24select")]
public string[]? Select { get; set; }
#nullable restore
#else
[QueryParameter("%24select")]
public string[] Select { get; set; }
#endif
}
}
}
#pragma warning restore CS0618