Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Generated models and request builders #2679

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// <auto-generated/>
#pragma warning disable CS0618
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions.Serialization;
using Microsoft.Kiota.Abstractions.Store;
using System.Collections.Generic;
using System.IO;
using System;
namespace Microsoft.Graph.Applications.Item.Restore
{
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.19.0")]
#pragma warning disable CS1591
public partial class RestorePostRequestBody : IAdditionalDataHolder, IBackedModel, IParsable
#pragma warning restore CS1591
{
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
public IDictionary<string, object> AdditionalData
{
get { return BackingStore.Get<IDictionary<string, object>>("AdditionalData") ?? new Dictionary<string, object>(); }
set { BackingStore.Set("AdditionalData", value); }
}
/// <summary>The autoReconcileProxyConflict property</summary>
public bool? AutoReconcileProxyConflict
{
get { return BackingStore?.Get<bool?>("autoReconcileProxyConflict"); }
set { BackingStore?.Set("autoReconcileProxyConflict", value); }
}
/// <summary>Stores model information.</summary>
public IBackingStore BackingStore { get; private set; }
/// <summary>
/// Instantiates a new <see cref="global::Microsoft.Graph.Applications.Item.Restore.RestorePostRequestBody"/> and sets the default values.
/// </summary>
public RestorePostRequestBody()
{
BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore();
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="global::Microsoft.Graph.Applications.Item.Restore.RestorePostRequestBody"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static global::Microsoft.Graph.Applications.Item.Restore.RestorePostRequestBody CreateFromDiscriminatorValue(IParseNode parseNode)
{
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
return new global::Microsoft.Graph.Applications.Item.Restore.RestorePostRequestBody();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{ "autoReconcileProxyConflict", n => { AutoReconcileProxyConflict = n.GetBoolValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteBoolValue("autoReconcileProxyConflict", AutoReconcileProxyConflict);
writer.WriteAdditionalData(AdditionalData);
}
}
}
#pragma warning restore CS0618
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this RequestBuilder make sense? I don't think it's possible to restore application this way, because /applications/{id} will return ResourceNotFound error code.
To restore application, user, group, servicePrincipal or administrativeUnit, you need to call /directory/deletedItems/{id}/restore
https://learn.microsoft.com/en-us/graph/api/directory-deleteditems-restore?view=graph-rest-1.0&tabs=http

Seems like restore was autogenerated for all entities inherit from directoryObject.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising this @MartinM85

Any chance you can raise an issue for this on the metadata repo to track. At first glance, we would need to drop this line so that the action is only added on the /deletedItems path rather than derived types of directory object.

https://github.com/microsoftgraph/msgraph-metadata/blob/45c385e860332aaa85f1ef7f1b52b0ea44232b34/transforms/csdl/preprocess_csdl.xsl#L2424

We would need to test and validate this change though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,51 @@ public RestoreRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : ba
{
}
/// <summary>
/// Restore a recently deleted application, group, servicePrincipal, administrative unit, or user object from deleted items. If an item was accidentally deleted, you can fully restore the item. However, security groups cannot be restored. Also, restoring an application doesn&apos;t restore the associated service principal automatically. You must call this API to explicitly restore the deleted service principal. A recently deleted item remains available for up to 30 days. After 30 days, the item is permanently deleted.
/// Restore a recently deleted application, group, servicePrincipal, administrative unit, or user object from deleted items. If an item was accidentally deleted, you can fully restore the item. However, security groups can&apos;t be restored. Also, restoring an application doesn&apos;t restore the associated service principal automatically. You must call this API to explicitly restore the deleted service principal. A recently deleted item remains available for up to 30 days. After 30 days, the item is permanently deleted.
/// Find more info here <see href="https://learn.microsoft.com/graph/api/directory-deleteditems-restore?view=graph-rest-1.0" />
/// </summary>
/// <returns>A <see cref="global::Microsoft.Graph.Models.DirectoryObject"/></returns>
/// <param name="body">The request body</param>
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="global::Microsoft.Graph.Models.ODataErrors.ODataError">When receiving a 4XX or 5XX status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public async Task<global::Microsoft.Graph.Models.DirectoryObject?> PostAsync(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
public async Task<global::Microsoft.Graph.Models.DirectoryObject?> PostAsync(global::Microsoft.Graph.Applications.Item.Restore.RestorePostRequestBody body, Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
{
#nullable restore
#else
public async Task<global::Microsoft.Graph.Models.DirectoryObject> PostAsync(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
public async Task<global::Microsoft.Graph.Models.DirectoryObject> PostAsync(global::Microsoft.Graph.Applications.Item.Restore.RestorePostRequestBody body, Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
{
#endif
var requestInfo = ToPostRequestInformation(requestConfiguration);
_ = body ?? throw new ArgumentNullException(nameof(body));
var requestInfo = ToPostRequestInformation(body, requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
{
{ "XXX", global::Microsoft.Graph.Models.ODataErrors.ODataError.CreateFromDiscriminatorValue },
};
return await RequestAdapter.SendAsync<global::Microsoft.Graph.Models.DirectoryObject>(requestInfo, global::Microsoft.Graph.Models.DirectoryObject.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Restore a recently deleted application, group, servicePrincipal, administrative unit, or user object from deleted items. If an item was accidentally deleted, you can fully restore the item. However, security groups cannot be restored. Also, restoring an application doesn&apos;t restore the associated service principal automatically. You must call this API to explicitly restore the deleted service principal. A recently deleted item remains available for up to 30 days. After 30 days, the item is permanently deleted.
/// Restore a recently deleted application, group, servicePrincipal, administrative unit, or user object from deleted items. If an item was accidentally deleted, you can fully restore the item. However, security groups can&apos;t be restored. Also, restoring an application doesn&apos;t restore the associated service principal automatically. You must call this API to explicitly restore the deleted service principal. A recently deleted item remains available for up to 30 days. After 30 days, the item is permanently deleted.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <param name="body">The request body</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public RequestInformation ToPostRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default)
public RequestInformation ToPostRequestInformation(global::Microsoft.Graph.Applications.Item.Restore.RestorePostRequestBody body, Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default)
{
#nullable restore
#else
public RequestInformation ToPostRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default)
public RequestInformation ToPostRequestInformation(global::Microsoft.Graph.Applications.Item.Restore.RestorePostRequestBody body, Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default)
{
#endif
_ = body ?? 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;
}
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public async Task DeleteAsync(Action<RequestConfiguration<DefaultQueryParameters
await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Retrieve a conversationMember from a chat or channel.
/// Find more info here <see href="https://learn.microsoft.com/graph/api/conversationmember-get?view=graph-rest-1.0" />
/// Retrieve a conversationMember from a chat.
/// Find more info here <see href="https://learn.microsoft.com/graph/api/chat-get-members?view=graph-rest-1.0" />
/// </summary>
/// <returns>A <see cref="global::Microsoft.Graph.Models.ConversationMember"/></returns>
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
Expand Down Expand Up @@ -126,7 +126,7 @@ public RequestInformation ToDeleteRequestInformation(Action<RequestConfiguration
return requestInfo;
}
/// <summary>
/// Retrieve a conversationMember from a chat or channel.
/// Retrieve a conversationMember from a chat.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
Expand Down Expand Up @@ -184,7 +184,7 @@ public partial class ConversationMemberItemRequestBuilderDeleteRequestConfigurat
{
}
/// <summary>
/// Retrieve a conversationMember from a chat or channel.
/// Retrieve a conversationMember from a chat.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.19.0")]
public partial class ConversationMemberItemRequestBuilderGetQueryParameters
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// <auto-generated/>
#pragma warning disable CS0618
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions.Serialization;
using Microsoft.Kiota.Abstractions.Store;
using System.Collections.Generic;
using System.IO;
using System;
namespace Microsoft.Graph.Contacts.Item.Restore
{
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.19.0")]
#pragma warning disable CS1591
public partial class RestorePostRequestBody : IAdditionalDataHolder, IBackedModel, IParsable
#pragma warning restore CS1591
{
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
public IDictionary<string, object> AdditionalData
{
get { return BackingStore.Get<IDictionary<string, object>>("AdditionalData") ?? new Dictionary<string, object>(); }
set { BackingStore.Set("AdditionalData", value); }
}
/// <summary>The autoReconcileProxyConflict property</summary>
public bool? AutoReconcileProxyConflict
{
get { return BackingStore?.Get<bool?>("autoReconcileProxyConflict"); }
set { BackingStore?.Set("autoReconcileProxyConflict", value); }
}
/// <summary>Stores model information.</summary>
public IBackingStore BackingStore { get; private set; }
/// <summary>
/// Instantiates a new <see cref="global::Microsoft.Graph.Contacts.Item.Restore.RestorePostRequestBody"/> and sets the default values.
/// </summary>
public RestorePostRequestBody()
{
BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore();
AdditionalData = new Dictionary<string, object>();
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="global::Microsoft.Graph.Contacts.Item.Restore.RestorePostRequestBody"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static global::Microsoft.Graph.Contacts.Item.Restore.RestorePostRequestBody CreateFromDiscriminatorValue(IParseNode parseNode)
{
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
return new global::Microsoft.Graph.Contacts.Item.Restore.RestorePostRequestBody();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{ "autoReconcileProxyConflict", n => { AutoReconcileProxyConflict = n.GetBoolValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteBoolValue("autoReconcileProxyConflict", AutoReconcileProxyConflict);
writer.WriteAdditionalData(AdditionalData);
}
}
}
#pragma warning restore CS0618
Loading
Loading