System.Data.RiakClient.RiakManagementRepository.GetServerInformation C# (CSharp) Method

GetServerInformation() public method

public GetServerInformation ( ) : RiakResponse
return RiakResponse
        public RiakResponse<ServerInfo> GetServerInformation()
        {
            var r = Connection.WriteRequestWithoutBody(new byte[] { }, RequestMethod.ServerInfo);

            return r.ResponseCode == RiakResponseCode.Failed
                ? RiakResponse<ServerInfo>.WithErrors(r.Messages)
                : RiakResponse<ServerInfo>.ReadResponse(() => {
                    var response = Connection.Read<GetServerInformationResponse>();
                    return response.ResponseCode == RiakResponseCode.Failed
                               ? RiakResponse<ServerInfo>.WithErrors(r.Messages)
                               : RiakResponse<ServerInfo>.WithoutErrors(new ServerInfo {
                                    Node = response.Result.Node.DecodeToString(),
                                    ServerVersion = response.Result.ServerVersion.DecodeToString()
                                });
                });
        }
    }

Usage Example

        public void ShouldGetServerInformation()
        {
            // Arrange.
            var connection = new RiakConnection { Host = "192.168.30.118", Port = 8087 };
            var repository = new RiakManagementRepository(connection);

            // Act.
            var response = repository.GetServerInformation();

            // Assert.
            Assert.IsTrue(response.ResponseCode == RiakResponseCode.Successful);
            Assert.IsNotNull(response.Result);
            Assert.IsNotNull(response.Result.Node);
            Assert.IsNotNull(response.Result.ServerVersion);
        }