Beispiel #1
0
        public async Task <SecurityGroup> CreateSecurityGroup(SecurityGroupDefinition definition)
        {
            var securityGroup = await _compute.CreateSecurityGroupAsync(definition);

            Register(securityGroup);
            return(securityGroup);
        }
Beispiel #2
0
        /// <inheritdoc cref="ComputeApi.UpdateSecurityGroupAsync{T}" />
        /// <exception cref="InvalidOperationException">When the <see cref="Server"/> instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
        public async Task UpdateAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            var compute = this.GetOwnerOrThrow <ComputeApi>();
            var request = new SecurityGroupDefinition(Name, Description);

            var result = await compute.UpdateSecurityGroupAsync <SecurityGroup>(Id, request, cancellationToken).ConfigureAwait(false);

            result.CopyProperties(this);
        }
Beispiel #3
0
        public void CreateSecurityGroup()
        {
            using (var httpTest = new HttpTest())
            {
                Identifier securityGroupId = Guid.NewGuid();
                httpTest.RespondWithJson(new SecurityGroup {
                    Id = securityGroupId
                });

                var request = new SecurityGroupDefinition("{name}", "{description}");
                var result  = _compute.CreateSecurityGroup(request);

                httpTest.ShouldHaveCalled("*/os-security-groups");
                Assert.Equal(securityGroupId, result.Id);
                Assert.IsType <ComputeApi>(((IServiceResource)result).Owner);
            }
        }
 /// <inheritdoc cref="ComputeApi.UpdateSecurityGroupAsync{T}" />
 public Task <SecurityGroup> UpdateSecurityGroupAsync(Identifier securityGroupId, SecurityGroupDefinition securityGroup, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(_computeApi.UpdateSecurityGroupAsync <SecurityGroup>(securityGroupId, securityGroup, cancellationToken));
 }
 /// <inheritdoc cref="ComputeApi.CreateSecurityGroupAsync{T}" />
 public Task <SecurityGroup> CreateSecurityGroupAsync(SecurityGroupDefinition securityGroup, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(_computeApi.CreateSecurityGroupAsync <SecurityGroup>(securityGroup, cancellationToken));
 }
 public async Task<SecurityGroup> CreateSecurityGroup(SecurityGroupDefinition definition)
 {
     var securityGroup = await _compute.CreateSecurityGroupAsync(definition);
     Register(securityGroup);
     return securityGroup;
 }
 /// <inheritdoc cref="ComputeService.UpdateSecurityGroupAsync" />
 public static SecurityGroup UpdateSecurityGroup(this ComputeService service, Identifier securityGroupid, SecurityGroupDefinition securityGroup)
 {
     return service.UpdateSecurityGroupAsync(securityGroupid, securityGroup).ForceSynchronous();
 }
 /// <inheritdoc cref="ComputeService.CreateSecurityGroupAsync" />
 public static SecurityGroup CreateSecurityGroup(this ComputeService service, SecurityGroupDefinition securityGroup)
 {
     return service.CreateSecurityGroupAsync(securityGroup).ForceSynchronous();
 }