async Task <VolumeResponse> IVolumeOperations.CreateAsync(VolumesCreateParameters parameters, CancellationToken cancellationToken)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var data     = new JsonRequestContent <VolumesCreateParameters>(parameters, this._client.JsonSerializer);
            var response = await this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Post, "volumes/create", null, data, cancellationToken);

            return(this._client.JsonSerializer.DeserializeObject <VolumeResponse>(response.Body));
        }
Пример #2
0
        public async Task <VolumeResponse> CreateVolumeAsync(VolumesCreateParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var data     = new JsonRequestContent <VolumesCreateParameters>(parameters, this._client.JsonSerializer);
            var response = await this._client.MakeRequestAsync(this._client.NoErrorHandlers, HttpMethod.Post, "volumes/create", null, data).ConfigureAwait(false);

            return(this._client.JsonSerializer.DeserializeObject <VolumeResponse>(response.Body));
        }
        public async Task <string> CreateAsync(ITestcontainersVolumeConfiguration configuration, CancellationToken ct = default)
        {
            var createParameters = new VolumesCreateParameters
            {
                Name   = configuration.Name,
                Labels = configuration.Labels.ToDictionary(item => item.Key, item => item.Value),
            };

            var name = (await this.Docker.Volumes.CreateAsync(createParameters, ct)
                        .ConfigureAwait(false)).Name;

            this.logger.DockerVolumeCreated(name);

            return(name);
        }