コード例 #1
0
        internal static ClusterListResult DeserializeClusterListResult(JsonElement element)
        {
            Optional <IReadOnlyList <EventHubClusterData> > value = default;
            Optional <string> nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <EventHubClusterData> array = new List <EventHubClusterData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(EventHubClusterData.DeserializeEventHubClusterData(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new ClusterListResult(Optional.ToList(value), nextLink.Value));
        }
コード例 #2
0
        public async Task CreateGetUpdateDeleteCluster()
        {
            //create a cluster
            _resourceGroup = await CreateResourceGroupAsync();

            string clusterName = Recording.GenerateAssetName("cluster");
            EventHubClusterCollection clusterCollection = _resourceGroup.GetEventHubClusters();
            EventHubClusterData       parameter         = new EventHubClusterData(Location.EastUS2);
            EventHubCluster           cluster           = (await clusterCollection.CreateOrUpdateAsync(clusterName, parameter)).Value;

            Assert.NotNull(cluster);
            Assert.AreEqual(cluster.Data.Name, clusterName);

            //get the cluster
            cluster = await clusterCollection.GetAsync(clusterName);

            Assert.NotNull(cluster);
            Assert.AreEqual(cluster.Data.Name, clusterName);

            //get the namespace under cluster
            IReadOnlyList <SubResource> namspaceIds = (await cluster.GetNamespacesAsync()).Value;

            //update the cluster
            cluster.Data.Tags.Add("key", "value");
            cluster = (await cluster.UpdateAsync(cluster.Data)).Value;
            Assert.AreEqual(cluster.Data.Tags["key"], "value");

            //delete the cluster
            await cluster.DeleteAsync();

            Assert.IsFalse(await clusterCollection.CheckIfExistsAsync(clusterName));
        }
コード例 #3
0
        EventHubCluster IOperationSource <EventHubCluster> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = EventHubClusterData.DeserializeEventHubClusterData(document.RootElement);

            return(new EventHubCluster(_armClient, data));
        }
コード例 #4
0
        public async Task CreateGetUpdateDeleteCluster()
        {
            //create a cluster
            _resourceGroup = await CreateResourceGroupAsync();

            string clusterName = Recording.GenerateAssetName("cluster");
            EventHubClusterCollection clusterCollection = _resourceGroup.GetEventHubClusters();
            EventHubClusterData       parameter         = new EventHubClusterData(AzureLocation.EastUS2);
            EventHubClusterResource   cluster           = (await clusterCollection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, parameter)).Value;

            Assert.NotNull(cluster);
            Assert.AreEqual(cluster.Data.Name, clusterName);

            //get the cluster
            cluster = await clusterCollection.GetAsync(clusterName);

            Assert.NotNull(cluster);
            Assert.AreEqual(cluster.Data.Name, clusterName);

            //get the namespace under cluster
            SubResource subResource = null;

            await foreach (var namespaceId in cluster.GetNamespacesAsync())
            {
                subResource = namespaceId;
                break;
            }

            Assert.NotNull(subResource);

            //update the cluster
            cluster.Data.Tags.Add("key", "value");
            cluster = (await cluster.UpdateAsync(WaitUntil.Completed, cluster.Data)).Value;
            Assert.AreEqual(cluster.Data.Tags["key"], "value");

            //delete the cluster
            await cluster.DeleteAsync(WaitUntil.Completed);

            Assert.IsFalse(await clusterCollection.ExistsAsync(clusterName));
        }