Exemplo n.º 1
0
        public void KustoPrincipalAssignmentsTests()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                var testBase = new KustoTestBase(context);

                //create cluster
                var createdCluster = testBase.client.Clusters.CreateOrUpdate(testBase.rgName, testBase.clusterName, testBase.cluster);

                var principalName = "principal1";
                //create cluster principal assignment
                var clusterPrincipalAssignment = new ClusterPrincipalAssignment(testBase.clientIdForPrincipal, "AllDatabasesAdmin", "App");
                testBase.client.ClusterPrincipalAssignments.CreateOrUpdate(testBase.rgName, testBase.clusterName, principalName, clusterPrincipalAssignment);
                testBase.client.ClusterPrincipalAssignments.Get(testBase.rgName, testBase.clusterName, principalName);
                testBase.client.ClusterPrincipalAssignments.Delete(testBase.rgName, testBase.clusterName, principalName);
                Assert.Throws <CloudException>(() =>
                {
                    testBase.client.ClusterPrincipalAssignments.Get(testBase.rgName, testBase.clusterName, principalName);
                });

                //create database
                var createdDb = testBase.client.Databases.CreateOrUpdate(testBase.rgName, createdCluster.Name, testBase.databaseName, testBase.database);

                //create database principal assignment
                var databasePrincipalAssignment = new DatabasePrincipalAssignment(testBase.clientIdForPrincipal, "Viewer", "App");
                testBase.client.DatabasePrincipalAssignments.CreateOrUpdate(testBase.rgName, testBase.clusterName, testBase.databaseName, principalName, databasePrincipalAssignment);
                testBase.client.DatabasePrincipalAssignments.Get(testBase.rgName, testBase.clusterName, testBase.databaseName, principalName);
                testBase.client.DatabasePrincipalAssignments.Delete(testBase.rgName, testBase.clusterName, testBase.databaseName, principalName);
                Assert.Throws <CloudException>(() =>
                {
                    testBase.client.DatabasePrincipalAssignments.Get(testBase.rgName, testBase.clusterName, testBase.databaseName, principalName);
                });

                //delete database
                testBase.client.Databases.Delete(testBase.rgName, testBase.clusterName, testBase.databaseName);

                //delete cluster
                testBase.client.Clusters.Delete(testBase.rgName, testBase.clusterName);
            }
        }
 /// <summary>
 /// Creates a Kusto cluster database principalAssignment.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group containing the Kusto cluster.
 /// </param>
 /// <param name='clusterName'>
 /// The name of the Kusto cluster.
 /// </param>
 /// <param name='databaseName'>
 /// The name of the database in the Kusto cluster.
 /// </param>
 /// <param name='principalAssignmentName'>
 /// The name of the Kusto principalAssignment.
 /// </param>
 /// <param name='parameters'>
 /// The Kusto principalAssignments parameters supplied for the operation.
 /// </param>
 public static DatabasePrincipalAssignment BeginCreateOrUpdate(this IDatabasePrincipalAssignmentsOperations operations, string resourceGroupName, string clusterName, string databaseName, string principalAssignmentName, DatabasePrincipalAssignment parameters)
 {
     return(operations.BeginCreateOrUpdateAsync(resourceGroupName, clusterName, databaseName, principalAssignmentName, parameters).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Creates a Kusto cluster database principalAssignment.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group containing the Kusto cluster.
 /// </param>
 /// <param name='clusterName'>
 /// The name of the Kusto cluster.
 /// </param>
 /// <param name='databaseName'>
 /// The name of the database in the Kusto cluster.
 /// </param>
 /// <param name='principalAssignmentName'>
 /// The name of the Kusto principalAssignment.
 /// </param>
 /// <param name='parameters'>
 /// The Kusto principalAssignments parameters supplied for the operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <DatabasePrincipalAssignment> BeginCreateOrUpdateAsync(this IDatabasePrincipalAssignmentsOperations operations, string resourceGroupName, string clusterName, string databaseName, string principalAssignmentName, DatabasePrincipalAssignment parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, databaseName, principalAssignmentName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Creates a Kusto pool database principalAssignment.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='workspaceName'>
 /// The name of the workspace.
 /// </param>
 /// <param name='kustoPoolName'>
 /// The name of the Kusto pool.
 /// </param>
 /// <param name='databaseName'>
 /// The name of the database in the Kusto pool.
 /// </param>
 /// <param name='principalAssignmentName'>
 /// The name of the Kusto principalAssignment.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='parameters'>
 /// The Kusto principalAssignments parameters supplied for the operation.
 /// </param>
 public static DatabasePrincipalAssignment BeginCreateOrUpdate(this IKustoPoolDatabasePrincipalAssignmentsOperations operations, string workspaceName, string kustoPoolName, string databaseName, string principalAssignmentName, string resourceGroupName, DatabasePrincipalAssignment parameters)
 {
     return(operations.BeginCreateOrUpdateAsync(workspaceName, kustoPoolName, databaseName, principalAssignmentName, resourceGroupName, parameters).GetAwaiter().GetResult());
 }