public Command BuildGetCommand() {
var command = new Command("get");
command.Description = "The groups, directory roles and administrative units that the user is a member of. Read-only. Nullable. Supports $expand.";
// Create options for all the parameters
var userIdOption = new Option<string>("--user-id", description: "key: id of user") {
};
userIdOption.IsRequired = true;
command.AddOption(userIdOption);
var directoryObjectIdOption = new Option<string>("--directory-object-id", description: "key: id of directoryObject") {
};
directoryObjectIdOption.IsRequired = true;
command.AddOption(directoryObjectIdOption);
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){
IsRequired = true
};
command.AddOption(outputOption);
var queryOption = new Option<string>("--query");
command.AddOption(queryOption);
var jsonNoIndentOption = new Option<bool>("--json-no-indent", r => {
if (bool.TryParse(r.Tokens.Select(t => t.Value).LastOrDefault(), out var value)) {
return value;
}
return true;
}, description: "Disable indentation for the JSON output formatter.");
command.AddOption(jsonNoIndentOption);
command.SetHandler(async (object[] parameters) => {
var userId = (string) parameters[0];
var directoryObjectId = (string) parameters[1];
var select = (string[]) parameters[2];
var expand = (string[]) parameters[3];
var output = (FormatterType) parameters[4];
var query = (string) parameters[5];
var jsonNoIndent = (bool) parameters[6];
var outputFilter = (IOutputFilter) parameters[7];
var outputFormatterFactory = (IOutputFormatterFactory) parameters[8];
var cancellationToken = (CancellationToken) parameters[9];
var requestInfo = CreateGetRequestInformation(q => {
q.QueryParameters.Select = select;
q.QueryParameters.Expand = expand;
});
requestInfo.PathParameters.Add("user%2Did", userId);
requestInfo.PathParameters.Add("directoryObject%2Did", directoryObjectId);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"4XX", ODataError.CreateFromDiscriminatorValue},
{"5XX", ODataError.CreateFromDiscriminatorValue},
};
var response = await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping: errorMapping, cancellationToken: cancellationToken);
response = await outputFilter?.FilterOutputAsync(response, query, cancellationToken) ?? response;
var formatterOptions = output.GetOutputFormatterOptions(new FormatterOptionsModel(!jsonNoIndent));
var formatter = outputFormatterFactory.GetFormatter(output);
await formatter.WriteOutputAsync(response, formatterOptions, cancellationToken);
}, new CollectionBinding(userIdOption, directoryObjectIdOption, selectOption, expandOption, outputOption, queryOption, jsonNoIndentOption, new TypeBinding(typeof(IOutputFilter)), new TypeBinding(typeof(IOutputFormatterFactory)), new TypeBinding(typeof(CancellationToken))));
return command;
}
/// <summary>