Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated models and request builders #411

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/generated/Admin/AdminRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ public Command BuildPeopleNavCommand() {
var execCommands = new List<Command>();
var nonExecCommands = new List<Command>();
execCommands.Add(builder.BuildGetCommand());
execCommands.Add(builder.BuildPatchCommand());
nonExecCommands.Add(builder.BuildProfileCardPropertiesNavCommand());
nonExecCommands.Add(builder.BuildPronounsNavCommand());
foreach (var cmd in execCommands)
{
command.AddCommand(cmd);
Expand Down
78 changes: 17 additions & 61 deletions src/generated/Admin/People/PeopleRequestBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// <auto-generated/>
using ApiSdk.Admin.People.ProfileCardProperties;
using ApiSdk.Admin.People.Pronouns;
using ApiSdk.Models.ODataErrors;
using ApiSdk.Models;
using Microsoft.Kiota.Abstractions.Serialization;
Expand Down Expand Up @@ -66,49 +67,6 @@ public Command BuildGetCommand() {
return command;
}
/// <summary>
/// Update the navigation property people in admin
/// </summary>
public Command BuildPatchCommand() {
var command = new Command("patch");
command.Description = "Update the navigation property people 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 = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream);
var model = parseNode.GetObjectValue<PeopleAdminSettings>(PeopleAdminSettings.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>
/// Provides operations to manage the profileCardProperties property of the microsoft.graph.peopleAdminSettings entity.
/// </summary>
public Command BuildProfileCardPropertiesNavCommand() {
Expand All @@ -134,6 +92,22 @@ public Command BuildProfileCardPropertiesNavCommand() {
return command;
}
/// <summary>
/// Provides operations to manage the pronouns property of the microsoft.graph.peopleAdminSettings entity.
/// </summary>
public Command BuildPronounsNavCommand() {
var command = new Command("pronouns");
command.Description = "Provides operations to manage the pronouns property of the microsoft.graph.peopleAdminSettings entity.";
var builder = new PronounsRequestBuilder(PathParameters);
var execCommands = new List<Command>();
execCommands.Add(builder.BuildGetCommand());
execCommands.Add(builder.BuildPatchCommand());
foreach (var cmd in execCommands)
{
command.AddCommand(cmd);
}
return command;
}
/// <summary>
/// Instantiates a new PeopleRequestBuilder and sets the default values.
/// </summary>
/// <param name="pathParameters">Path parameters for the request</param>
Expand Down Expand Up @@ -162,24 +136,6 @@ public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<Pe
return requestInfo;
}
/// <summary>
/// Update the navigation property people in admin
/// </summary>
/// <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(PeopleAdminSettings body, Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default) {
#nullable restore
#else
public RequestInformation ToPatchRequestInformation(PeopleAdminSettings 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>
/// Retrieve the properties and relationships of a peopleAdminSettings object.
/// </summary>
public class PeopleRequestBuilderGetQueryParameters {
Expand Down
183 changes: 183 additions & 0 deletions src/generated/Admin/People/Pronouns/PronounsRequestBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
// <auto-generated/>
using ApiSdk.Models.ODataErrors;
using ApiSdk.Models;
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.People.Pronouns {
/// <summary>
/// Provides operations to manage the pronouns property of the microsoft.graph.peopleAdminSettings entity.
/// </summary>
public class PronounsRequestBuilder : BaseCliRequestBuilder {
/// <summary>
/// Get the properties of the pronounsSettings resource for an organization. For more information on settings to manage pronouns support, see Manage pronouns settings for an organization using the Microsoft Graph API.
/// Find more info here <see href="https://learn.microsoft.com/graph/api/peopleadminsettings-list-pronouns?view=graph-rest-1.0" />
/// </summary>
public Command BuildGetCommand() {
var command = new Command("get");
command.Description = "Get the properties of the pronounsSettings resource for an organization. For more information on settings to manage pronouns support, see Manage pronouns settings for an organization using the Microsoft Graph API.\n\nFind more info here:\n https://learn.microsoft.com/graph/api/peopleadminsettings-list-pronouns?view=graph-rest-1.0";
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>
/// Update the properties of a pronounsSettings object in an organization. For more information on settings to manage pronouns support, see Manage pronouns settings for an organization using the Microsoft Graph API.
/// Find more info here <see href="https://learn.microsoft.com/graph/api/pronounssettings-update?view=graph-rest-1.0" />
/// </summary>
public Command BuildPatchCommand() {
var command = new Command("patch");
command.Description = "Update the properties of a pronounsSettings object in an organization. For more information on settings to manage pronouns support, see Manage pronouns settings for an organization using the Microsoft Graph API.\n\nFind more info here:\n https://learn.microsoft.com/graph/api/pronounssettings-update?view=graph-rest-1.0";
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 = ParseNodeFactoryRegistry.DefaultInstance.GetRootParseNode("application/json", stream);
var model = parseNode.GetObjectValue<PronounsSettings>(PronounsSettings.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 PronounsRequestBuilder and sets the default values.
/// </summary>
/// <param name="pathParameters">Path parameters for the request</param>
public PronounsRequestBuilder(Dictionary<string, object> pathParameters) : base("{+baseurl}/admin/people/pronouns{?%24select,%24expand}", pathParameters) {
}
/// <summary>
/// Instantiates a new PronounsRequestBuilder and sets the default values.
/// </summary>
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
public PronounsRequestBuilder(string rawUrl) : base("{+baseurl}/admin/people/pronouns{?%24select,%24expand}", rawUrl) {
}
/// <summary>
/// Get the properties of the pronounsSettings resource for an organization. For more information on settings to manage pronouns support, see Manage pronouns settings for an organization using the Microsoft Graph API.
/// </summary>
/// <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<PronounsRequestBuilderGetQueryParameters>>? requestConfiguration = default) {
#nullable restore
#else
public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<PronounsRequestBuilderGetQueryParameters>> 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 properties of a pronounsSettings object in an organization. For more information on settings to manage pronouns support, see Manage pronouns settings for an organization using the Microsoft Graph API.
/// </summary>
/// <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(PronounsSettings body, Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default) {
#nullable restore
#else
public RequestInformation ToPatchRequestInformation(PronounsSettings 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>
/// Get the properties of the pronounsSettings resource for an organization. For more information on settings to manage pronouns support, see Manage pronouns settings for an organization using the Microsoft Graph API.
/// </summary>
public class PronounsRequestBuilderGetQueryParameters {
/// <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
}
}
}
Loading