/// <summary> /// Deletes an existing element from the collection. /// </summary> /// <typeparam name="TElementEndpoint">The type of <see cref="IEndpoint"/> to provide for individual entities.</typeparam> /// <param name="endpoint">The collection endpoint containing the element.</param> /// <param name="id">The ID identifying the entity in the collection.</param> /// <param name="cancellationToken">Used to cancel the request.</param> /// <exception cref="InvalidDataException"><see cref="HttpStatusCode.BadRequest"/></exception> /// <exception cref="AuthenticationException"><see cref="HttpStatusCode.Unauthorized"/></exception> /// <exception cref="UnauthorizedAccessException"><see cref="HttpStatusCode.Forbidden"/></exception> /// <exception cref="KeyNotFoundException"><see cref="HttpStatusCode.NotFound"/> or <see cref="HttpStatusCode.Gone"/></exception> /// <exception cref="InvalidOperationException"><see cref="HttpStatusCode.Conflict"/></exception> /// <exception cref="HttpRequestException">Other non-success status code.</exception> /// <remarks>This is a convenience method equivalent to combining <see cref="IIndexerEndpoint{TElementEndpoint}.this[string]"/> with <see cref="IElementEndpoint.DeleteAsync"/>.</remarks> public static Task DeleteAsync <TElementEndpoint>(this IIndexerEndpoint <TElementEndpoint> endpoint, string id, CancellationToken cancellationToken = default) where TElementEndpoint : class, IElementEndpoint => endpoint[id].DeleteAsync(cancellationToken);
/// <summary> /// Determines whether the collection contains a specific element. /// </summary> /// <typeparam name="TElementEndpoint">The type of <see cref="IEndpoint"/> to provide for individual entity.</typeparam> /// <param name="endpoint">The collection endpoint containing the element.</param> /// <param name="id">The ID identifying the entity in the collection.</param> /// <param name="cancellationToken">Used to cancel the request.</param> /// <exception cref="AuthenticationException"><see cref="HttpStatusCode.Unauthorized"/></exception> /// <exception cref="UnauthorizedAccessException"><see cref="HttpStatusCode.Forbidden"/></exception> /// <exception cref="HttpRequestException">Other non-success status code.</exception> /// <remarks>This is a convenience method equivalent to combining <see cref="IIndexerEndpoint{TElementEndpoint}.this[string]"/> with <see cref="IElementEndpoint.ExistsAsync"/>.</remarks> public static Task <bool> ContainsAsync <TElementEndpoint>(this IIndexerEndpoint <TElementEndpoint> endpoint, string id, CancellationToken cancellationToken = default) where TElementEndpoint : class, IElementEndpoint => endpoint[id].ExistsAsync(cancellationToken);