Class CustomHostnamesApi
- Namespace
- Cloudflare.NET.Zones.CustomHostnames
- Assembly
- Cloudflare.NET.dll
Implements the API for managing Custom Hostnames (Cloudflare for SaaS) at the zone level.
public class CustomHostnamesApi : ApiResource, ICustomHostnamesApi
- Inheritance
-
CustomHostnamesApi
- Implements
- Inherited Members
Constructors
CustomHostnamesApi(HttpClient, ILoggerFactory)
Implements the API for managing Custom Hostnames (Cloudflare for SaaS) at the zone level.
public CustomHostnamesApi(HttpClient httpClient, ILoggerFactory loggerFactory)
Parameters
httpClientHttpClientloggerFactoryILoggerFactory
Methods
CreateAsync(string, CreateCustomHostnameRequest, CancellationToken)
Creates a new custom hostname for the specified zone.
public Task<CustomHostname> CreateAsync(string zoneId, CreateCustomHostnameRequest request, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
requestCreateCustomHostnameRequestThe request containing the custom hostname configuration.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<CustomHostname>
The created custom hostname with its initial status and SSL information.
DeleteAsync(string, string, CancellationToken)
Deletes a custom hostname and any associated SSL certificates.
public Task DeleteAsync(string zoneId, string customHostnameId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
customHostnameIdstringThe ID of the custom hostname to delete.
cancellationTokenCancellationTokenA cancellation token.
Returns
DeleteFallbackOriginAsync(string, CancellationToken)
Deletes the fallback origin configuration for the zone.
public Task DeleteFallbackOriginAsync(string zoneId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
cancellationTokenCancellationTokenA cancellation token.
Returns
GetAsync(string, string, CancellationToken)
Gets the details of a specific custom hostname.
public Task<CustomHostname> GetAsync(string zoneId, string customHostnameId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
customHostnameIdstringThe ID of the custom hostname to retrieve.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<CustomHostname>
The custom hostname details including current status and SSL information.
GetFallbackOriginAsync(string, CancellationToken)
Gets the fallback origin for custom hostnames in the zone.
public Task<FallbackOrigin> GetFallbackOriginAsync(string zoneId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<FallbackOrigin>
The fallback origin configuration.
Remarks
The fallback origin is the default origin server used when a custom hostname does not have a specific custom_origin_server configured.
ListAllAsync(string, ListCustomHostnamesFilters?, CancellationToken)
Lists all custom hostnames for the specified zone, automatically handling pagination.
public IAsyncEnumerable<CustomHostname> ListAllAsync(string zoneId, ListCustomHostnamesFilters? filters = null, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
filtersListCustomHostnamesFiltersOptional filters to apply. Pagination parameters (Page, PerPage) will be managed automatically.
cancellationTokenCancellationTokenA cancellation token.
Returns
- IAsyncEnumerable<CustomHostname>
An asynchronous stream of all custom hostnames matching the criteria.
ListAsync(string, ListCustomHostnamesFilters?, CancellationToken)
Lists custom hostnames for the specified zone, allowing for manual pagination control.
public Task<PagePaginatedResult<CustomHostname>> ListAsync(string zoneId, ListCustomHostnamesFilters? filters = null, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
filtersListCustomHostnamesFiltersOptional filters to apply, including pagination parameters.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<PagePaginatedResult<CustomHostname>>
A single page of custom hostnames along with pagination information.
Remarks
This method is intended for developers who need to control the pagination process manually. Use the properties of the returned PagePaginatedResult<T> to determine if there are more pages and to construct the filter for the next call.
UpdateAsync(string, string, UpdateCustomHostnameRequest, CancellationToken)
Updates an existing custom hostname.
public Task<CustomHostname> UpdateAsync(string zoneId, string customHostnameId, UpdateCustomHostnameRequest request, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
customHostnameIdstringThe ID of the custom hostname to update.
requestUpdateCustomHostnameRequestThe request containing the fields to update.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<CustomHostname>
The updated custom hostname.
Remarks
This is a PATCH operation. Only the properties set in the request will be updated. Sending a PATCH request can also be used to refresh the validation status.
UpdateFallbackOriginAsync(string, UpdateFallbackOriginRequest, CancellationToken)
Updates the fallback origin for custom hostnames in the zone.
public Task<FallbackOrigin> UpdateFallbackOriginAsync(string zoneId, UpdateFallbackOriginRequest request, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
requestUpdateFallbackOriginRequestThe request containing the new fallback origin.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<FallbackOrigin>
The updated fallback origin configuration.