/// <summary> /// Returns the properties of the specified manager name. /// </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='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ManagerInner> GetAsync(this IManagersOperations operations, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Use this method to fetch the Registration Key which can used for device registration. /// </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> /// <returns> /// The device registration key. /// </returns> public static string GetDeviceRegistrationKey(this IManagersOperations operations, string resourceGroupName, string managerName) { Key activationKey = null; try { activationKey = operations.GetActivationKey(resourceGroupName, managerName); } catch (Exception exception) { throw new Exception( "The call to get the activation key failed. Check inner exception for more details.", exception); } ManagerExtendedInfo managerExtendedInfo = null; try { managerExtendedInfo = operations.GetExtendedInfo(resourceGroupName, managerName); } catch (Microsoft.Rest.Azure.CloudException cloudException) { if (cloudException != null && cloudException.Response != null && !string.IsNullOrEmpty(cloudException.Response.Content)) { #if FullNetFx if (cloudException.Response.Content.IndexOf("ResourceExtendedInfoNotFound", StringComparison.InvariantCultureIgnoreCase) >= 0) #else if (cloudException.Response.Content.IndexOf("ResourceExtendedInfoNotFound", StringComparison.OrdinalIgnoreCase) >= 0) #endif { // Manager extended info not found for manager, creating new extended info" var extendedInfo = new ManagerExtendedInfo() { IntegrityKey = GenerateRandomKey(128), Algorithm = "None", }; managerExtendedInfo = operations.CreateExtendedInfo(extendedInfo, resourceGroupName, managerName); } else { // cases like user session token expired, etc. throw cloudException; } } } var registrationKeyWithoutHash = string.Format( "{0}:{1}", activationKey.ActivationKey, managerExtendedInfo.IntegrityKey); var sha512Hash = GenerateSha512Hash(registrationKeyWithoutHash); var truncatedHash = sha512Hash.Substring(0, 16); return(string.Format("{0}#{1}", registrationKeyWithoutHash, truncatedHash)); }
/// <summary> /// Returns the public encryption key of 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='cancellationToken'> /// The cancellation token. /// </param> public static async Task <PublicKey> GetDevicePublicEncryptionKeyAsync(this IManagersOperations operations, string deviceName, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetDevicePublicEncryptionKeyWithHttpMessagesAsync(deviceName, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Updates the StorSimple 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='tags'> /// The tags attached to the Manager. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ManagerInner> UpdateAsync(this IManagersOperations operations, string resourceGroupName, string managerName, IDictionary <string, string> tags = default(IDictionary <string, string>), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, managerName, tags, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Retrieves all the managers 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='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IEnumerable <Manager> > ListByResourceGroupAsync(this IManagersOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Updates the extended info of the manager. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='parameters'> /// The manager extended information. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> /// <param name='ifMatch'> /// Pass the ETag of ExtendedInfo fetched from GET call /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ManagerExtendedInfoInner> UpdateExtendedInfoAsync(this IManagersOperations operations, ManagerExtendedInfoInner parameters, string resourceGroupName, string managerName, string ifMatch, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateExtendedInfoWithHttpMessagesAsync(parameters, resourceGroupName, managerName, ifMatch, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates the manager. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='parameters'> /// The manager. /// </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 <Manager> CreateOrUpdateAsync(this IManagersOperations operations, Manager parameters, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(parameters, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates the extended info of the manager. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='managerExtendedInfo'> /// The manager extended information. /// </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 <ManagerExtendedInfo> CreateExtendedInfoAsync(this IManagersOperations operations, ManagerExtendedInfo managerExtendedInfo, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateExtendedInfoWithHttpMessagesAsync(managerExtendedInfo, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Gets the metrics for the specified manager. /// </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='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 IManagersOperations operations, ODataQuery <MetricFilterInner> odataQuery, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListMetricsWithHttpMessagesAsync(odataQuery, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Retrieves all the managers in a subscription. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IEnumerable <ManagerInner> > ListAsync(this IManagersOperations operations, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Use this method to encrypt the user secrets (Storage Account Access Key, Volume Container Encryption Key etc.) /// </summary> /// <param name="managerName"> /// 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 IManagersOperations operations, string resourceGroupName, string managerName, string plainTextSecret) { 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(managerName)) { throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "managerName"); } var encryptionSettings = operations.GetEncryptionSettings(resourceGroupName, managerName); if (encryptionSettings.EncryptionStatus == EncryptionStatus.Disabled) { throw new InvalidOperationException( "The EncryptionStatus of this resource is disabled. Register atleast 1 device to your resource before proceeding"); } var encryptionKey = operations.GetPublicEncryptionKey(resourceGroupName, managerName); if (encryptionKey.Value == null) { throw new InvalidOperationException( "The encryptionKey is null. Register atleast 1 device to your resource before proceeding"); } var managerExtendedInfo = operations.GetExtendedInfo(resourceGroupName, managerName); if (managerExtendedInfo == null || string.IsNullOrEmpty(managerExtendedInfo.IntegrityKey)) { throw new InvalidOperationException("An unexpected error has occured in your system. Please retry the operation after sometime or contact support"); } // Decrypt the encrypted encryption key using integrity key. var plainTextEncryptionKey = CryptoHelper.DecryptCipherAES(encryptionKey.Value, managerExtendedInfo.IntegrityKey); // Encrypt the user secret using the plain text encryption key. var encryptedSecret = CryptoHelper.EncryptSecretRSAPKCS(plainTextSecret, plainTextEncryptionKey); return(new AsymmetricEncryptedSecret(encryptedSecret, EncryptionAlgorithm.RSAESPKCS1V15, encryptionKey.ValueCertificateThumbprint)); }
/// <summary> /// Lists the features and their support status /// </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='odataQuery'> /// OData parameters to apply to the operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IEnumerable <Feature> > ListFeatureSupportStatusAsync(this IManagersOperations operations, string resourceGroupName, string managerName, ODataQuery <FeatureFilterInner> odataQuery = default(ODataQuery <FeatureFilterInner>), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListFeatureSupportStatusWithHttpMessagesAsync(resourceGroupName, managerName, odataQuery, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Upload Vault Cred Certificate. /// Returns UploadCertificateResponse /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='certificateName'> /// Certificate Name /// </param> /// <param name='uploadCertificateRequestrequest'> /// UploadCertificateRequest Request /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> public static UploadCertificateResponse UploadRegistrationCertificate(this IManagersOperations operations, string certificateName, UploadCertificateRequest uploadCertificateRequestrequest, string resourceGroupName, string managerName) { return(operations.UploadRegistrationCertificateAsync(certificateName, uploadCertificateRequestrequest, resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Deletes the extended info of the 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='cancellationToken'> /// The cancellation token. /// </param> public static async Task DeleteExtendedInfoAsync(this IManagersOperations operations, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { (await operations.DeleteExtendedInfoWithHttpMessagesAsync(resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <summary> /// Updates the StorSimple Manager. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='parameters'> /// The manager update parameters. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> public static Manager Update(this IManagersOperations operations, ManagerPatch parameters, string resourceGroupName, string managerName) { return(operations.UpdateAsync(parameters, resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Returns the properties of the specified manager name. /// </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> public static Manager Get(this IManagersOperations operations, string resourceGroupName, string managerName) { return(operations.GetAsync(resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Retrieves all the managers in a subscription. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> public static IEnumerable <Manager> List(this IManagersOperations operations) { return(operations.ListAsync().GetAwaiter().GetResult()); }
/// <summary> /// Returns the public encryption key of 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> public static PublicKey GetDevicePublicEncryptionKey(this IManagersOperations operations, string deviceName, string resourceGroupName, string managerName) { return(operations.GetDevicePublicEncryptionKeyAsync(deviceName, resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Re-generates and returns the activation key of the 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> public static Key RegenerateActivationKey(this IManagersOperations operations, string resourceGroupName, string managerName) { return(operations.RegenerateActivationKeyAsync(resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Gets the metrics for the specified manager. /// </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='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> public static IEnumerable <Metrics> ListMetrics(this IManagersOperations operations, ODataQuery <MetricFilter> odataQuery, string resourceGroupName, string managerName) { return(operations.ListMetricsAsync(odataQuery, resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Gets the metric definitions 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> public static IEnumerable <MetricDefinition> ListMetricDefinition(this IManagersOperations operations, string resourceGroupName, string managerName) { return(operations.ListMetricDefinitionAsync(resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Creates the extended info of the manager. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='managerExtendedInfo'> /// The manager extended information. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> public static ManagerExtendedInfo CreateExtendedInfo(this IManagersOperations operations, ManagerExtendedInfo managerExtendedInfo, string resourceGroupName, string managerName) { return(operations.CreateExtendedInfoAsync(managerExtendedInfo, resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Returns the encryption settings of the 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> public static EncryptionSettings GetEncryptionSettings(this IManagersOperations operations, string resourceGroupName, string managerName) { return(operations.GetEncryptionSettingsAsync(resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Lists the features and their support status /// </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='odataQuery'> /// OData parameters to apply to the operation. /// </param> public static IEnumerable <Feature> ListFeatureSupportStatus(this IManagersOperations operations, string resourceGroupName, string managerName, ODataQuery <FeatureFilter> odataQuery = default(ODataQuery <FeatureFilter>)) { return(operations.ListFeatureSupportStatusAsync(resourceGroupName, managerName, odataQuery).GetAwaiter().GetResult()); }
/// <summary> /// Updates the extended info of the manager. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='parameters'> /// The manager extended information. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> /// <param name='ifMatch'> /// Pass the ETag of ExtendedInfo fetched from GET call /// </param> public static ManagerExtendedInfo UpdateExtendedInfo(this IManagersOperations operations, ManagerExtendedInfo parameters, string resourceGroupName, string managerName, string ifMatch) { return(operations.UpdateExtendedInfoAsync(parameters, resourceGroupName, managerName, ifMatch).GetAwaiter().GetResult()); }
/// <summary> /// Deletes the extended info of the 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> public static void DeleteExtendedInfo(this IManagersOperations operations, string resourceGroupName, string managerName) { operations.DeleteExtendedInfoAsync(resourceGroupName, managerName).GetAwaiter().GetResult(); }
/// <summary> /// Retrieves all the managers in a resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> public static IEnumerable <Manager> ListByResourceGroup(this IManagersOperations operations, string resourceGroupName) { return(operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult()); }
/// <summary> /// Upload Vault Cred Certificate. /// Returns UploadCertificateResponse /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='certificateName'> /// Certificate Name /// </param> /// <param name='uploadCertificateRequestrequest'> /// UploadCertificateRequest Request /// </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 <UploadCertificateResponse> UploadRegistrationCertificateAsync(this IManagersOperations operations, string certificateName, UploadCertificateRequest uploadCertificateRequestrequest, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UploadRegistrationCertificateWithHttpMessagesAsync(certificateName, uploadCertificateRequestrequest, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Returns the symmetric encrypted public encryption key of the 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> public static SymmetricEncryptedSecret GetPublicEncryptionKey(this IManagersOperations operations, string resourceGroupName, string managerName) { return(operations.GetPublicEncryptionKeyAsync(resourceGroupName, managerName).GetAwaiter().GetResult()); }
/// <summary> /// Creates or updates the manager. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='manager'> /// The manager. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> public static Manager CreateOrUpdate(this IManagersOperations operations, Manager manager, string resourceGroupName, string managerName) { return(operations.CreateOrUpdateAsync(manager, resourceGroupName, managerName).GetAwaiter().GetResult()); }