Exemplo n.º 1
0
        async Task <string> ISwarmOperations.InitSwarmAsync(SwarmInitParameters parameters, CancellationToken cancellationToken)
        {
            var data     = new JsonRequestContent <SwarmInitParameters>(parameters ?? throw new ArgumentNullException(nameof(parameters)), this._client.JsonSerializer);
            var response = await this._client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Post, "swarm/init", null, data, cancellationToken).ConfigureAwait(false);

            return(response.Body);
        }
Exemplo n.º 2
0
        public async Task <String> createSwarmAsync(String advertiseAddr, String listenAddr)
        {
            SwarmInitParameters parameters = new SwarmInitParameters();

            parameters.AdvertiseAddr = advertiseAddr;
            parameters.ListenAddr    = listenAddr;
            CancellationToken cancellationToken = new CancellationToken();

            return(await this.client.Swarm.InitSwarmAsync(parameters, cancellationToken));
        }
Exemplo n.º 3
0
        async Task <string> ISwarmOperations.InitSwarmAsync(SwarmInitParameters parameters, CancellationToken cancellationToken)
        {
            var data     = new JsonRequestContent <SwarmInitParameters>(parameters ?? throw new ArgumentNullException(nameof(parameters)), this._client.JsonSerializer);
            var response = await this._client.MakeRequestAsync(
                new ApiResponseErrorHandlingDelegate[]
            {
                (statusCode, responseBody) =>
                {
                    if (statusCode == HttpStatusCode.NotAcceptable)
                    {
                        // TODO: Make typed error.
                        throw new Exception("Node is already part of a swarm.");
                    }
                }
            },
                HttpMethod.Post,
                "swarm/init",
                null,
                data,
                cancellationToken).ConfigureAwait(false);

            return(response.Body);
        }
Exemplo n.º 4
0
 public async Task <string> InitCluster(SwarmInitParameters initParameters)
 {
     return(await _client.Swarm.InitSwarmAsync(initParameters));
 }
Exemplo n.º 5
0
        public async Task <string> InitSwarm(SwarmInitParameters swarmPrm)
        {
            var result = await _client.Swarm.InitSwarmAsync(swarmPrm);

            return(result);
        }