/// <summary>
        /// Create Database If not exist
        /// Note: Created Database will have ulimited days of retention period and 0 cache period.
        /// </summary>
        /// <param name="databaseName">Azure Data Explorer Database Name.</param>
        public async Task CreateDatabaseIfNotExistAsync(string databaseName)
        {
            CheckNameRequest checkNameRequest = new CheckNameRequest(databaseName, Type.MicrosoftKustoClustersDatabases);

            CheckNameResult databaseNameAvailability = this.client.Databases.CheckNameAvailability(
                this.config.Global.ResourceGroup,
                this.config.Global.DataExplorer.Name,
                checkNameRequest);

            if (databaseNameAvailability.NameAvailable.GetValueOrDefault())
            {
                try
                {
                    await this.CreateDBInClusterAsync(databaseName, null, new TimeSpan(0, 0, 0, 0));
                }
                catch (CloudException e)
                {
                    if (e.Body.Code == "ResourceNotFound")
                    {
                        throw new ResourceNotFoundException($"Error Creating kusto database {databaseName}");
                    }

                    throw e;
                }
            }
        }
        public IHttpActionResult CheckName(string storeId, string name, string language, string id = "")
        {
            var retVal   = _menuService.CheckList(storeId, name, language, id);
            var response = new CheckNameResult {
                Result = retVal
            };

            return(Ok(response));
        }
Esempio n. 3
0
        public IHttpActionResult CheckName(string storeId, [FromUri] string pageName, [FromUri] string language)
        {
            var result   = _pagesService.CheckList(storeId, pageName, language);
            var response = new CheckNameResult {
                Result = result
            };

            return(Ok(response));
        }
Esempio n. 4
0
        public IHttpActionResult CheckName(string storeId, [FromUri] string pageName, [FromUri] string language)
        {
            CheckCurrentUserHasPermissionForObjects(ContentPredefinedPermissions.Read, new ContentScopeObject {
                StoreId = storeId
            });
            var response = new CheckNameResult {
                Result = true
            };

            return(Ok(response));
        }
Esempio n. 5
0
        public IHttpActionResult CheckName(string storeId, string name, string language, string id = "")
        {
            base.CheckCurrentUserHasPermissionForObjects(ContentPredefinedPermissions.Read, new ContentScopeObject {
                StoreId = storeId
            });

            var retVal   = _menuService.CheckList(storeId, name, language, id);
            var response = new CheckNameResult {
                Result = retVal
            };

            return(Ok(response));
        }
Esempio n. 6
0
 public void SendCheckNameResult(IConnection connection, string name, CheckNameResult result)
 {
     new SpCheckName(name, result).Send(connection);
 }
Esempio n. 7
0
 public void SendCheckNameResult(IConnection connection, string name, CheckNameResult result)
 {
     new SpCheckName(name, result).Send(connection);
 }
Esempio n. 8
0
 public void SendCheckNameResult(IConnection connection, string name, short type, CheckNameResult result)
 {
     new SpCharacterCheckNameResult(result.GetHashCode(), name, type).Send(connection);
 }
Esempio n. 9
0
 public void SendCheckNameResult(IConnection connection, string name, short type, CheckNameResult result)
 {
     new SpCharacterCheckNameResult(result.GetHashCode(), name, type).Send(connection);
 }
Esempio n. 10
0
        public static void CheckName(IConnection connection, string name, short type)
        {
            CheckNameResult result = PlayerService.CheckName(name, type);

            FeedbackService.SendCheckNameResult(connection, name, type, result);
        }
