public override void ExecuteCmdlet() { var updateGatewaySettingsParameters = new UpdateGatewaySettingsParameters { IsCredentialEnabled = true, UserName = HttpCredential.UserName, Password = HttpCredential.Password.ConvertToString() }; if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(ResourceId); this.Name = resourceIdentifier.ResourceName; this.ResourceGroupName = resourceIdentifier.ResourceGroupName; } if (this.IsParameterBound(c => c.InputObject)) { this.Name = this.InputObject.Name; this.ResourceGroupName = this.InputObject.ResourceGroup; } if (ResourceGroupName == null) { ResourceGroupName = GetResourceGroupByAccountName(Name); } if (ShouldProcess(Name, "set gateway http credential")) { HDInsightManagementClient.UpdateGatewayCredential(ResourceGroupName, Name, updateGatewaySettingsParameters); WriteObject(new AzureHDInsightGatewaySettings(HDInsightManagementClient.GetGatewaySettings(ResourceGroupName, Name))); } }
public void TestGetOrUpdateGatewaySettings() { TestInitialize(); string clusterName = TestUtilities.GenerateName("hdisdk-gateway"); var createParams = CommonData.PrepareClusterCreateParamsForWasb(); var cluster = HDInsightClient.Clusters.Create(CommonData.ResourceGroupName, clusterName, createParams); ValidateCluster(clusterName, createParams, cluster); string expectedUserName = CommonData.ClusterUserName; string expectedPassword = CommonData.ClusterPassword; var gatewaySettings = HDInsightClient.Clusters.GetGatewaySettings(CommonData.ResourceGroupName, clusterName); ValidateGatewaySettings(expectedUserName, expectedPassword, gatewaySettings); // Disable gateway settings is not allowed. var updateParams = new UpdateGatewaySettingsParameters { IsCredentialEnabled = false }; try { HDInsightClient.Clusters.UpdateGatewaySettings(CommonData.ResourceGroupName, clusterName, updateParams); Assert.True(false, "Disable gateway settings should fail"); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.MethodNotAllowed, ex.Response.StatusCode); } // Make sure anything stay unchanged after attempting to disable gateway settings. gatewaySettings = HDInsightClient.Clusters.GetGatewaySettings(CommonData.ResourceGroupName, clusterName); ValidateGatewaySettings(expectedUserName, expectedPassword, gatewaySettings); string newExpectedPassword = "******"; updateParams = new UpdateGatewaySettingsParameters { IsCredentialEnabled = true, UserName = expectedUserName, Password = newExpectedPassword }; HDInsightClient.Clusters.UpdateGatewaySettings(CommonData.ResourceGroupName, clusterName, updateParams); gatewaySettings = HDInsightClient.Clusters.GetGatewaySettings(CommonData.ResourceGroupName, clusterName); ValidateGatewaySettings(expectedUserName, newExpectedPassword, gatewaySettings); }
public virtual void UpdateGatewayCredential(string resourceGroupName, string clusterName, UpdateGatewaySettingsParameters updateGatewaySettingsParameters) { HdInsightManagementClient.Clusters.UpdateGatewaySettings(resourceGroupName, clusterName, updateGatewaySettingsParameters); }
/// <summary> /// Configures the gateway settings on the specified cluster. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='clusterName'> /// The name of the cluster. /// </param> /// <param name='parameters'> /// The cluster configurations. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task BeginUpdateGatewaySettingsAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, UpdateGatewaySettingsParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) { (await operations.BeginUpdateGatewaySettingsWithHttpMessagesAsync(resourceGroupName, clusterName, parameters, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <summary> /// Configures the gateway settings on the specified cluster. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='clusterName'> /// The name of the cluster. /// </param> /// <param name='parameters'> /// The cluster configurations. /// </param> public static void BeginUpdateGatewaySettings(this IClustersOperations operations, string resourceGroupName, string clusterName, UpdateGatewaySettingsParameters parameters) { operations.BeginUpdateGatewaySettingsAsync(resourceGroupName, clusterName, parameters).GetAwaiter().GetResult(); }