diff --git a/Marechai.App/Services/Client/ApiClient.cs b/Marechai.App/Services/Client/ApiClient.cs index c03efe3c..8d534143 100644 --- a/Marechai.App/Services/Client/ApiClient.cs +++ b/Marechai.App/Services/Client/ApiClient.cs @@ -41,6 +41,7 @@ using Marechai.App.Software; using Marechai.App.SoundSynths; using Marechai.App.SoundSynthsByMachine; using Marechai.App.StorageByMachine; +using Marechai.App.Users; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Serialization.Form; @@ -264,6 +265,11 @@ namespace Marechai.App { get => new global::Marechai.App.StorageByMachine.StorageByMachineRequestBuilder(PathParameters, RequestAdapter); } + /// The users property + public global::Marechai.App.Users.UsersRequestBuilder Users + { + get => new global::Marechai.App.Users.UsersRequestBuilder(PathParameters, RequestAdapter); + } /// /// Instantiates a new and sets the default values. /// diff --git a/Marechai.App/Services/Client/Gpus/Item/GpuItemRequestBuilder.cs b/Marechai.App/Services/Client/Gpus/Item/GpuItemRequestBuilder.cs new file mode 100644 index 00000000..021df8c0 --- /dev/null +++ b/Marechai.App/Services/Client/Gpus/Item/GpuItemRequestBuilder.cs @@ -0,0 +1,198 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Gpus.Item.Machines; +using Marechai.App.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.Gpus.Item +{ + /// + /// Builds and executes requests for operations under \gpus\{gpu-id} + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class GpuItemRequestBuilder : BaseRequestBuilder + { + /// The machines property + public global::Marechai.App.Gpus.Item.Machines.MachinesRequestBuilder Machines + { + get => new global::Marechai.App.Gpus.Item.Machines.MachinesRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public GpuItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/gpus/{gpu%2Did}", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public GpuItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/gpus/{gpu%2Did}", rawUrl) + { + } + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 401 status code + /// When receiving a 404 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::Marechai.App.Models.GpuDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 401 status code + /// When receiving a 404 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PutAsync(global::Marechai.App.Models.GpuDto body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task PutAsync(global::Marechai.App.Models.GpuDto body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPutRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendPrimitiveAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToDeleteRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json, text/plain;q=0.9"); + return requestInfo; + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json, text/plain;q=0.9"); + return requestInfo; + } + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPutRequestInformation(global::Marechai.App.Models.GpuDto body, Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToPutRequestInformation(global::Marechai.App.Models.GpuDto body, Action> requestConfiguration = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PUT, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json, text/plain;q=0.9"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.Gpus.Item.GpuItemRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.Gpus.Item.GpuItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class GpuItemRequestBuilderDeleteRequestConfiguration : RequestConfiguration + { + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class GpuItemRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class GpuItemRequestBuilderPutRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Gpus/Item/Machines/MachinesRequestBuilder.cs b/Marechai.App/Services/Client/Gpus/Item/Machines/MachinesRequestBuilder.cs new file mode 100644 index 00000000..933de615 --- /dev/null +++ b/Marechai.App/Services/Client/Gpus/Item/Machines/MachinesRequestBuilder.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.Gpus.Item.Machines +{ + /// + /// Builds and executes requests for operations under \gpus\{gpu-id}\machines + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class MachinesRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public MachinesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/gpus/{gpu%2Did}/machines", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public MachinesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/gpus/{gpu%2Did}/machines", rawUrl) + { + } + /// A List<global::Marechai.App.Models.MachineDto> + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + var collectionResult = await RequestAdapter.SendCollectionAsync(requestInfo, global::Marechai.App.Models.MachineDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + return collectionResult?.AsList(); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "text/plain;q=0.9"); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.Gpus.Item.Machines.MachinesRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.Gpus.Item.Machines.MachinesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class MachinesRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Models/ChangePasswordRequest.cs b/Marechai.App/Services/Client/Models/ChangePasswordRequest.cs new file mode 100644 index 00000000..f45b3c0e --- /dev/null +++ b/Marechai.App/Services/Client/Models/ChangePasswordRequest.cs @@ -0,0 +1,65 @@ +// +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace Marechai.App.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ChangePasswordRequest : IAdditionalDataHolder, IParsable + #pragma warning restore CS1591 + { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// The newPassword property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? NewPassword { get; set; } +#nullable restore +#else + public string NewPassword { get; set; } +#endif + /// + /// Instantiates a new and sets the default values. + /// + public ChangePasswordRequest() + { + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::Marechai.App.Models.ChangePasswordRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); + return new global::Marechai.App.Models.ChangePasswordRequest(); + } + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "newPassword", n => { NewPassword = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) + { + if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("newPassword", NewPassword); + writer.WriteAdditionalData(AdditionalData); + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Models/CreateUserRequest.cs b/Marechai.App/Services/Client/Models/CreateUserRequest.cs new file mode 100644 index 00000000..9d0d1f71 --- /dev/null +++ b/Marechai.App/Services/Client/Models/CreateUserRequest.cs @@ -0,0 +1,95 @@ +// +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace Marechai.App.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class CreateUserRequest : IAdditionalDataHolder, IParsable + #pragma warning restore CS1591 + { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// The email property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Email { get; set; } +#nullable restore +#else + public string Email { get; set; } +#endif + /// The password property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Password { get; set; } +#nullable restore +#else + public string Password { get; set; } +#endif + /// The phoneNumber property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? PhoneNumber { get; set; } +#nullable restore +#else + public string PhoneNumber { get; set; } +#endif + /// The userName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? UserName { get; set; } +#nullable restore +#else + public string UserName { get; set; } +#endif + /// + /// Instantiates a new and sets the default values. + /// + public CreateUserRequest() + { + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::Marechai.App.Models.CreateUserRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); + return new global::Marechai.App.Models.CreateUserRequest(); + } + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "email", n => { Email = n.GetStringValue(); } }, + { "password", n => { Password = n.GetStringValue(); } }, + { "phoneNumber", n => { PhoneNumber = n.GetStringValue(); } }, + { "userName", n => { UserName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) + { + if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("email", Email); + writer.WriteStringValue("password", Password); + writer.WriteStringValue("phoneNumber", PhoneNumber); + writer.WriteStringValue("userName", UserName); + writer.WriteAdditionalData(AdditionalData); + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Models/UpdateUserRequest.cs b/Marechai.App/Services/Client/Models/UpdateUserRequest.cs new file mode 100644 index 00000000..ffd151a9 --- /dev/null +++ b/Marechai.App/Services/Client/Models/UpdateUserRequest.cs @@ -0,0 +1,93 @@ +// +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace Marechai.App.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UpdateUserRequest : IAdditionalDataHolder, IParsable + #pragma warning restore CS1591 + { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// The email property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Email { get; set; } +#nullable restore +#else + public string Email { get; set; } +#endif + /// The emailConfirmed property + public bool? EmailConfirmed { get; set; } + /// The lockoutEnabled property + public bool? LockoutEnabled { get; set; } + /// The phoneNumber property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? PhoneNumber { get; set; } +#nullable restore +#else + public string PhoneNumber { get; set; } +#endif + /// The userName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? UserName { get; set; } +#nullable restore +#else + public string UserName { get; set; } +#endif + /// + /// Instantiates a new and sets the default values. + /// + public UpdateUserRequest() + { + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::Marechai.App.Models.UpdateUserRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); + return new global::Marechai.App.Models.UpdateUserRequest(); + } + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "email", n => { Email = n.GetStringValue(); } }, + { "emailConfirmed", n => { EmailConfirmed = n.GetBoolValue(); } }, + { "lockoutEnabled", n => { LockoutEnabled = n.GetBoolValue(); } }, + { "phoneNumber", n => { PhoneNumber = n.GetStringValue(); } }, + { "userName", n => { UserName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) + { + if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("email", Email); + writer.WriteBoolValue("emailConfirmed", EmailConfirmed); + writer.WriteBoolValue("lockoutEnabled", LockoutEnabled); + writer.WriteStringValue("phoneNumber", PhoneNumber); + writer.WriteStringValue("userName", UserName); + writer.WriteAdditionalData(AdditionalData); + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Models/UserDto.cs b/Marechai.App/Services/Client/Models/UserDto.cs new file mode 100644 index 00000000..275e4a5c --- /dev/null +++ b/Marechai.App/Services/Client/Models/UserDto.cs @@ -0,0 +1,131 @@ +// +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace Marechai.App.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UserDto : IAdditionalDataHolder, IParsable + #pragma warning restore CS1591 + { + /// The accessFailedCount property + public int? AccessFailedCount { get; set; } + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// The email property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Email { get; set; } +#nullable restore +#else + public string Email { get; set; } +#endif + /// The emailConfirmed property + public bool? EmailConfirmed { get; set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { get; set; } +#nullable restore +#else + public string Id { get; set; } +#endif + /// The lockoutEnabled property + public bool? LockoutEnabled { get; set; } + /// The lockoutEnd property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? LockoutEnd { get; set; } +#nullable restore +#else + public string LockoutEnd { get; set; } +#endif + /// The phoneNumber property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? PhoneNumber { get; set; } +#nullable restore +#else + public string PhoneNumber { get; set; } +#endif + /// The phoneNumberConfirmed property + public bool? PhoneNumberConfirmed { get; set; } + /// The roles property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Roles { get; set; } +#nullable restore +#else + public List Roles { get; set; } +#endif + /// The userName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? UserName { get; set; } +#nullable restore +#else + public string UserName { get; set; } +#endif + /// + /// Instantiates a new and sets the default values. + /// + public UserDto() + { + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::Marechai.App.Models.UserDto CreateFromDiscriminatorValue(IParseNode parseNode) + { + if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); + return new global::Marechai.App.Models.UserDto(); + } + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "accessFailedCount", n => { AccessFailedCount = n.GetIntValue(); } }, + { "email", n => { Email = n.GetStringValue(); } }, + { "emailConfirmed", n => { EmailConfirmed = n.GetBoolValue(); } }, + { "id", n => { Id = n.GetStringValue(); } }, + { "lockoutEnabled", n => { LockoutEnabled = n.GetBoolValue(); } }, + { "lockoutEnd", n => { LockoutEnd = n.GetStringValue(); } }, + { "phoneNumber", n => { PhoneNumber = n.GetStringValue(); } }, + { "phoneNumberConfirmed", n => { PhoneNumberConfirmed = n.GetBoolValue(); } }, + { "roles", n => { Roles = n.GetCollectionOfPrimitiveValues()?.AsList(); } }, + { "userName", n => { UserName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) + { + if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer)); + writer.WriteIntValue("accessFailedCount", AccessFailedCount); + writer.WriteStringValue("email", Email); + writer.WriteBoolValue("emailConfirmed", EmailConfirmed); + writer.WriteStringValue("id", Id); + writer.WriteBoolValue("lockoutEnabled", LockoutEnabled); + writer.WriteStringValue("lockoutEnd", LockoutEnd); + writer.WriteStringValue("phoneNumber", PhoneNumber); + writer.WriteBoolValue("phoneNumberConfirmed", PhoneNumberConfirmed); + writer.WriteCollectionOfPrimitiveValues("roles", Roles); + writer.WriteStringValue("userName", UserName); + writer.WriteAdditionalData(AdditionalData); + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Models/UserRoleRequest.cs b/Marechai.App/Services/Client/Models/UserRoleRequest.cs new file mode 100644 index 00000000..8ba99e05 --- /dev/null +++ b/Marechai.App/Services/Client/Models/UserRoleRequest.cs @@ -0,0 +1,65 @@ +// +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace Marechai.App.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UserRoleRequest : IAdditionalDataHolder, IParsable + #pragma warning restore CS1591 + { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { get; set; } + /// The roleName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? RoleName { get; set; } +#nullable restore +#else + public string RoleName { get; set; } +#endif + /// + /// Instantiates a new and sets the default values. + /// + public UserRoleRequest() + { + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::Marechai.App.Models.UserRoleRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); + return new global::Marechai.App.Models.UserRoleRequest(); + } + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "roleName", n => { RoleName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) + { + if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("roleName", RoleName); + writer.WriteAdditionalData(AdditionalData); + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/ProcessorsByMachine/ByProcessor/ByProcessorRequestBuilder.cs b/Marechai.App/Services/Client/ProcessorsByMachine/ByProcessor/ByProcessorRequestBuilder.cs new file mode 100644 index 00000000..9c282fab --- /dev/null +++ b/Marechai.App/Services/Client/ProcessorsByMachine/ByProcessor/ByProcessorRequestBuilder.cs @@ -0,0 +1,61 @@ +// +#pragma warning disable CS0618 +using Marechai.App.ProcessorsByMachine.ByProcessor.Item; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System; +namespace Marechai.App.ProcessorsByMachine.ByProcessor +{ + /// + /// Builds and executes requests for operations under \processors-by-machine\by-processor + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class ByProcessorRequestBuilder : BaseRequestBuilder + { + /// Gets an item from the Marechai.App.processorsByMachine.byProcessor.item collection + /// Unique identifier of the item + /// A + public global::Marechai.App.ProcessorsByMachine.ByProcessor.Item.WithProcessorItemRequestBuilder this[int position] + { + get + { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("processorId", position); + return new global::Marechai.App.ProcessorsByMachine.ByProcessor.Item.WithProcessorItemRequestBuilder(urlTplParams, RequestAdapter); + } + } + /// Gets an item from the Marechai.App.processorsByMachine.byProcessor.item collection + /// Unique identifier of the item + /// A + [Obsolete("This indexer is deprecated and will be removed in the next major version. Use the one with the typed parameter instead.")] + public global::Marechai.App.ProcessorsByMachine.ByProcessor.Item.WithProcessorItemRequestBuilder this[string position] + { + get + { + var urlTplParams = new Dictionary(PathParameters); + if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("processorId", position); + return new global::Marechai.App.ProcessorsByMachine.ByProcessor.Item.WithProcessorItemRequestBuilder(urlTplParams, RequestAdapter); + } + } + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ByProcessorRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/processors-by-machine/by-processor", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ByProcessorRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/processors-by-machine/by-processor", rawUrl) + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/ProcessorsByMachine/ByProcessor/Item/WithProcessorItemRequestBuilder.cs b/Marechai.App/Services/Client/ProcessorsByMachine/ByProcessor/Item/WithProcessorItemRequestBuilder.cs new file mode 100644 index 00000000..d6f28421 --- /dev/null +++ b/Marechai.App/Services/Client/ProcessorsByMachine/ByProcessor/Item/WithProcessorItemRequestBuilder.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.ProcessorsByMachine.ByProcessor.Item +{ + /// + /// Builds and executes requests for operations under \processors-by-machine\by-processor\{processorId} + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class WithProcessorItemRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public WithProcessorItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/processors-by-machine/by-processor/{processorId}", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public WithProcessorItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/processors-by-machine/by-processor/{processorId}", rawUrl) + { + } + /// A List<global::Marechai.App.Models.ProcessorByMachineDto> + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + var collectionResult = await RequestAdapter.SendCollectionAsync(requestInfo, global::Marechai.App.Models.ProcessorByMachineDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + return collectionResult?.AsList(); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "text/plain;q=0.9"); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.ProcessorsByMachine.ByProcessor.Item.WithProcessorItemRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.ProcessorsByMachine.ByProcessor.Item.WithProcessorItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class WithProcessorItemRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/ResolutionsByGpu/Gpus/Item/WithGpuItemRequestBuilder.cs b/Marechai.App/Services/Client/ResolutionsByGpu/Gpus/Item/WithGpuItemRequestBuilder.cs new file mode 100644 index 00000000..a3fd9c1a --- /dev/null +++ b/Marechai.App/Services/Client/ResolutionsByGpu/Gpus/Item/WithGpuItemRequestBuilder.cs @@ -0,0 +1,41 @@ +// +#pragma warning disable CS0618 +using Marechai.App.ResolutionsByGpu.Gpus.Item.Resolutions; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System; +namespace Marechai.App.ResolutionsByGpu.Gpus.Item +{ + /// + /// Builds and executes requests for operations under \resolutions-by-gpu\gpus\{gpuId} + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class WithGpuItemRequestBuilder : BaseRequestBuilder + { + /// The resolutions property + public global::Marechai.App.ResolutionsByGpu.Gpus.Item.Resolutions.ResolutionsRequestBuilder Resolutions + { + get => new global::Marechai.App.ResolutionsByGpu.Gpus.Item.Resolutions.ResolutionsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public WithGpuItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/resolutions-by-gpu/gpus/{gpuId}", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public WithGpuItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/resolutions-by-gpu/gpus/{gpuId}", rawUrl) + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/SoundSynthsByMachine/BySoundSynth/BySoundSynthRequestBuilder.cs b/Marechai.App/Services/Client/SoundSynthsByMachine/BySoundSynth/BySoundSynthRequestBuilder.cs new file mode 100644 index 00000000..da978720 --- /dev/null +++ b/Marechai.App/Services/Client/SoundSynthsByMachine/BySoundSynth/BySoundSynthRequestBuilder.cs @@ -0,0 +1,61 @@ +// +#pragma warning disable CS0618 +using Marechai.App.SoundSynthsByMachine.BySoundSynth.Item; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System; +namespace Marechai.App.SoundSynthsByMachine.BySoundSynth +{ + /// + /// Builds and executes requests for operations under \sound-synths-by-machine\by-sound-synth + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class BySoundSynthRequestBuilder : BaseRequestBuilder + { + /// Gets an item from the Marechai.App.soundSynthsByMachine.bySoundSynth.item collection + /// Unique identifier of the item + /// A + public global::Marechai.App.SoundSynthsByMachine.BySoundSynth.Item.WithSoundSynthItemRequestBuilder this[int position] + { + get + { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("soundSynthId", position); + return new global::Marechai.App.SoundSynthsByMachine.BySoundSynth.Item.WithSoundSynthItemRequestBuilder(urlTplParams, RequestAdapter); + } + } + /// Gets an item from the Marechai.App.soundSynthsByMachine.bySoundSynth.item collection + /// Unique identifier of the item + /// A + [Obsolete("This indexer is deprecated and will be removed in the next major version. Use the one with the typed parameter instead.")] + public global::Marechai.App.SoundSynthsByMachine.BySoundSynth.Item.WithSoundSynthItemRequestBuilder this[string position] + { + get + { + var urlTplParams = new Dictionary(PathParameters); + if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("soundSynthId", position); + return new global::Marechai.App.SoundSynthsByMachine.BySoundSynth.Item.WithSoundSynthItemRequestBuilder(urlTplParams, RequestAdapter); + } + } + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public BySoundSynthRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/sound-synths-by-machine/by-sound-synth", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public BySoundSynthRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/sound-synths-by-machine/by-sound-synth", rawUrl) + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/SoundSynthsByMachine/BySoundSynth/Item/WithSoundSynthItemRequestBuilder.cs b/Marechai.App/Services/Client/SoundSynthsByMachine/BySoundSynth/Item/WithSoundSynthItemRequestBuilder.cs new file mode 100644 index 00000000..fafae1da --- /dev/null +++ b/Marechai.App/Services/Client/SoundSynthsByMachine/BySoundSynth/Item/WithSoundSynthItemRequestBuilder.cs @@ -0,0 +1,92 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.SoundSynthsByMachine.BySoundSynth.Item +{ + /// + /// Builds and executes requests for operations under \sound-synths-by-machine\by-sound-synth\{soundSynthId} + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class WithSoundSynthItemRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public WithSoundSynthItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/sound-synths-by-machine/by-sound-synth/{soundSynthId}", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public WithSoundSynthItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/sound-synths-by-machine/by-sound-synth/{soundSynthId}", rawUrl) + { + } + /// A List<global::Marechai.App.Models.SoundSynthByMachineDto> + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + var collectionResult = await RequestAdapter.SendCollectionAsync(requestInfo, global::Marechai.App.Models.SoundSynthByMachineDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + return collectionResult?.AsList(); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "text/plain;q=0.9"); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.SoundSynthsByMachine.BySoundSynth.Item.WithSoundSynthItemRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.SoundSynthsByMachine.BySoundSynth.Item.WithSoundSynthItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class WithSoundSynthItemRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Users/Item/Password/PasswordRequestBuilder.cs b/Marechai.App/Services/Client/Users/Item/Password/PasswordRequestBuilder.cs new file mode 100644 index 00000000..d7b0a5ac --- /dev/null +++ b/Marechai.App/Services/Client/Users/Item/Password/PasswordRequestBuilder.cs @@ -0,0 +1,101 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.Users.Item.Password +{ + /// + /// Builds and executes requests for operations under \users\{id}\password + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class PasswordRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public PasswordRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}/password", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public PasswordRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}/password", rawUrl) + { + } + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 401 status code + /// When receiving a 403 status code + /// When receiving a 404 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(global::Marechai.App.Models.ChangePasswordRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task PostAsync(global::Marechai.App.Models.ChangePasswordRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "403", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPostRequestInformation(global::Marechai.App.Models.ChangePasswordRequest body, Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(global::Marechai.App.Models.ChangePasswordRequest body, Action> requestConfiguration = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json, text/plain;q=0.9"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.Users.Item.Password.PasswordRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.Users.Item.Password.PasswordRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class PasswordRequestBuilderPostRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Users/Item/Roles/Item/WithRoleNameItemRequestBuilder.cs b/Marechai.App/Services/Client/Users/Item/Roles/Item/WithRoleNameItemRequestBuilder.cs new file mode 100644 index 00000000..ec86130b --- /dev/null +++ b/Marechai.App/Services/Client/Users/Item/Roles/Item/WithRoleNameItemRequestBuilder.cs @@ -0,0 +1,96 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.Users.Item.Roles.Item +{ + /// + /// Builds and executes requests for operations under \users\{id}\roles\{roleName} + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class WithRoleNameItemRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public WithRoleNameItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}/roles/{roleName}", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public WithRoleNameItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}/roles/{roleName}", rawUrl) + { + } + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 401 status code + /// When receiving a 403 status code + /// When receiving a 404 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "403", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToDeleteRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json, text/plain;q=0.9"); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.Users.Item.Roles.Item.WithRoleNameItemRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.Users.Item.Roles.Item.WithRoleNameItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class WithRoleNameItemRequestBuilderDeleteRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Users/Item/Roles/RolesRequestBuilder.cs b/Marechai.App/Services/Client/Users/Item/Roles/RolesRequestBuilder.cs new file mode 100644 index 00000000..479d6bfe --- /dev/null +++ b/Marechai.App/Services/Client/Users/Item/Roles/RolesRequestBuilder.cs @@ -0,0 +1,114 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Models; +using Marechai.App.Users.Item.Roles.Item; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.Users.Item.Roles +{ + /// + /// Builds and executes requests for operations under \users\{id}\roles + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class RolesRequestBuilder : BaseRequestBuilder + { + /// Gets an item from the Marechai.App.users.item.roles.item collection + /// Unique identifier of the item + /// A + public global::Marechai.App.Users.Item.Roles.Item.WithRoleNameItemRequestBuilder this[string position] + { + get + { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("roleName", position); + return new global::Marechai.App.Users.Item.Roles.Item.WithRoleNameItemRequestBuilder(urlTplParams, RequestAdapter); + } + } + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RolesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}/roles", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RolesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}/roles", rawUrl) + { + } + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 401 status code + /// When receiving a 403 status code + /// When receiving a 404 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(global::Marechai.App.Models.UserRoleRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task PostAsync(global::Marechai.App.Models.UserRoleRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "403", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPostRequestInformation(global::Marechai.App.Models.UserRoleRequest body, Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(global::Marechai.App.Models.UserRoleRequest body, Action> requestConfiguration = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json, text/plain;q=0.9"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.Users.Item.Roles.RolesRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.Users.Item.Roles.RolesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class RolesRequestBuilderPostRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Users/Item/UsersItemRequestBuilder.cs b/Marechai.App/Services/Client/Users/Item/UsersItemRequestBuilder.cs new file mode 100644 index 00000000..4435825f --- /dev/null +++ b/Marechai.App/Services/Client/Users/Item/UsersItemRequestBuilder.cs @@ -0,0 +1,209 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Models; +using Marechai.App.Users.Item.Password; +using Marechai.App.Users.Item.Roles; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.Users.Item +{ + /// + /// Builds and executes requests for operations under \users\{id} + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class UsersItemRequestBuilder : BaseRequestBuilder + { + /// The password property + public global::Marechai.App.Users.Item.Password.PasswordRequestBuilder Password + { + get => new global::Marechai.App.Users.Item.Password.PasswordRequestBuilder(PathParameters, RequestAdapter); + } + /// The roles property + public global::Marechai.App.Users.Item.Roles.RolesRequestBuilder Roles + { + get => new global::Marechai.App.Users.Item.Roles.RolesRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public UsersItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public UsersItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}", rawUrl) + { + } + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 401 status code + /// When receiving a 403 status code + /// When receiving a 404 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "403", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 401 status code + /// When receiving a 403 status code + /// When receiving a 404 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "403", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::Marechai.App.Models.UserDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 401 status code + /// When receiving a 403 status code + /// When receiving a 404 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PutAsync(global::Marechai.App.Models.UpdateUserRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task PutAsync(global::Marechai.App.Models.UpdateUserRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPutRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "403", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::Marechai.App.Models.UserDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToDeleteRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json, text/plain;q=0.9"); + return requestInfo; + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json"); + return requestInfo; + } + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPutRequestInformation(global::Marechai.App.Models.UpdateUserRequest body, Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToPutRequestInformation(global::Marechai.App.Models.UpdateUserRequest body, Action> requestConfiguration = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PUT, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.Users.Item.UsersItemRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.Users.Item.UsersItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class UsersItemRequestBuilderDeleteRequestConfiguration : RequestConfiguration + { + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class UsersItemRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class UsersItemRequestBuilderPutRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Users/Roles/RolesRequestBuilder.cs b/Marechai.App/Services/Client/Users/Roles/RolesRequestBuilder.cs new file mode 100644 index 00000000..9fc0dfd1 --- /dev/null +++ b/Marechai.App/Services/Client/Users/Roles/RolesRequestBuilder.cs @@ -0,0 +1,94 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Models; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.Users.Roles +{ + /// + /// Builds and executes requests for operations under \users\roles + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class RolesRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RolesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/roles", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RolesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/roles", rawUrl) + { + } + /// A List<string> + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 401 status code + /// When receiving a 403 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "403", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + var collectionResult = await RequestAdapter.SendPrimitiveCollectionAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + return collectionResult?.AsList(); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json"); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.Users.Roles.RolesRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.Users.Roles.RolesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class RolesRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/Users/UsersRequestBuilder.cs b/Marechai.App/Services/Client/Users/UsersRequestBuilder.cs new file mode 100644 index 00000000..e99ee02a --- /dev/null +++ b/Marechai.App/Services/Client/Users/UsersRequestBuilder.cs @@ -0,0 +1,166 @@ +// +#pragma warning disable CS0618 +using Marechai.App.Models; +using Marechai.App.Users.Item; +using Marechai.App.Users.Roles; +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace Marechai.App.Users +{ + /// + /// Builds and executes requests for operations under \users + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class UsersRequestBuilder : BaseRequestBuilder + { + /// The roles property + public global::Marechai.App.Users.Roles.RolesRequestBuilder Roles + { + get => new global::Marechai.App.Users.Roles.RolesRequestBuilder(PathParameters, RequestAdapter); + } + /// Gets an item from the Marechai.App.users.item collection + /// Unique identifier of the item + /// A + public global::Marechai.App.Users.Item.UsersItemRequestBuilder this[string position] + { + get + { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new global::Marechai.App.Users.Item.UsersItemRequestBuilder(urlTplParams, RequestAdapter); + } + } + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public UsersRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users", pathParameters) + { + } + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public UsersRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users", rawUrl) + { + } + /// A List<global::Marechai.App.Models.UserDto> + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 401 status code + /// When receiving a 403 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task?> GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task> GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "403", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + var collectionResult = await RequestAdapter.SendCollectionAsync(requestInfo, global::Marechai.App.Models.UserDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + return collectionResult?.AsList(); + } + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 401 status code + /// When receiving a 403 status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(global::Marechai.App.Models.CreateUserRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task PostAsync(global::Marechai.App.Models.CreateUserRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "401", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "403", global::Marechai.App.Models.ProblemDetails.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::Marechai.App.Models.UserDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json"); + return requestInfo; + } + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPostRequestInformation(global::Marechai.App.Models.CreateUserRequest body, Action>? requestConfiguration = default) + { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(global::Marechai.App.Models.CreateUserRequest body, Action> requestConfiguration = default) + { +#endif + if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::Marechai.App.Users.UsersRequestBuilder WithUrl(string rawUrl) + { + return new global::Marechai.App.Users.UsersRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class UsersRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + /// + /// Configuration for the request such as headers, query parameters, and middleware options. + /// + [Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class UsersRequestBuilderPostRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/Marechai.App/Services/Client/kiota-lock.json b/Marechai.App/Services/Client/kiota-lock.json index c8d6ea80..4d5bb428 100644 --- a/Marechai.App/Services/Client/kiota-lock.json +++ b/Marechai.App/Services/Client/kiota-lock.json @@ -1,34 +1,34 @@ { - "descriptionHash": "C3420A48BBEE846A2606007719F2CB672783E54BFC6264E374C4EE4E7983D3F3D8505882D01625FF9C5A4C3A861D92FB482DCC66804B3CA76FD67E8E10717E5D", - "descriptionLocation": "http://localhost:5023/openapi/v1.json", - "lockFileVersion": "1.0.0", - "kiotaVersion": "1.29.0", - "clientClassName": "ApiClient", - "typeAccessModifier": "Public", - "clientNamespaceName": "Marechai.App", - "language": "CSharp", - "usesBackingStore": false, + "descriptionHash": "1F12C3D431E5804DE0610670BB6E3F6E813834C2AE2B82DDD54DF72B577E977AEA2FF00FC1C309AD40E33BE29228A8A5E988A7997CD2C75EFBB900C28190FAE3", + "descriptionLocation": "http://localhost:5023/openapi/v1.json", + "lockFileVersion": "1.0.0", + "kiotaVersion": "1.29.0", + "clientClassName": "ApiClient", + "typeAccessModifier": "Public", + "clientNamespaceName": "Marechai.App", + "language": "CSharp", + "usesBackingStore": false, "excludeBackwardCompatible": false, - "includeAdditionalData": true, - "disableSSLValidation": false, - "serializers": [ + "includeAdditionalData": true, + "disableSSLValidation": false, + "serializers": [ "Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory", "Microsoft.Kiota.Serialization.Text.TextSerializationWriterFactory", "Microsoft.Kiota.Serialization.Form.FormSerializationWriterFactory", "Microsoft.Kiota.Serialization.Multipart.MultipartSerializationWriterFactory" ], - "deserializers": [ + "deserializers": [ "Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory", "Microsoft.Kiota.Serialization.Text.TextParseNodeFactory", "Microsoft.Kiota.Serialization.Form.FormParseNodeFactory" ], - "structuredMimeTypes": [ + "structuredMimeTypes": [ "application/json", "text/plain;q=0.9", "application/x-www-form-urlencoded;q=0.2", "multipart/form-data;q=0.1" ], - "includePatterns": [], - "excludePatterns": [], - "disabledValidationRules": [] + "includePatterns": [], + "excludePatterns": [], + "disabledValidationRules": [] } \ No newline at end of file diff --git a/Marechai.Data/Models/ChangePasswordRequest.cs b/Marechai.Data/Models/ChangePasswordRequest.cs new file mode 100644 index 00000000..fb15e1f2 --- /dev/null +++ b/Marechai.Data/Models/ChangePasswordRequest.cs @@ -0,0 +1,12 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; + +namespace Marechai.Data.Models; + +public sealed record ChangePasswordRequest +{ + [Required] + [MinLength(6)] + [JsonPropertyName("newPassword")] + public string NewPassword { get; set; } = null!; +} diff --git a/Marechai.Data/Models/CreateUserRequest.cs b/Marechai.Data/Models/CreateUserRequest.cs new file mode 100644 index 00000000..16d28f99 --- /dev/null +++ b/Marechai.Data/Models/CreateUserRequest.cs @@ -0,0 +1,24 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; + +namespace Marechai.Data.Models; + +public sealed record CreateUserRequest +{ + [Required] + [JsonPropertyName("userName")] + public string UserName { get; set; } = null!; + + [Required] + [EmailAddress] + [JsonPropertyName("email")] + public string Email { get; set; } = null!; + + [Required] + [MinLength(6)] + [JsonPropertyName("password")] + public string Password { get; set; } = null!; + + [JsonPropertyName("phoneNumber")] + public string? PhoneNumber { get; set; } +} diff --git a/Marechai.Data/Models/UpdateUserRequest.cs b/Marechai.Data/Models/UpdateUserRequest.cs new file mode 100644 index 00000000..4325e970 --- /dev/null +++ b/Marechai.Data/Models/UpdateUserRequest.cs @@ -0,0 +1,25 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; + +namespace Marechai.Data.Models; + +public sealed record UpdateUserRequest +{ + [Required] + [JsonPropertyName("userName")] + public string UserName { get; set; } = null!; + + [Required] + [EmailAddress] + [JsonPropertyName("email")] + public string Email { get; set; } = null!; + + [JsonPropertyName("phoneNumber")] + public string? PhoneNumber { get; set; } + + [JsonPropertyName("emailConfirmed")] + public bool? EmailConfirmed { get; set; } + + [JsonPropertyName("lockoutEnabled")] + public bool? LockoutEnabled { get; set; } +} diff --git a/Marechai.Data/Models/UserDto.cs b/Marechai.Data/Models/UserDto.cs new file mode 100644 index 00000000..a39a6f5e --- /dev/null +++ b/Marechai.Data/Models/UserDto.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace Marechai.Data.Models; + +public sealed record UserDto +{ + [JsonPropertyName("id")] + public string Id { get; set; } = null!; + + [JsonPropertyName("userName")] + public string UserName { get; set; } = null!; + + [JsonPropertyName("email")] + public string Email { get; set; } = null!; + + [JsonPropertyName("emailConfirmed")] + public bool EmailConfirmed { get; set; } + + [JsonPropertyName("phoneNumber")] + public string? PhoneNumber { get; set; } + + [JsonPropertyName("phoneNumberConfirmed")] + public bool PhoneNumberConfirmed { get; set; } + + [JsonPropertyName("lockoutEnabled")] + public bool LockoutEnabled { get; set; } + + [JsonPropertyName("lockoutEnd")] + public string? LockoutEnd { get; set; } + + [JsonPropertyName("accessFailedCount")] + public int AccessFailedCount { get; set; } + + [JsonPropertyName("roles")] + public List Roles { get; set; } = []; +} diff --git a/Marechai.Data/Models/UserRoleRequest.cs b/Marechai.Data/Models/UserRoleRequest.cs new file mode 100644 index 00000000..9c7ba970 --- /dev/null +++ b/Marechai.Data/Models/UserRoleRequest.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; + +namespace Marechai.Data.Models; + +public sealed record UserRoleRequest +{ + [Required] + [JsonPropertyName("roleName")] + public string RoleName { get; set; } = null!; +} diff --git a/Marechai.Server/Controllers/UsersController.cs b/Marechai.Server/Controllers/UsersController.cs new file mode 100644 index 00000000..0d1d4a0f --- /dev/null +++ b/Marechai.Server/Controllers/UsersController.cs @@ -0,0 +1,304 @@ +/****************************************************************************** +// MARECHAI: Master repository of computing history artifacts information +// --------------------------------------------------------------------------- +// +// Author(s) : Natalia Portillo +// +// --[ License ] ----------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// --------------------------------------------------------------------------- +// Copyright © 2003-2026 Natalia Portillo +*******************************************************************************/ + +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Marechai.Data.Models; +using Marechai.Database.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc; + +namespace Marechai.Server.Controllers; + +[ApiController] +[Route("users")] +[Authorize(Roles = ApplicationRole.RoleUberAdmin)] +public class UsersController(UserManager userManager) : ControllerBase +{ + [HttpGet] + [ProducesResponseType(typeof(List), StatusCodes.Status200OK, Description = "Returns a list of all users.")] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [Produces("application/json")] + public async Task>> GetAll() + { + var users = userManager.Users.ToList(); + var userDtos = new List(); + + foreach(ApplicationUser user in users) + { + IList roles = await userManager.GetRolesAsync(user); + + userDtos.Add(new UserDto + { + Id = user.Id, + UserName = user.UserName!, + Email = user.Email!, + EmailConfirmed = user.EmailConfirmed, + PhoneNumber = user.PhoneNumber, + PhoneNumberConfirmed = user.PhoneNumberConfirmed, + LockoutEnabled = user.LockoutEnabled, + LockoutEnd = user.LockoutEnd?.ToString("O"), + AccessFailedCount = user.AccessFailedCount, + Roles = roles.ToList() + }); + } + + return Ok(userDtos); + } + + [HttpGet("{id}")] + [ProducesResponseType(typeof(UserDto), StatusCodes.Status200OK, Description = "Returns a specific user by ID.")] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [Produces("application/json")] + public async Task> GetById(string id) + { + ApplicationUser user = await userManager.FindByIdAsync(id); + + if(user == null) return NotFound("User not found"); + + IList roles = await userManager.GetRolesAsync(user); + + return Ok(new UserDto + { + Id = user.Id, + UserName = user.UserName!, + Email = user.Email!, + EmailConfirmed = user.EmailConfirmed, + PhoneNumber = user.PhoneNumber, + PhoneNumberConfirmed = user.PhoneNumberConfirmed, + LockoutEnabled = user.LockoutEnabled, + LockoutEnd = user.LockoutEnd?.ToString("O"), + AccessFailedCount = user.AccessFailedCount, + Roles = roles.ToList() + }); + } + + [HttpPost] + [ProducesResponseType(typeof(UserDto), StatusCodes.Status201Created, Description = "Creates a new user.")] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [Produces("application/json")] + [Consumes("application/json")] + public async Task> Create([FromBody] CreateUserRequest request) + { + if(!ModelState.IsValid) return BadRequest(ModelState); + + var user = new ApplicationUser + { + UserName = request.UserName, + Email = request.Email, + PhoneNumber = request.PhoneNumber + }; + + IdentityResult result = await userManager.CreateAsync(user, request.Password); + + if(!result.Succeeded) return BadRequest(result.Errors); + + IList roles = await userManager.GetRolesAsync(user); + + return CreatedAtAction(nameof(GetById), + new + { + id = user.Id + }, + new UserDto + { + Id = user.Id, + UserName = user.UserName, + Email = user.Email, + EmailConfirmed = user.EmailConfirmed, + PhoneNumber = user.PhoneNumber, + PhoneNumberConfirmed = user.PhoneNumberConfirmed, + LockoutEnabled = user.LockoutEnabled, + LockoutEnd = user.LockoutEnd?.ToString("O"), + AccessFailedCount = user.AccessFailedCount, + Roles = roles.ToList() + }); + } + + [HttpPut("{id}")] + [ProducesResponseType(typeof(UserDto), StatusCodes.Status200OK, Description = "Updates an existing user.")] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [Produces("application/json")] + [Consumes("application/json")] + public async Task> Update(string id, [FromBody] UpdateUserRequest request) + { + if(!ModelState.IsValid) return BadRequest(ModelState); + + ApplicationUser user = await userManager.FindByIdAsync(id); + + if(user == null) return NotFound("User not found"); + + user.UserName = request.UserName; + user.Email = request.Email; + user.PhoneNumber = request.PhoneNumber; + + if(request.EmailConfirmed.HasValue) user.EmailConfirmed = request.EmailConfirmed.Value; + + if(request.LockoutEnabled.HasValue) user.LockoutEnabled = request.LockoutEnabled.Value; + + IdentityResult result = await userManager.UpdateAsync(user); + + if(!result.Succeeded) return BadRequest(result.Errors); + + IList roles = await userManager.GetRolesAsync(user); + + return Ok(new UserDto + { + Id = user.Id, + UserName = user.UserName, + Email = user.Email, + EmailConfirmed = user.EmailConfirmed, + PhoneNumber = user.PhoneNumber, + PhoneNumberConfirmed = user.PhoneNumberConfirmed, + LockoutEnabled = user.LockoutEnabled, + LockoutEnd = user.LockoutEnd?.ToString("O"), + AccessFailedCount = user.AccessFailedCount, + Roles = roles.ToList() + }); + } + + [HttpDelete("{id}")] + [ProducesResponseType(StatusCodes.Status204NoContent, Description = "Deletes a user.")] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task Delete(string id) + { + ApplicationUser user = await userManager.FindByIdAsync(id); + + if(user == null) return NotFound("User not found"); + + IdentityResult result = await userManager.DeleteAsync(user); + + if(!result.Succeeded) return BadRequest(result.Errors); + + return NoContent(); + } + + [HttpPost("{id}/password")] + [ProducesResponseType(StatusCodes.Status204NoContent, Description = "Changes a user's password.")] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [Consumes("application/json")] + public async Task ChangePassword(string id, [FromBody] ChangePasswordRequest request) + { + if(!ModelState.IsValid) return BadRequest(ModelState); + + ApplicationUser user = await userManager.FindByIdAsync(id); + + if(user == null) return NotFound("User not found"); + + // Remove old password and set new one + IdentityResult removeResult = await userManager.RemovePasswordAsync(user); + + if(!removeResult.Succeeded) return BadRequest(removeResult.Errors); + + IdentityResult addResult = await userManager.AddPasswordAsync(user, request.NewPassword); + + if(!addResult.Succeeded) return BadRequest(addResult.Errors); + + return NoContent(); + } + + [HttpPost("{id}/roles")] + [ProducesResponseType(StatusCodes.Status204NoContent, Description = "Adds a role to a user.")] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [Consumes("application/json")] + public async Task AddRole(string id, [FromBody] UserRoleRequest request) + { + if(!ModelState.IsValid) return BadRequest(ModelState); + + ApplicationUser user = await userManager.FindByIdAsync(id); + + if(user == null) return NotFound("User not found"); + + IdentityResult result = await userManager.AddToRoleAsync(user, request.RoleName); + + if(!result.Succeeded) return BadRequest(result.Errors); + + return NoContent(); + } + + [HttpDelete("{id}/roles/{roleName}")] + [ProducesResponseType(StatusCodes.Status204NoContent, Description = "Removes a role from a user.")] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task RemoveRole(string id, string roleName) + { + ApplicationUser user = await userManager.FindByIdAsync(id); + + if(user == null) return NotFound("User not found"); + + IdentityResult result = await userManager.RemoveFromRoleAsync(user, roleName); + + if(!result.Succeeded) return BadRequest(result.Errors); + + return NoContent(); + } + + [HttpGet("roles")] + [ProducesResponseType(typeof(List), StatusCodes.Status200OK, Description = "Returns all available roles.")] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [Produces("application/json")] + public IActionResult GetAllRoles() + { + var roles = new List + { + ApplicationRole.RoleUberAdmin, + ApplicationRole.RoleWriter, + ApplicationRole.RoleProofreader, + ApplicationRole.RoleTranslator, + ApplicationRole.RoleSuperTranslator, + ApplicationRole.RoleCollaborator, + ApplicationRole.RoleCurator, + ApplicationRole.RolePhysicalCurator, + ApplicationRole.RoleTechnician, + ApplicationRole.RoleSuperTechnician, + ApplicationRole.RoleAdmin, + ApplicationRole.RoleNone + }; + + return Ok(roles); + } +} \ No newline at end of file