/// <summary> /// Request deletion of the specified CustomResourceDefinition. /// </summary> /// <param name="name"> /// The name of the CustomResourceDefinition to delete. /// </param> /// <param name="propagationPolicy"> /// A <see cref="DeletePropagationPolicy"/> indicating how child resources should be deleted (if at all). /// </param> /// <param name="cancellationToken"> /// An optional <see cref="CancellationToken"/> that can be used to cancel the request. /// </param> /// <returns> /// A <see cref="CustomResourceDefinitionV1Beta1"/> representing the job's most recent state before it was deleted, if <paramref name="propagationPolicy"/> is <see cref="DeletePropagationPolicy.Foreground"/>; otherwise, a <see cref="StatusV1"/>. /// </returns> public async Task <KubeObjectV1> Delete(string name, DeletePropagationPolicy propagationPolicy = DeletePropagationPolicy.Background, CancellationToken cancellationToken = default) { var request = Http.DeleteAsJsonAsync( Requests.ByName.WithTemplateParameters(new { Name = name }), deleteBody: new DeleteOptionsV1 { PropagationPolicy = propagationPolicy }, cancellationToken: cancellationToken ); if (propagationPolicy == DeletePropagationPolicy.Foreground) { return(await request.ReadContentAsObjectV1Async <CustomResourceDefinitionV1Beta1>(HttpStatusCode.OK)); } return(await request.ReadContentAsObjectV1Async <StatusV1>(HttpStatusCode.OK, HttpStatusCode.NotFound)); }
/// <summary> /// Request deletion of the specified PersistentVolumeClaim. /// </summary> /// <param name="name"> /// The name of the PersistentVolumeClaim to delete. /// </param> /// <param name="kubeNamespace"> /// The target Kubernetes namespace (defaults to <see cref="KubeApiClient.DefaultNamespace"/>). /// </param> /// <param name="propagationPolicy"> /// A <see cref="DeletePropagationPolicy"/> value indicating how (or if) dependent resources should be deleted. /// </param> /// <param name="cancellationToken"> /// An optional <see cref="CancellationToken"/> that can be used to cancel the request. /// </param> /// <returns> /// A <see cref="PersistentVolumeClaimV1"/> representing the persistent volume claim's most recent state before it was deleted, if <paramref name="propagationPolicy"/> is <see cref="DeletePropagationPolicy.Foreground"/>; otherwise, a <see cref="StatusV1"/>. /// </returns> public async Task <KubeObjectV1> Delete(string name, string kubeNamespace = null, DeletePropagationPolicy propagationPolicy = DeletePropagationPolicy.Background, CancellationToken cancellationToken = default) { var request = Http.DeleteAsJsonAsync( Requests.ByName.WithTemplateParameters(new { Name = name, Namespace = kubeNamespace ?? KubeClient.DefaultNamespace }), deleteBody: new DeleteOptionsV1 { PropagationPolicy = propagationPolicy }, cancellationToken: cancellationToken ); if (propagationPolicy == DeletePropagationPolicy.Foreground) { return(await request.ReadContentAsObjectV1Async <PersistentVolumeClaimV1>(HttpStatusCode.OK)); } return(await request.ReadContentAsObjectV1Async <StatusV1>(HttpStatusCode.OK, HttpStatusCode.NotFound)); }
/// <summary> /// Request deletion of the specified ReplicationController. /// </summary> /// <param name="name"> /// The name of the ReplicationController to delete. /// </param> /// <param name="kubeNamespace"> /// The target Kubernetes namespace (defaults to <see cref="KubeApiClient.DefaultNamespace"/>). /// </param> /// <param name="propagationPolicy"> /// A <see cref="DeletePropagationPolicy"/> indicating how child resources should be deleted (if at all). /// </param> /// <param name="cancellationToken"> /// An optional <see cref="CancellationToken"/> that can be used to cancel the request. /// </param> /// <returns> /// An <see cref="StatusV1"/> indicating the result of the request. /// </returns> public async Task <StatusV1> Delete(string name, string kubeNamespace = null, DeletePropagationPolicy propagationPolicy = DeletePropagationPolicy.Background, CancellationToken cancellationToken = default) { return (await Http.DeleteAsJsonAsync( Requests.ByName.WithTemplateParameters(new { Name = name, Namespace = kubeNamespace ?? Client.DefaultNamespace }), deleteBody : new { apiVersion = "v1", kind = "DeleteOptions", propagationPolicy = propagationPolicy }, cancellationToken : cancellationToken ) .ReadContentAsAsync <StatusV1, StatusV1>(HttpStatusCode.OK, HttpStatusCode.NotFound)); }