diff --git a/src/ChangeNotifications/ChangeNotifications.md b/src/ChangeNotifications/ChangeNotifications.md index 34af78e17dd..1ef1f1449b1 100644 --- a/src/ChangeNotifications/ChangeNotifications.md +++ b/src/ChangeNotifications/ChangeNotifications.md @@ -18,3 +18,43 @@ require: ``` yaml # Directives go here! ``` + +### Wrapper migration audit + +The shared file contains no cmdlet suppressions or renames and no parameter +aliases/transforms or schema/response directives to defer. The AutoRest require +and placeholder above remain unchanged. This audit excludes `src/readme.graph.md` +and both profile-local `readme.md` files; their directives are not migrated. + +`wrapper/ChangeNotifications_directiveMigrationMap.json` therefore has an empty +`mappings` array, not invented directive-to-operation mappings. Its separate audit +records exact HTTP method/path/operation-ID evidence from both required +`openApiDocs_KiotaCompat` specifications: seven operations in each profile. +Neither profile is excluded. Revalidation against the merged #3849 target also +refreshes the aligned `subscription_*` operation IDs and spec hashes. The current +compatible v1.0 spec now includes `getVapidPublicKey()`, unlike the original +six-operation audit; that spec refresh is not a shared-directive change. + +`ChangeNotifications_cmdletConfigurations.cs` intentionally remains empty. +Structural naming supplies subscription CRUD names and the action/function +names. Existing v1.0 parity data renames the structural +`Invoke-MgSubscriptionReauthorize` to `Invoke-MgReauthorizeSubscription`; beta +currently retains the structural name. Beta's structural +`Get-MgSubscriptionGetVapidPublicKey` also differs from the legacy beta published noun +`Get-MgBetaSubscriptionVapidPublicKey`. These baseline naming differences are not +shared directives and do not justify new overrides in this audit. + +`tools/WrapperGenerator.Tests/ChangeNotificationsDirectiveMigrationTests.cs` +checks the empty audit and pins every compatible operation's identity, +classification, unsuppressed status, structural name, and data-aware name in both +profiles with derived data enabled and disabled. The profile is separate runtime +context on naming/suppression calls, not authored `GeneratorConfig` state. +Full generation/build evidence is a separate gate; existing tracked +output directories are `wrapper/v1.0` and `wrapper/Beta`. + +The module-specific mutation regression also pins the merged #3886 contract: +`Update-MgSubscription` sends one PATCH and does not read the subscription back. +A 204 response produces no object; a model-bearing 200 returns that model. +Callers may explicitly use `Get-MgSubscription` for an independent read. The +PATCH operation has no native query inputs, so GET-only parameters are not +added to Update and no readback switch or selector is introduced. diff --git a/src/ChangeNotifications/wrapper/Beta/Client/kiota-lock.json b/src/ChangeNotifications/wrapper/Beta/Client/kiota-lock.json index 14c65e1ef48..01c15cac4a6 100644 --- a/src/ChangeNotifications/wrapper/Beta/Client/kiota-lock.json +++ b/src/ChangeNotifications/wrapper/Beta/Client/kiota-lock.json @@ -1,8 +1,8 @@ { - "descriptionHash": "E53648C740810AA50C7438897FBB143D286760102F13C6B81BCE8FE0251DBB3FC0248686673119F586579444A35A9615A9643D4D1055AFA243FEF8FEC43E0689", - "descriptionLocation": "../../../../../openApiDocs_KiotaCompat/Beta/ChangeNotifications.yml", + "descriptionHash": "F5354FDC96BF1B98800BD52F1C40992665344C16C4ADFA4A9E38F492E8BED3F3F5E34B188E147C0FFB6280DF9465451089021B234CDAA5502689F0761A8F4B53", + "descriptionLocation": "../../../../../openApiDocs_KiotaCompat/beta/ChangeNotifications.yml", "lockFileVersion": "1.0.0", - "kiotaVersion": "1.34.1", + "kiotaVersion": "1.36.1", "clientClassName": "ApiClient", "typeAccessModifier": "Public", "clientNamespaceName": "Microsoft.Graph.PowerShell.ChangeNotifications.Client", diff --git a/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription.g.cs b/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription.g.cs index 24c99700b02..e44d3a6b50d 100644 --- a/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription.g.cs +++ b/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription.g.cs @@ -19,6 +19,7 @@ public class GetMgSubscriptionCommand : GraphClientCmdlet + [Parameter(Mandatory = false)] [Alias("Select")] public string[]? Property { get; set; } diff --git a/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscriptionGetVapidPublicKey.g.cs b/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscriptionGetVapidPublicKey.g.cs index cd18273819f..4ac548acd94 100644 --- a/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscriptionGetVapidPublicKey.g.cs +++ b/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscriptionGetVapidPublicKey.g.cs @@ -31,7 +31,7 @@ public class GetMgSubscriptionGetVapidPublicKeyCommand : GraphClientCmdlet protected override void ProcessRecord() { - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("beta"); var client = new ApiClient(requestAdapter); diff --git a/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription_Get.g.cs b/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription_Get.g.cs index df07c580723..9cbf48b3235 100644 --- a/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription_Get.g.cs +++ b/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription_Get.g.cs @@ -31,7 +31,7 @@ public class GetMgSubscription_GetCommand : GraphClientCmdlet protected override void ProcessRecord() { - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("beta"); var client = new ApiClient(requestAdapter); Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.Subscription? result; @@ -44,6 +44,7 @@ protected override void ProcessRecord() + AddRequestHeaders(requestConfiguration.Headers); }).GetAwaiter().GetResult(); } diff --git a/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription_List.g.cs b/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription_List.g.cs index 4369ba17af5..a2db07660c0 100644 --- a/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription_List.g.cs +++ b/src/ChangeNotifications/wrapper/Beta/Cmdlets/GetMgSubscription_List.g.cs @@ -59,7 +59,7 @@ public class GetMgSubscription_ListCommand : GraphClientCmdlet protected override void ProcessRecord() { - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("beta"); var client = new ApiClient(requestAdapter); Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.SubscriptionCollectionResponse? result; @@ -93,6 +93,7 @@ protected override void ProcessRecord() + AddRequestHeaders(requestConfiguration.Headers); }).GetAwaiter().GetResult(); diff --git a/src/ChangeNotifications/wrapper/Beta/Cmdlets/InvokeMgSubscriptionReauthorize.g.cs b/src/ChangeNotifications/wrapper/Beta/Cmdlets/InvokeMgSubscriptionReauthorize.g.cs index b86c12e20e6..296629a1b16 100644 --- a/src/ChangeNotifications/wrapper/Beta/Cmdlets/InvokeMgSubscriptionReauthorize.g.cs +++ b/src/ChangeNotifications/wrapper/Beta/Cmdlets/InvokeMgSubscriptionReauthorize.g.cs @@ -35,7 +35,7 @@ protected override void ProcessRecord() return; - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("beta"); var client = new ApiClient(requestAdapter); diff --git a/src/ChangeNotifications/wrapper/Beta/Cmdlets/NewMgSubscription.g.cs b/src/ChangeNotifications/wrapper/Beta/Cmdlets/NewMgSubscription.g.cs index d27dc36d3b8..c9ba91483a1 100644 --- a/src/ChangeNotifications/wrapper/Beta/Cmdlets/NewMgSubscription.g.cs +++ b/src/ChangeNotifications/wrapper/Beta/Cmdlets/NewMgSubscription.g.cs @@ -142,7 +142,7 @@ protected override void ProcessRecord() - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("beta"); var client = new ApiClient(requestAdapter); Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.Subscription? result; diff --git a/src/ChangeNotifications/wrapper/Beta/Cmdlets/RemoveMgSubscription.g.cs b/src/ChangeNotifications/wrapper/Beta/Cmdlets/RemoveMgSubscription.g.cs index 73f2c98e96f..4ab38f1b515 100644 --- a/src/ChangeNotifications/wrapper/Beta/Cmdlets/RemoveMgSubscription.g.cs +++ b/src/ChangeNotifications/wrapper/Beta/Cmdlets/RemoveMgSubscription.g.cs @@ -30,7 +30,7 @@ protected override void ProcessRecord() if (!ShouldProcess(SubscriptionId, "Remove")) return; - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("beta"); var client = new ApiClient(requestAdapter); // DeleteAsync returns a plain Task: a standard delete response has no body. diff --git a/src/ChangeNotifications/wrapper/Beta/Cmdlets/UpdateMgSubscription.g.cs b/src/ChangeNotifications/wrapper/Beta/Cmdlets/UpdateMgSubscription.g.cs index dd82254a677..773a9d8e4af 100644 --- a/src/ChangeNotifications/wrapper/Beta/Cmdlets/UpdateMgSubscription.g.cs +++ b/src/ChangeNotifications/wrapper/Beta/Cmdlets/UpdateMgSubscription.g.cs @@ -143,7 +143,7 @@ protected override void ProcessRecord() - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("beta"); var client = new ApiClient(requestAdapter); Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.Subscription? result; @@ -161,20 +161,6 @@ protected override void ProcessRecord() return; } - - if (result is null) - { - WriteVerbose("PATCH succeeded with no response body, re-fetching the updated resource."); - try - { - result = client.Subscriptions[SubscriptionId].GetAsync().GetAwaiter().GetResult(); - } - catch (Exception ex) when (ex is not PipelineStoppedException && ex is not OperationCanceledException) - { - ThrowGraphRequestFailed(ex, SubscriptionId); - return; - } - } if (result is not null) WriteObject(result); } diff --git a/src/ChangeNotifications/wrapper/Beta/Cmdlets/kiota-lock.json b/src/ChangeNotifications/wrapper/Beta/Cmdlets/kiota-lock.json index a32225e9723..b658a7a351b 100644 --- a/src/ChangeNotifications/wrapper/Beta/Cmdlets/kiota-lock.json +++ b/src/ChangeNotifications/wrapper/Beta/Cmdlets/kiota-lock.json @@ -1,3 +1,3 @@ { - "descriptionLocation": "../../../../../openApiDocs_KiotaCompat/Beta/ChangeNotifications.yml" + "descriptionLocation": "../../../../../openApiDocs_KiotaCompat/beta/ChangeNotifications.yml" } \ No newline at end of file diff --git a/src/ChangeNotifications/wrapper/Beta/Microsoft.Graph.Wrapper.ChangeNotifications.csproj b/src/ChangeNotifications/wrapper/Beta/Microsoft.Graph.Wrapper.ChangeNotifications.csproj index 28c3005ae73..a175dc92e1c 100644 --- a/src/ChangeNotifications/wrapper/Beta/Microsoft.Graph.Wrapper.ChangeNotifications.csproj +++ b/src/ChangeNotifications/wrapper/Beta/Microsoft.Graph.Wrapper.ChangeNotifications.csproj @@ -48,18 +48,16 @@ - + Removal is by package identity, not filename. --> + Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != ''" /> diff --git a/src/ChangeNotifications/wrapper/ChangeNotifications_directiveMigrationMap.json b/src/ChangeNotifications/wrapper/ChangeNotifications_directiveMigrationMap.json new file mode 100644 index 00000000000..dd419979cfd --- /dev/null +++ b/src/ChangeNotifications/wrapper/ChangeNotifications_directiveMigrationMap.json @@ -0,0 +1,104 @@ +{ + "mappings": [], + "audit": { + "module": "ChangeNotifications", + "source": "src/ChangeNotifications/ChangeNotifications.md", + "disposition": "NoSharedDirectives", + "sharedCmdletDirectiveCount": 0, + "deferredParameterDirectiveCount": 0, + "deferredSchemaDirectiveCount": 0, + "excludedProfiles": [], + "ignoredSources": [ + "src/readme.graph.md", + "src/ChangeNotifications/v1.0/readme.md", + "src/ChangeNotifications/beta/readme.md" + ], + "notes": "These are unaffected-operation audit evidence, not directive mappings. No curated overrides are needed. Revalidated after #3849 against target 08e409a6aa8fd48736b8f9a9199559f46fc0d1ad: compatible operation IDs now align with the original subscription_* IDs; compatible v1.0 now also includes getVapidPublicKey(). Existing v1.0 parity data renames reauthorize; action/function naming differences from the legacy SDK remain baseline behavior. Runtime profile context is passed separately from shared GeneratorConfig, with derived data both enabled and disabled.", + "profiles": { + "v1.0": { + "spec": "openApiDocs_KiotaCompat/v1.0/ChangeNotifications.yml", + "specGitBlob": "e53bd7d80255a87fe5c11b94c5d1f09e15adc854", + "trackedOutputDirectory": "src/ChangeNotifications/wrapper/v1.0", + "operations": [ + { + "method": "GET", + "path": "/subscriptions", + "operationId": "subscription_ListSubscription" + }, + { + "method": "POST", + "path": "/subscriptions", + "operationId": "subscription_CreateSubscription" + }, + { + "method": "GET", + "path": "/subscriptions/{subscription-id}", + "operationId": "subscription_GetSubscription" + }, + { + "method": "PATCH", + "path": "/subscriptions/{subscription-id}", + "operationId": "subscription_UpdateSubscription" + }, + { + "method": "DELETE", + "path": "/subscriptions/{subscription-id}", + "operationId": "subscription_DeleteSubscription" + }, + { + "method": "POST", + "path": "/subscriptions/{subscription-id}/reauthorize", + "operationId": "subscription_reauthorize" + }, + { + "method": "GET", + "path": "/subscriptions/getVapidPublicKey()", + "operationId": "subscription_getVapidPublicKey" + } + ] + }, + "beta": { + "spec": "openApiDocs_KiotaCompat/beta/ChangeNotifications.yml", + "specGitBlob": "14bf6c727c87c5433274bfec78a4a681169e5390", + "trackedOutputDirectory": "src/ChangeNotifications/wrapper/Beta", + "operations": [ + { + "method": "GET", + "path": "/subscriptions", + "operationId": "subscription_ListSubscription" + }, + { + "method": "POST", + "path": "/subscriptions", + "operationId": "subscription_CreateSubscription" + }, + { + "method": "GET", + "path": "/subscriptions/{subscription-id}", + "operationId": "subscription_GetSubscription" + }, + { + "method": "PATCH", + "path": "/subscriptions/{subscription-id}", + "operationId": "subscription_UpdateSubscription" + }, + { + "method": "DELETE", + "path": "/subscriptions/{subscription-id}", + "operationId": "subscription_DeleteSubscription" + }, + { + "method": "POST", + "path": "/subscriptions/{subscription-id}/reauthorize", + "operationId": "subscription_reauthorize" + }, + { + "method": "GET", + "path": "/subscriptions/getVapidPublicKey()", + "operationId": "subscription_getVapidPublicKey" + } + ] + } + } + } +} diff --git a/src/ChangeNotifications/wrapper/v1.0/Client/Models/Subscription.cs b/src/ChangeNotifications/wrapper/v1.0/Client/Models/Subscription.cs index 67960aafb59..da9f47d4338 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Client/Models/Subscription.cs +++ b/src/ChangeNotifications/wrapper/v1.0/Client/Models/Subscription.cs @@ -111,6 +111,30 @@ public partial class Subscription : global::Microsoft.Graph.PowerShell.ChangeNot #nullable restore #else public string Resource { get; set; } +#endif + /// Optional. The application server's VAPID public key, base64url-encoded (P-256 uncompressed point, 65 bytes pre-encoding). Obtained by calling the getVapidPublicKey function on the subscription collection. The browser passes this value to PushManager.subscribe({ applicationServerKey: vapidPublicKey }) to bind the push subscription to this server identity. Required when notificationUrl targets a known Web Push service origin (for example, *.push.apple.com, fcm.googleapis.com, updates.push.services.mozilla.com); rejected with 400 Bad Request if supplied on a standard webhook subscription. For more information, see RFC 8292. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? VapidPublicKey { get; set; } +#nullable restore +#else + public string VapidPublicKey { get; set; } +#endif + /// Optional. The subscriber's ECDH public key, base64url-encoded (P-256 uncompressed point, 65 bytes pre-encoding). Obtained from the browser via PushSubscription.getKey('p256dh'). Used as the peer public key during ECDH key agreement to derive the per-message content encryption key for RFC 8291 payload encryption. Required when notificationUrl targets a known Web Push service origin; rejected with 400 Bad Request if supplied on a standard webhook subscription. For more information, see RFC 8291 Section 3. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? WebPushEncryptionP256dhPublicKey { get; set; } +#nullable restore +#else + public string WebPushEncryptionP256dhPublicKey { get; set; } +#endif + /// Optional. The subscriber's auth secret, base64url-encoded (16 bytes pre-encoding). Obtained from the browser via PushSubscription.getKey('auth'). Used as the HMAC-SHA-256 salt for the HKDF combine step that derives key material for RFC 8291 payload encryption. Write-only: this value is never returned in GET responses (returned as null). Treat as a secret. Required when notificationUrl targets a known Web Push service origin; rejected with 400 Bad Request if supplied on a standard webhook subscription. For more information, see RFC 8291 Section 3. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? WebPushEncryptionSecret { get; set; } +#nullable restore +#else + public string WebPushEncryptionSecret { get; set; } #endif /// /// Creates a new instance of the appropriate class based on discriminator value @@ -144,6 +168,9 @@ public override IDictionary> GetFieldDeserializers() { "notificationUrl", n => { NotificationUrl = n.GetStringValue(); } }, { "notificationUrlAppId", n => { NotificationUrlAppId = n.GetStringValue(); } }, { "resource", n => { Resource = n.GetStringValue(); } }, + { "vapidPublicKey", n => { VapidPublicKey = n.GetStringValue(); } }, + { "webPushEncryptionP256dhPublicKey", n => { WebPushEncryptionP256dhPublicKey = n.GetStringValue(); } }, + { "webPushEncryptionSecret", n => { WebPushEncryptionSecret = n.GetStringValue(); } }, }; } /// @@ -168,6 +195,9 @@ public override void Serialize(ISerializationWriter writer) writer.WriteStringValue("notificationUrl", NotificationUrl); writer.WriteStringValue("notificationUrlAppId", NotificationUrlAppId); writer.WriteStringValue("resource", Resource); + writer.WriteStringValue("vapidPublicKey", VapidPublicKey); + writer.WriteStringValue("webPushEncryptionP256dhPublicKey", WebPushEncryptionP256dhPublicKey); + writer.WriteStringValue("webPushEncryptionSecret", WebPushEncryptionSecret); } } } diff --git a/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/GetVapidPublicKey/GetVapidPublicKeyGetResponse.cs b/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/GetVapidPublicKey/GetVapidPublicKeyGetResponse.cs new file mode 100644 index 00000000000..0400f4e2ba3 --- /dev/null +++ b/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/GetVapidPublicKey/GetVapidPublicKeyGetResponse.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 Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class GetVapidPublicKeyGetResponse : 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 value property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Value { get; set; } +#nullable restore +#else + public string Value { get; set; } +#endif + /// + /// Instantiates a new and sets the default values. + /// + public GetVapidPublicKeyGetResponse() + { + 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::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyGetResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); + return new global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyGetResponse(); + } + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "value", n => { Value = 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("value", Value); + writer.WriteAdditionalData(AdditionalData); + } + } +} +#pragma warning restore CS0618 diff --git a/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/GetVapidPublicKey/GetVapidPublicKeyRequestBuilder.cs b/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/GetVapidPublicKey/GetVapidPublicKeyRequestBuilder.cs new file mode 100644 index 00000000000..5304394268e --- /dev/null +++ b/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/GetVapidPublicKey/GetVapidPublicKeyRequestBuilder.cs @@ -0,0 +1,123 @@ +// +#pragma warning disable CS0618 +using Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.ODataErrors; +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 Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey +{ + /// + /// Builds and executes requests for operations under \subscriptions\getVapidPublicKey() + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class GetVapidPublicKeyRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public GetVapidPublicKeyRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/subscriptions/getVapidPublicKey()", 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 GetVapidPublicKeyRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/subscriptions/getVapidPublicKey()", rawUrl) + { + } + /// + /// Get the public key information required to validate push notifications according to RFC 8292 specifications. + /// Find more info here + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 4XX or 5XX status code +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsGetVapidPublicKeyGetResponseAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { +#nullable restore +#else + public async Task GetAsGetVapidPublicKeyGetResponseAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "XXX", global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.ODataErrors.ODataError.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyGetResponse.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Get the public key information required to validate push notifications according to RFC 8292 specifications. + /// Find more info here + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 4XX or 5XX status code + [Obsolete("This method is obsolete. Use GetAsGetVapidPublicKeyGetResponseAsync instead.")] +#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> + { + { "XXX", global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.ODataErrors.ODataError.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyResponse.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Get the public key information required to validate push notifications according to RFC 8292 specifications. + /// + /// 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::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyRequestBuilder WithUrl(string rawUrl) + { + return new global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyRequestBuilder(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 GetVapidPublicKeyRequestBuilderGetRequestConfiguration : RequestConfiguration + { + } + } +} +#pragma warning restore CS0618 diff --git a/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/GetVapidPublicKey/GetVapidPublicKeyResponse.cs b/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/GetVapidPublicKey/GetVapidPublicKeyResponse.cs new file mode 100644 index 00000000000..fbafd5fee7e --- /dev/null +++ b/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/GetVapidPublicKey/GetVapidPublicKeyResponse.cs @@ -0,0 +1,28 @@ +// +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey +{ + [Obsolete("This class is obsolete. Use GetVapidPublicKeyGetResponse instead.")] + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class GetVapidPublicKeyResponse : global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyGetResponse, IParsable + #pragma warning restore CS1591 + { + /// + /// 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 new global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); + return new global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyResponse(); + } + } +} +#pragma warning restore CS0618 diff --git a/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/SubscriptionsRequestBuilder.cs b/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/SubscriptionsRequestBuilder.cs index cd2ea8b2639..c4fd5c71c58 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/SubscriptionsRequestBuilder.cs +++ b/src/ChangeNotifications/wrapper/v1.0/Client/Subscriptions/SubscriptionsRequestBuilder.cs @@ -2,6 +2,7 @@ #pragma warning disable CS0618 using Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.ODataErrors; using Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models; +using Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey; using Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.Item; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions.Serialization; @@ -19,6 +20,11 @@ namespace Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] public partial class SubscriptionsRequestBuilder : BaseRequestBuilder { + /// The getVapidPublicKey property + public global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyRequestBuilder GetVapidPublicKey + { + get => new global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyRequestBuilder(PathParameters, RequestAdapter); + } /// Gets an item from the Microsoft.Graph.PowerShell.ChangeNotifications.Client.subscriptions.item collection /// Unique identifier of the item /// A diff --git a/src/ChangeNotifications/wrapper/v1.0/Client/kiota-lock.json b/src/ChangeNotifications/wrapper/v1.0/Client/kiota-lock.json index 48b2f902944..15fa5bc898f 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Client/kiota-lock.json +++ b/src/ChangeNotifications/wrapper/v1.0/Client/kiota-lock.json @@ -1,8 +1,8 @@ { - "descriptionHash": "148FDD3EA330C3467A8E26CDB67CFD21E3C6FC320F73C74B6F9FBF105D273D4046C2176BCF07EAA4C5203E6C4308F6C0E4C329ABAAFC0222772BBE3B15F911D3", + "descriptionHash": "39794BC788C8223ACA97639F858477509AEB337A27A4F18E34A0C87BE61947F763903CBFFC439EF32A37541547E45B4A0625C8779BD38DB691645F984529076F", "descriptionLocation": "../../../../../openApiDocs_KiotaCompat/v1.0/ChangeNotifications.yml", "lockFileVersion": "1.0.0", - "kiotaVersion": "1.34.1", + "kiotaVersion": "1.36.1", "clientClassName": "ApiClient", "typeAccessModifier": "Public", "clientNamespaceName": "Microsoft.Graph.PowerShell.ChangeNotifications.Client", diff --git a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription.g.cs b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription.g.cs index 24c99700b02..e44d3a6b50d 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription.g.cs +++ b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription.g.cs @@ -19,6 +19,7 @@ public class GetMgSubscriptionCommand : GraphClientCmdlet + [Parameter(Mandatory = false)] [Alias("Select")] public string[]? Property { get; set; } diff --git a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscriptionGetVapidPublicKey.g.cs b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscriptionGetVapidPublicKey.g.cs new file mode 100644 index 00000000000..681483a92cd --- /dev/null +++ b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscriptionGetVapidPublicKey.g.cs @@ -0,0 +1,56 @@ +#nullable enable + +using System; +using System.Collections.Generic; +using System.Management.Automation; +using System.Net.Http; +using Microsoft.Graph.Wrapper.Runtime; +using Microsoft.Graph.PowerShell.ChangeNotifications.Client; +using Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Abstractions.Authentication; +using Microsoft.Kiota.Http.HttpClientLibrary; + +namespace Microsoft.Graph.PowerShell.ChangeNotifications +{ + [GraphRoute("GET", "/subscriptions/getVapidPublicKey()")] + [Cmdlet(VerbsCommon.Get, "MgSubscriptionGetVapidPublicKey")] + [OutputType(typeof(global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyGetResponse))] + public class GetMgSubscriptionGetVapidPublicKeyCommand : GraphClientCmdlet + { + + + + + + + + + + + protected override void ProcessRecord() + { + + var requestAdapter = GetRequestAdapter("v1.0"); + var client = new ApiClient(requestAdapter); + + + global::Microsoft.Graph.PowerShell.ChangeNotifications.Client.Subscriptions.GetVapidPublicKey.GetVapidPublicKeyGetResponse? result; + try + { + result = client.Subscriptions.GetVapidPublicKey.GetAsGetVapidPublicKeyGetResponseAsync(requestConfiguration => + { + + AddRequestHeaders(requestConfiguration.Headers); + }).GetAwaiter().GetResult(); + } + catch (Exception ex) when (ex is not PipelineStoppedException && ex is not OperationCanceledException) + { + ThrowGraphRequestFailed(ex, null); + return; + } + + WriteObject(result); + } + } +} diff --git a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription_Get.g.cs b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription_Get.g.cs index df07c580723..b5213938a24 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription_Get.g.cs +++ b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription_Get.g.cs @@ -31,7 +31,7 @@ public class GetMgSubscription_GetCommand : GraphClientCmdlet protected override void ProcessRecord() { - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("v1.0"); var client = new ApiClient(requestAdapter); Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.Subscription? result; @@ -44,6 +44,7 @@ protected override void ProcessRecord() + AddRequestHeaders(requestConfiguration.Headers); }).GetAwaiter().GetResult(); } diff --git a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription_List.g.cs b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription_List.g.cs index 4369ba17af5..66bcd42df95 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription_List.g.cs +++ b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/GetMgSubscription_List.g.cs @@ -59,7 +59,7 @@ public class GetMgSubscription_ListCommand : GraphClientCmdlet protected override void ProcessRecord() { - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("v1.0"); var client = new ApiClient(requestAdapter); Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.SubscriptionCollectionResponse? result; @@ -93,6 +93,7 @@ protected override void ProcessRecord() + AddRequestHeaders(requestConfiguration.Headers); }).GetAwaiter().GetResult(); diff --git a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/InvokeMgReauthorizeSubscription.g.cs b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/InvokeMgReauthorizeSubscription.g.cs index e4f1af24421..867010eb564 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/InvokeMgReauthorizeSubscription.g.cs +++ b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/InvokeMgReauthorizeSubscription.g.cs @@ -35,7 +35,7 @@ protected override void ProcessRecord() return; - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("v1.0"); var client = new ApiClient(requestAdapter); diff --git a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/NewMgSubscription.g.cs b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/NewMgSubscription.g.cs index 48195d84886..7c9a2b9ccc2 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/NewMgSubscription.g.cs +++ b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/NewMgSubscription.g.cs @@ -61,6 +61,15 @@ public class NewMgSubscriptionCommand : GraphClientCmdlet [Parameter(Mandatory = false)] public string? Resource { get; set; } + [Parameter(Mandatory = false)] + public string? VapidPublicKey { get; set; } + + [Parameter(Mandatory = false)] + public string? WebPushEncryptionP256dhPublicKey { get; set; } + + [Parameter(Mandatory = false)] + public string? WebPushEncryptionSecret { get; set; } + @@ -116,9 +125,18 @@ protected override void ProcessRecord() if (this.IsParameterBound(nameof(Resource))) body.Resource = Resource; + if (this.IsParameterBound(nameof(VapidPublicKey))) + body.VapidPublicKey = VapidPublicKey; + + if (this.IsParameterBound(nameof(WebPushEncryptionP256dhPublicKey))) + body.WebPushEncryptionP256dhPublicKey = WebPushEncryptionP256dhPublicKey; + + if (this.IsParameterBound(nameof(WebPushEncryptionSecret))) + body.WebPushEncryptionSecret = WebPushEncryptionSecret; + - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("v1.0"); var client = new ApiClient(requestAdapter); Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.Subscription? result; diff --git a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/RemoveMgSubscription.g.cs b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/RemoveMgSubscription.g.cs index 73f2c98e96f..ec3478f0dd4 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/RemoveMgSubscription.g.cs +++ b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/RemoveMgSubscription.g.cs @@ -30,7 +30,7 @@ protected override void ProcessRecord() if (!ShouldProcess(SubscriptionId, "Remove")) return; - var requestAdapter = GetRequestAdapter(); + var requestAdapter = GetRequestAdapter("v1.0"); var client = new ApiClient(requestAdapter); // DeleteAsync returns a plain Task: a standard delete response has no body. diff --git a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/UpdateMgSubscription.g.cs b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/UpdateMgSubscription.g.cs index cc4a2c3e39a..e651b8953d0 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Cmdlets/UpdateMgSubscription.g.cs +++ b/src/ChangeNotifications/wrapper/v1.0/Cmdlets/UpdateMgSubscription.g.cs @@ -62,6 +62,15 @@ public class UpdateMgSubscriptionCommand : GraphClientCmdlet [Parameter(Mandatory = false)] public string? Resource { get; set; } + [Parameter(Mandatory = false)] + public string? VapidPublicKey { get; set; } + + [Parameter(Mandatory = false)] + public string? WebPushEncryptionP256dhPublicKey { get; set; } + + [Parameter(Mandatory = false)] + public string? WebPushEncryptionSecret { get; set; } + @@ -117,9 +126,18 @@ protected override void ProcessRecord() if (this.IsParameterBound(nameof(Resource))) body.Resource = Resource; + if (this.IsParameterBound(nameof(VapidPublicKey))) + body.VapidPublicKey = VapidPublicKey; + + if (this.IsParameterBound(nameof(WebPushEncryptionP256dhPublicKey))) + body.WebPushEncryptionP256dhPublicKey = WebPushEncryptionP256dhPublicKey; + if (this.IsParameterBound(nameof(WebPushEncryptionSecret))) + body.WebPushEncryptionSecret = WebPushEncryptionSecret; - var requestAdapter = GetRequestAdapter(); + + + var requestAdapter = GetRequestAdapter("v1.0"); var client = new ApiClient(requestAdapter); Microsoft.Graph.PowerShell.ChangeNotifications.Client.Models.Subscription? result; @@ -137,20 +155,6 @@ protected override void ProcessRecord() return; } - - if (result is null) - { - WriteVerbose("PATCH succeeded with no response body, re-fetching the updated resource."); - try - { - result = client.Subscriptions[SubscriptionId].GetAsync().GetAwaiter().GetResult(); - } - catch (Exception ex) when (ex is not PipelineStoppedException && ex is not OperationCanceledException) - { - ThrowGraphRequestFailed(ex, SubscriptionId); - return; - } - } if (result is not null) WriteObject(result); } diff --git a/src/ChangeNotifications/wrapper/v1.0/Microsoft.Graph.Wrapper.ChangeNotifications.csproj b/src/ChangeNotifications/wrapper/v1.0/Microsoft.Graph.Wrapper.ChangeNotifications.csproj index 28c3005ae73..a175dc92e1c 100644 --- a/src/ChangeNotifications/wrapper/v1.0/Microsoft.Graph.Wrapper.ChangeNotifications.csproj +++ b/src/ChangeNotifications/wrapper/v1.0/Microsoft.Graph.Wrapper.ChangeNotifications.csproj @@ -48,18 +48,16 @@ - + Removal is by package identity, not filename. --> + Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != ''" /> diff --git a/tools/WrapperGenerator.Tests/ChangeNotificationsDirectiveMigrationTests.cs b/tools/WrapperGenerator.Tests/ChangeNotificationsDirectiveMigrationTests.cs new file mode 100644 index 00000000000..0c6d12c2b9c --- /dev/null +++ b/tools/WrapperGenerator.Tests/ChangeNotificationsDirectiveMigrationTests.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text.Json; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.OpenApi; +using Microsoft.OpenApi.Reader; +using WrapperGenerator; +using Xunit; + +namespace WrapperGenerator.Tests; + +public sealed class ChangeNotificationsDirectiveMigrationTests +{ + private static string FindRepoRoot() + { + var directory = AppContext.BaseDirectory; + while (directory is not null && + !File.Exists(Path.Combine(directory, "src", "ChangeNotifications", "ChangeNotifications.md"))) + directory = Path.GetDirectoryName(directory); + return directory ?? throw new InvalidOperationException("Repository root not found."); + } + + private static JsonDocument ReadAudit(string root) => + JsonDocument.Parse(File.ReadAllText(Path.Combine(root, "src", "ChangeNotifications", "wrapper", + "ChangeNotifications_directiveMigrationMap.json"))); + + private static async Task ReadCompatibleSpecAsync(string root, string profile) + { + var settings = new OpenApiReaderSettings(); + settings.AddYamlReader(); + using var stream = File.OpenRead(Path.Combine(root, "openApiDocs_KiotaCompat", profile, + "ChangeNotifications.yml")); + var result = await OpenApiDocument.LoadAsync(stream, settings: settings, + cancellationToken: CancellationToken.None); + return Assert.IsType(result.Document); + } + + [Fact] + public void EmptySharedSourceHasAnHonestAuditWithoutOverrides() + { + var root = FindRepoRoot(); + using var ledger = ReadAudit(root); + Assert.Empty(ledger.RootElement.GetProperty("mappings").EnumerateArray()); + var audit = ledger.RootElement.GetProperty("audit"); + Assert.Equal("ChangeNotifications", audit.GetProperty("module").GetString()); + Assert.Equal("NoSharedDirectives", audit.GetProperty("disposition").GetString()); + Assert.Equal(0, audit.GetProperty("sharedCmdletDirectiveCount").GetInt32()); + Assert.Equal(0, audit.GetProperty("deferredParameterDirectiveCount").GetInt32()); + Assert.Equal(0, audit.GetProperty("deferredSchemaDirectiveCount").GetInt32()); + Assert.Empty(audit.GetProperty("excludedProfiles").EnumerateArray()); + Assert.DoesNotMatch(@"(?m)^\s*directive:", File.ReadAllText( + Path.Combine(root, "src", "ChangeNotifications", "ChangeNotifications.md"))); + Assert.Matches(@"ChangeNotificationsCmdletConfigurations\s*=\s*\[\s*\]", File.ReadAllText( + Path.Combine(root, "src", "ChangeNotifications", "wrapper", + "ChangeNotifications_cmdletConfigurations.cs"))); + } + + [Theory] + [InlineData("v1.0", true)] + [InlineData("v1.0", false)] + [InlineData("beta", true)] + [InlineData("beta", false)] + public async Task CompatibleOperationsKeepTheirIdentityAndNaming(string profile, bool useCollisionData) + { + var root = FindRepoRoot(); + using var ledger = ReadAudit(root); + var evidence = ledger.RootElement.GetProperty("audit").GetProperty("profiles").GetProperty(profile); + Assert.Equal($"openApiDocs_KiotaCompat/{profile}/ChangeNotifications.yml", + evidence.GetProperty("spec").GetString()); + var document = await ReadCompatibleSpecAsync(root, profile); + const int expectedCount = 7; + Assert.Equal(expectedCount, document.Paths.Sum(path => path.Value.Operations!.Count)); + var operations = evidence.GetProperty("operations").EnumerateArray().ToArray(); + Assert.Equal(expectedCount, operations.Length); + Assert.Equal(expectedCount, operations.Select(operation => + $"{operation.GetProperty("method").GetString()} {operation.GetProperty("path").GetString()}") + .Distinct(StringComparer.Ordinal).Count()); + + var structuralNames = new Dictionary(StringComparer.Ordinal) + { + ["subscription_ListSubscription"] = ("Get-MgSubscription", OperationKind.Resource), + ["subscription_CreateSubscription"] = ("New-MgSubscription", OperationKind.Resource), + ["subscription_GetSubscription"] = ("Get-MgSubscription", OperationKind.Resource), + ["subscription_UpdateSubscription"] = ("Update-MgSubscription", OperationKind.Resource), + ["subscription_DeleteSubscription"] = ("Remove-MgSubscription", OperationKind.Resource), + ["subscription_reauthorize"] = ("Invoke-MgSubscriptionReauthorize", OperationKind.Action), + ["subscription_getVapidPublicKey"] = ("Get-MgSubscriptionGetVapidPublicKey", OperationKind.Function), + }; + var config = new GeneratorConfig("Microsoft.Graph.PowerShell.Test.Client", Path.GetTempPath(), + UseCollisionData: useCollisionData); + foreach (var operation in operations) + { + var method = new HttpMethod(operation.GetProperty("method").GetString()!); + var path = operation.GetProperty("path").GetString()!; + var operationId = operation.GetProperty("operationId").GetString()!; + Assert.True(document.Paths.ContainsKey(path), $"Missing {profile} {method} {path}."); + var actual = Assert.Single(document.Paths[path].Operations!, + candidate => candidate.Key == method).Value; + Assert.Equal(operationId, actual.OperationId); + var expected = structuralNames[operationId]; + var extension = Assert.IsType( + actual.Extensions!["x-ms-docs-operation-type"]); + Assert.Equal(expected.Kind switch + { + OperationKind.Action => "action", + OperationKind.Function => "function", + _ => "operation", + }, extension.Node!.ToString().Trim('"')); + + Assert.False(CmdletConfigurator.IsSuppressed(method, path, apiVersion: profile)); + Assert.False(CmdletConfigurator.IsSuppressed(method, path, config, apiVersion: profile)); + var operationInfo = new OperationInfo(method, path, Kind: expected.Kind); + var structural = Naming.Resolve(operationInfo, apiVersion: profile); + Assert.Equal(expected.Command, $"{structural.VerbName}-{structural.Noun}"); + var configured = Naming.Resolve(operationInfo, config, apiVersion: profile); + var configuredName = useCollisionData && profile == "v1.0" && expected.Kind == OperationKind.Action + ? "Invoke-MgReauthorizeSubscription" + : expected.Command; + Assert.Equal(configuredName, $"{configured.VerbName}-{configured.Noun}"); + } + } + + [Theory] + [InlineData("v1.0", true)] + [InlineData("v1.0", false)] + [InlineData("beta", true)] + [InlineData("beta", false)] + public async Task SubscriptionPatchEmitsOneMutationAndOnlyItsOwnInputs(string profile, bool useCollisionData) + { + var document = await ReadCompatibleSpecAsync(FindRepoRoot(), profile); + const string itemPath = "/subscriptions/{subscription-id}"; + var item = document.Paths[itemPath]; + Assert.Contains(HttpMethod.Get, item.Operations!.Keys); + Assert.Contains(HttpMethod.Patch, item.Operations.Keys); + Assert.DoesNotContain(item.Operations[HttpMethod.Patch].Parameters ?? [], + parameter => parameter.In == ParameterLocation.Query); + + var output = Path.Combine(Path.GetTempPath(), $"changenotifications-patch-{Guid.NewGuid():N}"); + try + { + var config = new GeneratorConfig("Microsoft.Graph.PowerShell.Test.Client", output, + UseCollisionData: useCollisionData); + await new PowerShellWrapperGenerationService(document, config, NullLogger.Instance, + apiVersion: profile).GenerateAsync(TestContext.Current.CancellationToken); + + var source = await File.ReadAllTextAsync(Path.Combine(output, "UpdateMgSubscription.g.cs"), + TestContext.Current.CancellationToken); + Assert.Single(Regex.Matches(source, @"\.PatchAsync\(")); + Assert.DoesNotContain(".GetAsync(", source); + Assert.DoesNotContain("re-fetch", source, StringComparison.OrdinalIgnoreCase); + Assert.DoesNotContain("if (result is null)", source); + Assert.Contains("if (result is not null)", source); + Assert.Contains("WriteObject(result)", source); + Assert.Contains($"GetRequestAdapter(\"{profile}\")", source); + Assert.Contains("AddRequestHeaders(requestConfiguration.Headers)", source); + Assert.Contains("SupportsShouldProcess = true", source); + Assert.Contains("ShouldProcess(SubscriptionId, \"Update\")", source); + Assert.Contains("body.ClientState = ClientState", source); + Assert.Contains("Models.Subscription", source); + Assert.DoesNotContain("public string[]? Property", source); + Assert.DoesNotContain("public int Top", source); + Assert.DoesNotContain("QueryId", source); + Assert.DoesNotContain("PassThru", source); + Assert.DoesNotContain("ReadBack", source); + Assert.DoesNotContain("Refetch", source); + } + finally + { + if (Directory.Exists(output)) + Directory.Delete(output, recursive: true); + } + } +}