VMwareDatastore IOperationSource <VMwareDatastore> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = VMwareDatastoreData.DeserializeVMwareDatastoreData(document.RootElement);

            return(new VMwareDatastore(_armClient, data));
        }
        public async Task Exists()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

            var _extendedLocation = new ExtendedLocation()
            {
                Name = CustomLocationId,
                Type = EXTENDED_LOCATION_TYPE
            };
            var datastoreBody = new VMwareDatastoreData(DefaultLocation);

            datastoreBody.MoRefId          = "datastore-11";
            datastoreBody.VCenterId        = VcenterId;
            datastoreBody.ExtendedLocation = _extendedLocation;
            // create datastore
            VMwareDatastore datastore1 = (await _datastoreCollection.CreateOrUpdateAsync(true, datastoreName, datastoreBody)).Value;

            Assert.IsNotNull(datastore1);
            Assert.AreEqual(datastore1.Id.Name, datastoreName);
            // check for exists datastore
            datastore1 = await _datastoreCollection.GetIfExistsAsync(datastoreName);

            Assert.AreEqual(datastore1.Id.Name, datastoreName);
        }
        public async Task GetAllInSubscription()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

            var _extendedLocation = new ExtendedLocation()
            {
                Name = CustomLocationId,
                Type = EXTENDED_LOCATION_TYPE
            };
            var datastoreBody = new VMwareDatastoreData(DefaultLocation);

            datastoreBody.MoRefId          = "datastore-11";
            datastoreBody.VCenterId        = VcenterId;
            datastoreBody.ExtendedLocation = _extendedLocation;
            // create datastore
            VMwareDatastore datastore1 = (await _datastoreCollection.CreateOrUpdateAsync(true, datastoreName, datastoreBody)).Value;

            Assert.IsNotNull(datastore1);
            Assert.AreEqual(datastore1.Id.Name, datastoreName);
            datastore1 = null;
            await foreach (var datastore in DefaultSubscription.GetVMwareDatastoresAsync())
            {
                if (datastore.Data.Name == datastoreName)
                {
                    datastore1 = datastore;
                }
            }
            Assert.NotNull(datastore1);
        }
        public async Task GetAll()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

            var _extendedLocation = new ExtendedLocation()
            {
                Name = CustomLocationId,
                Type = EXTENDED_LOCATION_TYPE
            };
            var datastoreBody = new VMwareDatastoreData(DefaultLocation);

            datastoreBody.MoRefId          = "datastore-11";
            datastoreBody.VCenterId        = VcenterId;
            datastoreBody.ExtendedLocation = _extendedLocation;
            // create datastore
            VMwareDatastore datastore1 = (await _datastoreCollection.CreateOrUpdateAsync(true, datastoreName, datastoreBody)).Value;

            Assert.IsNotNull(datastore1);
            Assert.AreEqual(datastore1.Id.Name, datastoreName);
            int count = 0;

            await foreach (var cluster in _datastoreCollection.GetAllAsync())
            {
                count++;
            }
            Assert.GreaterOrEqual(count, 1);
        }
示例#5
0
        internal static DatastoresList DeserializeDatastoresList(JsonElement element)
        {
            Optional <string> nextLink = default;
            IReadOnlyList <VMwareDatastoreData> value = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    List <VMwareDatastoreData> array = new List <VMwareDatastoreData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VMwareDatastoreData.DeserializeVMwareDatastoreData(item));
                    }
                    value = array;
                    continue;
                }
            }
            return(new DatastoresList(nextLink.Value, value));
        }
示例#6
0
        public async Task CreateDelete()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

            var _extendedLocation = new ExtendedLocation()
            {
                Name = CustomLocationId,
                ExtendedLocationType = EXTENDED_LOCATION_TYPE
            };
            var datastoreBody = new VMwareDatastoreData(DefaultLocation);

            datastoreBody.MoRefId          = "datastore-11";
            datastoreBody.VCenterId        = VcenterId;
            datastoreBody.ExtendedLocation = _extendedLocation;
            // create datastore
            VMwareDatastoreResource datastore1 = (await _datastoreCollection.CreateOrUpdateAsync(WaitUntil.Completed, datastoreName, datastoreBody)).Value;

            Assert.IsNotNull(datastore1);
            Assert.AreEqual(datastore1.Id.Name, datastoreName);
        }