public async Task GetAllInSubscription() { var collection = await GetDiskAccessCollectionAsync(); var name1 = Recording.GenerateAssetName("testDA"); var name2 = Recording.GenerateAssetName("testDA"); var input = ResourceDataHelper.GetEmptyDiskAccess(DefaultLocation); _ = await collection.CreateOrUpdateAsync(name1, input); _ = await collection.CreateOrUpdateAsync(name2, input); DiskAccess access1 = null, access2 = null; await foreach (var access in DefaultSubscription.GetDiskAccessesAsync()) { if (access.Data.Name == name1) { access1 = access; } if (access.Data.Name == name2) { access2 = access; } } Assert.NotNull(access1); Assert.NotNull(access2); }
public async Task Get() { var name = Recording.GenerateAssetName("testDA-"); var access1 = await CreateDiskAccessAsync(name); DiskAccess access2 = await access1.GetAsync(); ResourceDataHelper.AssertDiskAccess(access1.Data, access2.Data); }
public async Task CreateOrUpdate() { var collection = await GetDiskAccessCollectionAsync(); var name = Recording.GenerateAssetName("testDA"); var input = ResourceDataHelper.GetEmptyDiskAccess(DefaultLocation); var lro = await collection.CreateOrUpdateAsync(name, input); DiskAccess access = lro.Value; Assert.AreEqual(name, access.Data.Name); }
public async Task Get() { var collection = await GetDiskAccessCollectionAsync(); var name = Recording.GenerateAssetName("testDA"); var input = ResourceDataHelper.GetEmptyDiskAccess(DefaultLocation); var lro = await collection.CreateOrUpdateAsync(name, input); DiskAccess access1 = lro.Value; DiskAccess access2 = await collection.GetAsync(name); ResourceDataHelper.AssertDiskAccess(access1.Data, access2.Data); }
public async Task CheckIfExistsAsync() { var collection = await GetDiskAccessCollectionAsync(); var name = Recording.GenerateAssetName("testDA"); var input = ResourceDataHelper.GetEmptyDiskAccess(DefaultLocation); var lro = await collection.CreateOrUpdateAsync(name, input); DiskAccess access = lro.Value; Assert.IsTrue(await collection.CheckIfExistsAsync(name)); Assert.IsFalse(await collection.CheckIfExistsAsync(name + "1")); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await collection.CheckIfExistsAsync(null)); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { if (ShouldProcess(this.Name, VerbsCommon.New)) { DiskAccess diskAccess = new DiskAccess(); diskAccess.Location = this.Location; var result = DiskAccessesClient.CreateOrUpdate(this.ResourceGroupName, this.Name, diskAccess); var psObject = new PSDiskAccess(); ComputeAutomationAutoMapperProfile.Mapper.Map <DiskAccess, PSDiskAccess>(result, psObject); WriteObject(psObject); } }); }
/// <summary> /// Creates or updates a disk access resource /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='diskAccessName'> /// The name of the disk access resource that is being created. The name can't /// be changed after the disk encryption set is created. Supported characters /// for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 /// characters. /// </param> /// <param name='diskAccess'> /// disk access object supplied in the body of the Put disk access operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task<DiskAccess> CreateOrUpdateAsync(this IDiskAccessesOperations operations, string resourceGroupName, string diskAccessName, DiskAccess diskAccess, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, diskAccessName, diskAccess, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } }
/// <summary> /// Creates or updates a disk access resource /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='diskAccessName'> /// The name of the disk access resource that is being created. The name can't /// be changed after the disk encryption set is created. Supported characters /// for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 /// characters. /// </param> /// <param name='diskAccess'> /// disk access object supplied in the body of the Put disk access operation. /// </param> public static DiskAccess BeginCreateOrUpdate(this IDiskAccessesOperations operations, string resourceGroupName, string diskAccessName, DiskAccess diskAccess) { return operations.BeginCreateOrUpdateAsync(resourceGroupName, diskAccessName, diskAccess).GetAwaiter().GetResult(); }