public async Task Exists() { BastionHost bastionHost = await CreateBastionHost(_bastionName); Assert.IsTrue(await _resourceGroup.GetBastionHosts().ExistsAsync(_bastionName)); Assert.IsFalse(await _resourceGroup.GetBastionHosts().ExistsAsync(_bastionName + "1")); }
public async Task CheckIfExists() { BastionHost bastionHost = await CreateBastionHost(_bastionName); Assert.IsTrue(_resourceGroup.GetBastionHosts().CheckIfExists(_bastionName)); Assert.IsFalse(_resourceGroup.GetBastionHosts().CheckIfExists(_bastionName + "1")); }
public async Task <Response <BastionHost> > GetAsync(string resourceGroupName, string bastionHostName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (bastionHostName == null) { throw new ArgumentNullException(nameof(bastionHostName)); } using var message = CreateGetRequest(resourceGroupName, bastionHostName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { BastionHost value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = BastionHost.DeserializeBastionHost(document.RootElement); } return(Response.FromValue(value, message.Response)); }
ResourceProvisioningResult CreateResult(BastionHost bastion) { var crudResult = ResourceProvisioningResultUtil.CreateFromIResource(bastion); crudResult.CurrentProvisioningState = bastion.ProvisioningState.ToString(); return(crudResult); }
public async Task TestTearDown() { if (await _resourceGroup.GetBastionHosts().ExistsAsync(_bastionName)) { BastionHost bastion = await _resourceGroup.GetBastionHosts().GetAsync(_bastionName); await bastion.DeleteAsync(WaitUntil.Completed); } }
public async Task GetAll() { BastionHost bastionHost = await CreateBastionHost(_bastionName); List <BastionHost> BastionList = await _resourceGroup.GetBastionHosts().GetAllAsync().ToEnumerableAsync(); Has.One.EqualTo(BastionList); Assert.AreEqual(_bastionName, BastionList[0].Data.Name); }
public async Task CreateOrUpdate() { BastionHost bastionHost = await CreateBastionHost(_bastionName); Assert.IsNotNull(bastionHost.Data); Assert.AreEqual(_bastionName, bastionHost.Data.Name); Assert.AreEqual(AzureLocation.WestUS2.ToString(), bastionHost.Data.Location); Assert.AreEqual(0, bastionHost.Data.Tags.Count); }
public async Task TestTearDown() { if (_resourceGroup.GetBastionHosts().CheckIfExists(_bastionName)) { BastionHost bastion = await _resourceGroup.GetBastionHosts().GetAsync(_bastionName); await bastion.DeleteAsync(); } }
public async Task Delete() { BastionHost bastionHost = await CreateBastionHost(_bastionName); await bastionHost.DeleteAsync(WaitUntil.Completed); List <BastionHost> bastionList = await _resourceGroup.GetBastionHosts().GetAllAsync().ToEnumerableAsync(); Assert.IsEmpty(bastionList); }
public async Task Get() { BastionHost bastionHost = await CreateBastionHost(_bastionName); var bastion = await _resourceGroup.GetBastionHosts().GetAsync(_bastionName); Assert.IsNotNull(bastion.Value.Data); Assert.AreEqual(_bastionName, bastion.Value.Data.Name); Assert.AreEqual(AzureLocation.WestUS2.ToString(), bastion.Value.Data.Location); Assert.AreEqual(0, bastion.Value.Data.Tags.Count); }
async Task <BastionHost> CreateInternal(Region region, string resourceGroupName, string bastionName, string subnetId, Dictionary <string, string> tags, CancellationToken cancellationToken = default) { var publicIpName = AzureResourceNameUtil.BastionPublicIp(bastionName); var pip = await _azure.PublicIPAddresses.Define(publicIpName) .WithRegion(region) .WithExistingResourceGroup(resourceGroupName) .WithStaticIP() .WithSku(PublicIPSkuType.Standard) .WithTags(tags) .CreateAsync(cancellationToken); using (var client = new Microsoft.Azure.Management.Network.NetworkManagementClient(_credentials)) { client.SubscriptionId = _subscriptionId; var ipConfigs = new List <BastionHostIPConfiguration> { new BastionHostIPConfiguration() { Name = $"{bastionName}-ip-config", Subnet = new SubResource(subnetId), PrivateIPAllocationMethod = "Dynamic", PublicIPAddress = new SubResource(pip.Inner.Id), } }; var bastion = new BastionHost() { Location = region.Name, IpConfigurations = ipConfigs, Tags = tags }; var createdBastion = await client.BastionHosts.CreateOrUpdateAsync(resourceGroupName, bastionName, bastion, cancellationToken); return(createdBastion); } }
public virtual BastionHostsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string bastionHostName, BastionHost parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (bastionHostName == null) { throw new ArgumentNullException(nameof(bastionHostName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("BastionHostsOperations.StartCreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, bastionHostName, parameters, cancellationToken); return(new BastionHostsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, bastionHostName, parameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Creates or updates the specified Bastion Host. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='bastionHostName'> /// The name of the Bastion Host. /// </param> /// <param name='parameters'> /// Parameters supplied to the create or update Bastion Host operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <BastionHost> BeginCreateOrUpdateAsync(this IBastionHostsOperations operations, string resourceGroupName, string bastionHostName, BastionHost parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, bastionHostName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates the specified Bastion Host. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='bastionHostName'> /// The name of the Bastion Host. /// </param> /// <param name='parameters'> /// Parameters supplied to the create or update Bastion Host operation. /// </param> public static BastionHost BeginCreateOrUpdate(this IBastionHostsOperations operations, string resourceGroupName, string bastionHostName, BastionHost parameters) { return(operations.BeginCreateOrUpdateAsync(resourceGroupName, bastionHostName, parameters).GetAwaiter().GetResult()); }