예제 #1
0
        /// <summary>
        ///     Request creation of a <see cref="PersistentVolumeV1"/>.
        /// </summary>
        /// <param name="newPersistentVolume">
        ///     A <see cref="PersistentVolumeV1"/> representing the PersistentVolume to create.
        /// </param>
        /// <param name="cancellationToken">
        ///     An optional <see cref="CancellationToken"/> that can be used to cancel the request.
        /// </param>
        /// <returns>
        ///     A <see cref="PersistentVolumeV1"/> representing the current state for the newly-created PersistentVolume.
        /// </returns>
        public async Task <PersistentVolumeV1> Create(PersistentVolumeV1 newPersistentVolume, CancellationToken cancellationToken = default)
        {
            if (newPersistentVolume == null)
            {
                throw new ArgumentNullException(nameof(newPersistentVolume));
            }

            return(await Http
                   .PostAsJsonAsync(
                       Requests.Collection,
                       postBody : newPersistentVolume,
                       cancellationToken : cancellationToken
                       )
                   .ReadContentAsObjectV1Async <PersistentVolumeV1>("create v1/PersistentVolume resource"));
        }
예제 #2
0
        /// <summary>
        ///     Request creation of a <see cref="PersistentVolume"/>.
        /// </summary>
        /// <param name="newPersistentVolume">
        ///     A <see cref="PersistentVolumeV1"/> representing the PersistentVolume to create.
        /// </param>
        /// <param name="cancellationToken">
        ///     An optional <see cref="CancellationToken"/> that can be used to cancel the request.
        /// </param>
        /// <returns>
        ///     A <see cref="PersistentVolumeV1"/> representing the current state for the newly-created PersistentVolume.
        /// </returns>
        public async Task <PersistentVolumeV1> Create(PersistentVolumeV1 newPersistentVolume, CancellationToken cancellationToken = default)
        {
            if (newPersistentVolume == null)
            {
                throw new ArgumentNullException(nameof(newPersistentVolume));
            }

            return(await Http
                   .PostAsJsonAsync(
                       Requests.Collection.WithTemplateParameters(new
            {
                Namespace = newPersistentVolume?.Metadata?.Namespace ?? Client.DefaultNamespace
            }),
                       postBody : newPersistentVolume,
                       cancellationToken : cancellationToken
                       )
                   .ReadContentAsAsync <PersistentVolumeV1, StatusV1>());
        }