/// <summary> /// Uploads registration certificate for the device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='certificate'> /// The base64 encoded certificate raw data. /// </param> /// <param name='authenticationType'> /// The authentication type. Possible values include: 'Invalid', /// 'AzureActiveDirectory' /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <UploadCertificateResponse> UploadCertificateAsync(this IDevicesOperations operations, string deviceName, string resourceGroupName, string certificate, string authenticationType = default(string), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UploadCertificateWithHttpMessagesAsync(deviceName, resourceGroupName, certificate, authenticationType, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Returns the list of devices for the specified manager. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> /// <param name='expand'> /// Specify $expand=details to populate additional fields related to the device /// or $expand=rolloverdetails to populate additional fields related to the /// service data encryption key rollover on device /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IEnumerable <DeviceInner> > ListByManagerAsync(this IDevicesOperations operations, string resourceGroupName, string managerName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListByManagerWithHttpMessagesAsync(resourceGroupName, managerName, expand, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Modifies a Data Box Edge/Gateway resource. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='tags'> /// The tags attached to the Data Box Edge/Gateway resource. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DataBoxEdgeDevice> UpdateAsync(this IDevicesOperations operations, string deviceName, string resourceGroupName, IDictionary <string, string> tags = default(IDictionary <string, string>), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(deviceName, resourceGroupName, tags, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Returns all failover sets for a given device and their eligibility for /// participating in a failover. A failover set refers to a set of volume /// containers that need to be failed-over as a single unit to maintain data /// integrity. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IEnumerable <FailoverSet> > ListFailoverSetsAsync(this IDevicesOperations operations, string deviceName, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListFailoverSetsWithHttpMessagesAsync(deviceName, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Gets the metrics for the specified device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='odataQuery'> /// OData parameters to apply to the operation. /// </param> /// <param name='deviceName'> /// The device name /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IEnumerable <Metrics> > ListMetricsAsync(this IDevicesOperations operations, ODataQuery <MetricFilterInner> odataQuery, string deviceName, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListMetricsWithHttpMessagesAsync(odataQuery, deviceName, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Patches the device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> /// <param name='deviceDescription'> /// Short description given for the device /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DeviceInner> UpdateAsync(this IDevicesOperations operations, string deviceName, string resourceGroupName, string managerName, string deviceDescription = default(string), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(deviceName, resourceGroupName, managerName, deviceDescription, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates a Data Box Edge/Gateway resource. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='dataBoxEdgeDevice'> /// The resource object. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DataBoxEdgeDevice> BeginCreateOrUpdateAsync(this IDevicesOperations operations, string deviceName, DataBoxEdgeDevice dataBoxEdgeDevice, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(deviceName, dataBoxEdgeDevice, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Returns the properties of the specified device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> /// <param name='expand'> /// Specify $expand=details to populate additional fields related to the device /// or $expand=rolloverdetails to populate additional fields related to the /// service data encryption key rollover on device /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <Device> GetAsync(this IDevicesOperations operations, string deviceName, string resourceGroupName, string managerName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetWithHttpMessagesAsync(deviceName, resourceGroupName, managerName, expand, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Gets information about the availability of updates based on the last scan /// of the device. It also gets information about any ongoing download or /// install jobs on the device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <UpdateSummary> GetUpdateSummaryAsync(this IDevicesOperations operations, string deviceName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetUpdateSummaryWithHttpMessagesAsync(deviceName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// This method generates the CIK of length 128 chars /// </summary> /// <returns></returns> public static string GenerateCIK(this IDevicesOperations operations) { var randomNumberGenerator = RandomNumberGenerator.Create(); var byteArr = new byte[128]; randomNumberGenerator.GetBytes(byteArr); var cik = Convert.ToBase64String(byteArr).Substring(0, StandardSizeOfCIK); return(cik); }
/// <summary> /// Uploads the vault certificate. /// </summary> /// <param name="resourceGroupName"></param> /// <param name="resourceName"></param> /// <param name="cert"></param> /// <returns></returns> internal static UploadCertificateResponse UploadVaultCertificate(IDevicesOperations operations, string resourceGroupName, string resourceName, X509Certificate2 cert) { var request = new UploadCertificateRequest { Certificate = Convert.ToBase64String(cert.RawData) }; return(operations.UploadCertificate(resourceName, request, resourceGroupName)); }
/// <summary> /// Use this method to generate the activation key for a device to register it with the ASE resource /// </summary> /// <param name="resourceGroupName">Name of the resource group</param> /// <param name="resourceName">Name of the resource</param> /// <param name="resourceLocation">Location of the resource</param> /// <returns></returns> public static string GenerateActivationKey(this IDevicesOperations operations, string resourceGroupName, string resourceName, string cik) { var resourceLocation = operations.Get(resourceName, resourceGroupName).Location; var subscriptionId = (operations as DevicesOperations).Client.SubscriptionId; var generateCertResponse = ActivationKeyHelper.GenerateVaultCertificate(operations, resourceGroupName, resourceName); var certPublicPart = ActivationKeyHelper.ImportCertificate(generateCertResponse.PublicKey); var uploadCertificateResponse = ActivationKeyHelper.UploadVaultCertificate(operations, resourceGroupName, resourceName, certPublicPart); var activationKeyToRegisterTheResource = ActivationKeyHelper.GetAadActivationKey(resourceGroupName, resourceName, resourceLocation, generateCertResponse.PrivateKey, uploadCertificateResponse, subscriptionId, cik); return(activationKeyToRegisterTheResource); }
/// <summary> /// Use this method to encrypt the user secrets (Storage Account Access Key, Volume Container Encryption Key etc.) /// </summary> /// <param name="deviceName"> /// The resource name. /// </param> /// <param name="resourceGroupName"> /// The resource group name. /// </param> /// <param name="plainTextSecret"> /// The plain text secret. /// </param> /// <returns> /// The <see cref="AsymmetricEncryptedSecret"/>. /// </returns> /// <exception cref="ValidationException"> /// </exception> /// <exception cref="InvalidOperationException"> /// </exception> public static AsymmetricEncryptedSecret GetAsymmetricEncryptedSecret( this IDevicesOperations operations, string deviceName, string resourceGroupName, string plainTextSecret, string activationKey) { if (string.IsNullOrWhiteSpace(activationKey)) { throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "activationKey"); } string channelIntegrationKey = GetChannelIntegrityKey(activationKey); return(operations.GetAsymmetricEncryptedSecretFromCIK(deviceName, resourceGroupName, plainTextSecret, channelIntegrationKey)); }
/// <summary> /// Use this method to encrypt the user secrets (Storage Account Access Key, Volume Container Encryption Key etc.) /// </summary> /// <param name="deviceName"> /// The resource name. /// </param> /// <param name="resourceGroupName"> /// The resource group name. /// </param> /// <param name="plainTextSecret"> /// The plain text secret. /// </param> /// <returns> /// The <see cref="AsymmetricEncryptedSecret"/>. /// </returns> /// <exception cref="ValidationException"> /// </exception> /// <exception cref="InvalidOperationException"> /// </exception> public static AsymmetricEncryptedSecret GetAsymmetricEncryptedSecretFromCIK( this IDevicesOperations operations, string deviceName, string resourceGroupName, string plainTextSecret, string channelIntegrationKey) { if (string.IsNullOrWhiteSpace(plainTextSecret)) { throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "plainTextSecret"); } if (string.IsNullOrWhiteSpace(resourceGroupName)) { throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); } if (string.IsNullOrWhiteSpace(deviceName)) { throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceName"); } DataBoxEdgeDeviceExtendedInfo extendedInfo = operations.GetExtendedInformation(deviceName, resourceGroupName); string encryptionKey = extendedInfo.EncryptionKey; string encryptionKeyThumbprint = extendedInfo.EncryptionKeyThumbprint; string ChannelEncryptionKey = CryptoUtilities.DecryptStringAES(encryptionKey, channelIntegrationKey); var secret = new AsymmetricEncryptedSecret() { EncryptionAlgorithm = EncryptionAlgorithm.AES256, EncryptionCertThumbprint = encryptionKeyThumbprint, Value = CryptoUtilities.EncryptStringRsaPkcs1v15(plainTextSecret, ChannelEncryptionKey) }; return(secret); }
/// <summary> /// Gets all the data box edge/gateway devices in a resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='expand'> /// Specify $expand=details to populate additional fields related to the /// resource or Specify $skipToken=<token> to populate the next page in /// the list. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IPage <DataBoxEdgeDevice> > ListByResourceGroupAsync(this IDevicesOperations operations, string resourceGroupName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, expand, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Gets all the data box edge/gateway devices in a subscription. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='nextPageLink'> /// The NextLink from the previous successful call to List operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IPage <DataBoxEdgeDevice> > ListBySubscriptionNextAsync(this IDevicesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Gets all the data box edge/gateway devices in a resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='nextPageLink'> /// The NextLink from the previous successful call to List operation. /// </param> public static IPage <DataBoxEdgeDevice> ListByResourceGroupNext(this IDevicesOperations operations, string nextPageLink) { return(operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult()); }
/// <summary> /// Updates the security settings on a data box edge/gateway device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='deviceAdminPassword'> /// Device administrator password as an encrypted string (encrypted using RSA /// PKCS #1) is used to sign into the local web UI of the device. The Actual /// password should have at least 8 characters that are a combination of /// uppercase, lowercase, numeric, and special characters. /// </param> public static void BeginCreateOrUpdateSecuritySettings(this IDevicesOperations operations, string deviceName, string resourceGroupName, AsymmetricEncryptedSecret deviceAdminPassword) { operations.BeginCreateOrUpdateSecuritySettingsAsync(deviceName, resourceGroupName, deviceAdminPassword).GetAwaiter().GetResult(); }
/// <summary> /// Updates the security settings on a data box edge/gateway device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='deviceAdminPassword'> /// Device administrator password as an encrypted string (encrypted using RSA /// PKCS #1) is used to sign into the local web UI of the device. The Actual /// password should have at least 8 characters that are a combination of /// uppercase, lowercase, numeric, and special characters. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task BeginCreateOrUpdateSecuritySettingsAsync(this IDevicesOperations operations, string deviceName, string resourceGroupName, AsymmetricEncryptedSecret deviceAdminPassword, CancellationToken cancellationToken = default(CancellationToken)) { (await operations.BeginCreateOrUpdateSecuritySettingsWithHttpMessagesAsync(deviceName, resourceGroupName, deviceAdminPassword, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <summary> /// Scans for updates on a data box edge/gateway device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> public static void BeginScanForUpdates(this IDevicesOperations operations, string deviceName, string resourceGroupName) { operations.BeginScanForUpdatesAsync(deviceName, resourceGroupName).GetAwaiter().GetResult(); }
/// <summary> /// Scans for updates on a data box edge/gateway device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task BeginScanForUpdatesAsync(this IDevicesOperations operations, string deviceName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) { (await operations.BeginScanForUpdatesWithHttpMessagesAsync(deviceName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <summary> /// Gets the network settings of the specified data box edge/gateway device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> public static NetworkSettings GetNetworkSettings(this IDevicesOperations operations, string deviceName, string resourceGroupName) { return(operations.GetNetworkSettingsAsync(deviceName, resourceGroupName).GetAwaiter().GetResult()); }
/// <summary> /// Gets additional information for the specified data box edge/gateway device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DataBoxEdgeDeviceExtendedInfo> GetExtendedInformationAsync(this IDevicesOperations operations, string deviceName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetExtendedInformationWithHttpMessagesAsync(deviceName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates a Data Box Edge/Gateway resource. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='dataBoxEdgeDevice'> /// The resource object. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> public static DataBoxEdgeDevice BeginCreateOrUpdate(this IDevicesOperations operations, string deviceName, DataBoxEdgeDevice dataBoxEdgeDevice, string resourceGroupName) { return(operations.BeginCreateOrUpdateAsync(deviceName, dataBoxEdgeDevice, resourceGroupName).GetAwaiter().GetResult()); }
/// <summary> /// Creates or updates the additional information of a the data box /// edge/gateway device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='parameters'> /// The additional information. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> public static DataBoxEdgeDeviceExtendedInfo CreateOrUpdateExtendedInfo(this IDevicesOperations operations, string deviceName, DataBoxEdgeDeviceExtendedInfo parameters, string resourceGroupName) { return(operations.CreateOrUpdateExtendedInfoAsync(deviceName, parameters, resourceGroupName).GetAwaiter().GetResult()); }
/// <summary> /// Uploads registration certificate for the device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='certificate'> /// The base64 encoded certificate raw data. /// </param> /// <param name='authenticationType'> /// The authentication type. Possible values include: 'Invalid', /// 'AzureActiveDirectory' /// </param> public static UploadCertificateResponse UploadCertificate(this IDevicesOperations operations, string deviceName, string resourceGroupName, string certificate, string authenticationType = default(string)) { return(operations.UploadCertificateAsync(deviceName, resourceGroupName, certificate, authenticationType).GetAwaiter().GetResult()); }
/// <summary> /// Gets all the data box edge/gateway devices in a subscription. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='expand'> /// Specify $expand=details to populate additional fields related to the /// resource or Specify $skipToken=<token> to populate the next page in /// the list. /// </param> public static IPage <DataBoxEdgeDevice> ListBySubscription(this IDevicesOperations operations, string expand = default(string)) { return(operations.ListBySubscriptionAsync(expand).GetAwaiter().GetResult()); }
/// <summary> /// Gets information about the availability of updates based on the last scan /// of the device. It also gets information about any ongoing download or /// install jobs on the device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> public static UpdateSummary GetUpdateSummary(this IDevicesOperations operations, string deviceName, string resourceGroupName) { return(operations.GetUpdateSummaryAsync(deviceName, resourceGroupName).GetAwaiter().GetResult()); }
/// <summary> /// Gets all the data box edge/gateway devices in a resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> /// <param name='expand'> /// Specify $expand=details to populate additional fields related to the /// resource or Specify $skipToken=<token> to populate the next page in /// the list. /// </param> public static IPage <DataBoxEdgeDevice> ListByResourceGroup(this IDevicesOperations operations, string resourceGroupName, string expand = default(string)) { return(operations.ListByResourceGroupAsync(resourceGroupName, expand).GetAwaiter().GetResult()); }
/// <summary> /// Gets additional information for the specified data box edge/gateway device. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='resourceGroupName'> /// The resource group name. /// </param> public static DataBoxEdgeDeviceExtendedInfo GetExtendedInformation(this IDevicesOperations operations, string deviceName, string resourceGroupName) { return(operations.GetExtendedInformationAsync(deviceName, resourceGroupName).GetAwaiter().GetResult()); }