Open robinmholt opened 1 week ago
Attempted a kludge to make this work. NOTE: THIS IS WRONG!
commit e170284aa3d3a967f9d06da7d2682e16ab2c684e
Author: Robin Holt <robin.holt@daikinapplied.com>
Date: Sat Nov 16 06:33:49 2024 -0600
Feature #26664: Add IsVerified option to Add-AzIoTDeviceProvisioningServiceCertificate
Currently, the command does not support the IsVerified option which
makes the certificate validation unnecessary.
KLUDGE WARNING: THIS CODE IS WRONG!!! I FORCE THE API VERSION TO A
NEWER VERSION WITHOUT USING THE AUTOREST MAGIC TO REGENERATE WHATEVER IS
BEING GENERATED. I COULD NOT FIND THE DOCUMENTATION AND REALLY DIDN'T
CARE.
I verified that with this change, the API call now has the isVerified
property set in the body of the PUT request and the certificate is added
with its verified flag set.
diff --git a/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/DpsCertificateOperations.cs b/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/DpsCertificateOperations.cs
index 95ad4bd19b3..35715953b72 100644
--- a/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/DpsCertificateOperations.cs
+++ b/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/DpsCertificateOperations.cs
@@ -306,7 +306,7 @@ namespace Microsoft.Azure.Management.DeviceProvisioningServices
/// <return>
/// A response object containing the response body and response headers.
/// </return>
- public async Task<AzureOperationResponse<CertificateResponse>> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ public async Task<AzureOperationResponse<CertificateResponse>> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), bool isVerified = false, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.ApiVersion == null)
{
@@ -340,6 +340,8 @@ namespace Microsoft.Azure.Management.DeviceProvisioningServices
{
certificateDescription.Certificate = certificate;
}
+ certificateDescription.IsVerified = isVerified;
+
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
@@ -365,7 +367,7 @@ namespace Microsoft.Azure.Management.DeviceProvisioningServices
List<string> _queryParameters = new List<string>();
if (Client.ApiVersion != null)
{
- _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString("2020-03-01")));
}
if (_queryParameters.Count > 0)
{
diff --git a/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/DpsCertificateOperationsExtensions.cs b/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/DpsCertificateOperationsExtensions.cs
index da68b00bbfc..e4a9063033a 100644
--- a/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/DpsCertificateOperationsExtensions.cs
+++ b/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/DpsCertificateOperationsExtensions.cs
@@ -99,9 +99,9 @@ namespace Microsoft.Azure.Management.DeviceProvisioningServices
/// Base-64 representation of the X509 leaf certificate .cer file or just .pem
/// file content.
/// </param>
- public static CertificateResponse CreateOrUpdate(this IDpsCertificateOperations operations, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string))
+ public static CertificateResponse CreateOrUpdate(this IDpsCertificateOperations operations, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), bool isVerified = false)
{
- return operations.CreateOrUpdateAsync(resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificate).GetAwaiter().GetResult();
+ return operations.CreateOrUpdateAsync(resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificate, isVerified).GetAwaiter().GetResult();
}
/// <summary>
@@ -133,9 +133,9 @@ namespace Microsoft.Azure.Management.DeviceProvisioningServices
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
- public static async Task<CertificateResponse> CreateOrUpdateAsync(this IDpsCertificateOperations operations, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ public static async Task<CertificateResponse> CreateOrUpdateAsync(this IDpsCertificateOperations operations, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), bool isVerified = false, CancellationToken cancellationToken = default(CancellationToken))
{
- using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificate, null, cancellationToken).ConfigureAwait(false))
+ using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificate, isVerified, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
diff --git a/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/IDpsCertificateOperations.cs b/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/IDpsCertificateOperations.cs
index 9ec14ce8004..50286d93042 100644
--- a/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/IDpsCertificateOperations.cs
+++ b/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/IDpsCertificateOperations.cs
@@ -93,7 +93,7 @@ namespace Microsoft.Azure.Management.DeviceProvisioningServices
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
- Task<AzureOperationResponse<CertificateResponse>> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ Task<AzureOperationResponse<CertificateResponse>> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), bool isVerified = false, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Delete the Provisioning Service Certificate.
/// </summary>
diff --git a/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/Models/CertificateBodyDescription.cs b/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/Models/CertificateBodyDescription.cs
index 9f0f9360730..2c8ec63915d 100644
--- a/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/Models/CertificateBodyDescription.cs
+++ b/src/DeviceProvisioningServices/DeviceProvisioningServices.Management.Sdk/Generated/Models/CertificateBodyDescription.cs
@@ -49,5 +49,10 @@ namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models
[JsonProperty(PropertyName = "certificate")]
public string Certificate { get; set; }
+ /// <summary>
+ /// Gets or sets the indicator of whether the certificate is verified.
+ /// </summary>
+ [JsonProperty(PropertyName = "isVerified")]
+ public bool IsVerified { get; set; } = false;
}
}
diff --git a/src/DeviceProvisioningServices/DeviceProvisioningServices/Cmdlet/IotDpsCertificates/AddAzureRmIotDeviceProvisioningServiceCertificate.cs b/src/DeviceProvisioningServices/DeviceProvisioningServices/Cmdlet/IotDpsCertificates/AddAzureRmIotDeviceProvisioningServiceCertificate.cs
index 041795d5824..27b5b141c0c 100644
--- a/src/DeviceProvisioningServices/DeviceProvisioningServices/Cmdlet/IotDpsCertificates/AddAzureRmIotDeviceProvisioningServiceCertificate.cs
+++ b/src/DeviceProvisioningServices/DeviceProvisioningServices/Cmdlet/IotDpsCertificates/AddAzureRmIotDeviceProvisioningServiceCertificate.cs
@@ -112,6 +112,11 @@ namespace Microsoft.Azure.Commands.Management.DeviceProvisioningServices
[ValidateNotNullOrEmpty]
public string Etag { get; set; }
+ [Parameter(
+ Mandatory = false,
+ HelpMessage = "Set the isVerified property on the certificate upon upload.")]
+ public bool IsVerified { get; set; } = false;
+
public override void ExecuteCmdlet()
{
Path = ResolveUserPath(Path);
@@ -167,7 +172,14 @@ namespace Microsoft.Azure.Commands.Management.DeviceProvisioningServices
certificateBodyDescription.Certificate = certificate;
CertificateResponse certificateResponse;
- certificateResponse = this.IotDpsClient.DpsCertificate.CreateOrUpdate(this.ResourceGroupName, this.Name, this.CertificateName, this.Etag, certificateBodyDescription.Certificate);
+ certificateResponse = this.IotDpsClient.DpsCertificate.CreateOrUpdate(
+ resourceGroupName: this.ResourceGroupName,
+ provisioningServiceName: this.Name,
+ certificateName: this.CertificateName,
+ ifMatch: this.Etag,
+ certificate: certificateBodyDescription.Certificate,
+ isVerified: IsVerified
+ );
this.WriteObject(IotDpsUtils.ToPSCertificateResponse(certificateResponse));
}
Description of the new feature
Add
-IsVerified
parameter to the Add-AzIoTDeviceProvisioningServiceCertificate command similar to az cli's az iot dps certificate create.Proposed implementation details (optional)
No response