Esempio n. 11
0
 public SpCheckName(string name, CheckNameResult rs)
 {
     Name = name;
     Result = rs;
 }
        public async Task TestDigitalTwinsLifecycle()
        {
            using var context = MockContext.Start(GetType());

            Initialize(context);

            // Create Resource Group
            ResourceGroup rg = await ResourcesClient.ResourceGroups.CreateOrUpdateAsync(
                DefaultResourceGroupName,
                new ResourceGroup
            {
                Location = DefaultLocation,
            });

            try
            {
                // Check if instance exists and delete
                CheckNameResult dtNameCheck = await DigitalTwinsClient.DigitalTwins.CheckNameAvailabilityAsync(
                    DefaultLocation,
                    DefaultInstanceName);

                if (!dtNameCheck.NameAvailable.Value)
                {
                    DigitalTwinsDescription dtDelete = await DigitalTwinsClient.DigitalTwins.DeleteAsync(
                        rg.Name,
                        DefaultInstanceName);

                    dtDelete.ProvisioningState.Should().Be(ProvisioningState.Deleted);

                    dtNameCheck = await DigitalTwinsClient.DigitalTwins.CheckNameAvailabilityAsync(
                        DefaultLocation,
                        DefaultInstanceName);

                    dtNameCheck.NameAvailable.Should().BeTrue();
                }

                // Create DigitalTwins resource
                var dtInstance = await DigitalTwinsClient.DigitalTwins.CreateOrUpdateAsync(
                    rg.Name,
                    DefaultInstanceName,
                    new DigitalTwinsDescription
                {
                    Location = DefaultLocation,
                });

                try
                {
                    dtInstance.Should().NotBeNull();
                    dtInstance.Name.Should().Be(DefaultInstanceName);
                    dtInstance.Location.Should().Be(DefaultLocation);

                    // Add and Get Tags
                    const string key2   = "key2";
                    const string value2 = "value2";
                    var          patch  = new DigitalTwinsPatchDescription(
                        tags: new Dictionary <string, string>
                    {
                        { "key1", "value1" },
                        { key2, value2 },
                    });
                    dtInstance = await DigitalTwinsClient.DigitalTwins.UpdateAsync(
                        rg.Name,
                        dtInstance.Name,
                        patch);

                    dtInstance.Should().NotBeNull();
                    dtInstance.Tags.Count().Should().Be(2);
                    dtInstance.Tags[key2].Should().Be(value2);

                    // List DigitalTwins instances in Resource Group
                    var twinsResources = await DigitalTwinsClient.DigitalTwins.ListByResourceGroupAsync(rg.Name);

                    twinsResources.Count().Should().BeGreaterThan(0);

                    // Get all of the available operations, ensure CRUD
                    var operationList = await DigitalTwinsClient.Operations.ListAsync();

                    operationList.Count().Should().BeGreaterThan(0);
                    Assert.Contains(operationList, e => e.Name.Equals($"Microsoft.DigitalTwins/digitalTwinsInstances/read", StringComparison.OrdinalIgnoreCase));
                    Assert.Contains(operationList, e => e.Name.Equals($"Microsoft.DigitalTwins/digitalTwinsInstances/write", StringComparison.OrdinalIgnoreCase));
                    Assert.Contains(operationList, e => e.Name.Equals($"Microsoft.DigitalTwins/digitalTwinsInstances/delete", StringComparison.OrdinalIgnoreCase));

                    // Test other operations

                    // Register Operation
                    var registerOperations = operationList.Where(e => e.Name.Contains($"Microsoft.DigitalTwins/register"));
                    registerOperations.Count().Should().BeGreaterThan(0);

                    // Twin Operations
                    var twinOperations = operationList.Where(e => e.Name.Contains($"Microsoft.DigitalTwins/digitaltwins"));
                    twinOperations.Count().Should().BeGreaterThan(0);

                    // Event Route Operations
                    var eventRouteOperations = operationList.Where(e => e.Name.Contains($"Microsoft.DigitalTwins/eventroutes"));
                    eventRouteOperations.Count().Should().BeGreaterThan(0);

                    // Model operations
                    var modelOperations = operationList.Where(e => e.Name.Contains($"Microsoft.DigitalTwins/models"));
                    modelOperations.Count().Should().BeGreaterThan(0);
                }
                finally
                {
                    // Delete instance
                    DigitalTwinsDescription deleteOp = await DigitalTwinsClient.DigitalTwins.BeginDeleteAsync(
                        rg.Name,
                        dtInstance.Name);

                    deleteOp.ProvisioningState.Should().Be(ProvisioningState.Deleting);
                }
            }
            finally
            {
                await ResourcesClient.ResourceGroups.DeleteAsync(rg.Name);
            }
        }
Esempio n. 13
0
 public SpCheckName(string name, CheckNameResult rs)
 {
     Name   = name;
     Result = rs;
 }
 public PSKustoClusterNameAvailability(CheckNameResult CheckClusterNameResult)
 {
     _checkNameResult = CheckClusterNameResult;
 }