Exemplo n.º 1
0
        /// <inheritdoc cref="ComputeApi.UpdateServerAsync{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 ServerUpdateDefinition();

            this.CopyProperties(request);

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

            result.CopyProperties(this);
        }
Exemplo n.º 2
0
        public void UpdateServer()
        {
            using (var httpTest = new HttpTest())
            {
                Identifier serverId = Guid.NewGuid();
                httpTest.RespondWithJson(new Server {
                    Id = serverId, Name = "{new-name}"
                });

                var request = new ServerUpdateDefinition {
                    Name = "{new-name}"
                };
                var result = _compute.UpdateServer(serverId, request);

                httpTest.ShouldHaveCalled($"*/servers/{serverId}");
                Assert.NotNull(result);
                Assert.Equal(serverId, result.Id);
                Assert.Equal(request.Name, result.Name);
                Assert.IsType <ComputeApi>(((IServiceResource)result).Owner);
            }
        }
Exemplo n.º 3
0
 /// <inheritdoc cref="ComputeApi.UpdateServerAsync{T}" />
 public Task <Server> UpdateServerAsync(Identifier serverid, ServerUpdateDefinition server, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(_computeApi.UpdateServerAsync <Server>(serverid, server, cancellationToken));
 }
Exemplo n.º 4
0
        public void UpdateServer()
        {
            using (var httpTest = new HttpTest())
            {
                Identifier serverId = Guid.NewGuid();
                httpTest.RespondWithJson(new Server { Id = serverId, Name = "{new-name}"});

                var request = new ServerUpdateDefinition {Name = "{new-name}"};
                var result = _compute.UpdateServer(serverId, request);

                httpTest.ShouldHaveCalled($"*/servers/{serverId}");
                Assert.NotNull(result);
                Assert.Equal(serverId, result.Id);
                Assert.Equal(request.Name, result.Name);
                Assert.IsType<ComputeApi>(((IServiceResource)result).Owner);
            }
        }
 /// <inheritdoc cref="ComputeService.UpdateServerAsync" />
 public static Server UpdateServer(this ComputeService service, Identifier serverid, ServerUpdateDefinition server)
 {
     return service.UpdateServerAsync(serverid, server).ForceSynchronous();
 }
Exemplo n.º 6
0
        /// <inheritdoc cref="ComputeApi.UpdateServerAsync{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 ServerUpdateDefinition();
            this.CopyProperties(request);

            var result = await compute.UpdateServerAsync<Server>(Id, request, cancellationToken).ConfigureAwait(false);
            result.CopyProperties(this);
        }