Class AccountAccessRulesApi
- Namespace
- Cloudflare.NET.Accounts.AccessRules
- Assembly
- Cloudflare.NET.dll
Implements the API for managing IP Access Rules at the account level.
public class AccountAccessRulesApi : ApiResource, IAccountAccessRulesApi
- Inheritance
-
AccountAccessRulesApi
- Implements
- Inherited Members
Constructors
AccountAccessRulesApi(HttpClient, IOptions<CloudflareApiOptions>, ILoggerFactory)
Implements the API for managing IP Access Rules at the account level.
public AccountAccessRulesApi(HttpClient httpClient, IOptions<CloudflareApiOptions> options, ILoggerFactory loggerFactory)
Parameters
httpClientHttpClientoptionsIOptions<CloudflareApiOptions>loggerFactoryILoggerFactory
Methods
CreateAsync(CreateAccessRuleRequest, CancellationToken)
Creates a new IP Access Rule for the account.
public Task<AccessRule> CreateAsync(CreateAccessRuleRequest request, CancellationToken cancellationToken = default)
Parameters
requestCreateAccessRuleRequestThe request containing the details of the rule to create.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<AccessRule>
The created access rule.
DeleteAsync(string, CancellationToken)
Deletes an IP Access Rule from the account.
public Task DeleteAsync(string ruleId, CancellationToken cancellationToken = default)
Parameters
ruleIdstringThe ID of the rule to delete.
cancellationTokenCancellationTokenA cancellation token.
Returns
GetAsync(string, CancellationToken)
Gets a single IP Access Rule for the account by its ID.
public Task<AccessRule> GetAsync(string ruleId, CancellationToken cancellationToken = default)
Parameters
ruleIdstringThe ID of the rule to retrieve.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<AccessRule>
The requested access rule.
ListAllAsync(ListAccessRulesFilters?, CancellationToken)
Lists all IP Access Rules for the account, automatically handling pagination.
public IAsyncEnumerable<AccessRule> ListAllAsync(ListAccessRulesFilters? filters = null, CancellationToken cancellationToken = default)
Parameters
filtersListAccessRulesFiltersOptional filters to apply to the list operation. Pagination parameters (Page, PerPage) will be ignored.
cancellationTokenCancellationTokenA cancellation token.
Returns
- IAsyncEnumerable<AccessRule>
An asynchronous stream of all access rules matching the criteria.
ListAsync(ListAccessRulesFilters?, CancellationToken)
Lists all IP Access Rules for the account, allowing for manual pagination control.
public Task<PagePaginatedResult<AccessRule>> ListAsync(ListAccessRulesFilters? filters = null, CancellationToken cancellationToken = default)
Parameters
filtersListAccessRulesFiltersOptional filters to apply to the list operation, such as filtering by mode or IP, and specifying the page number.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<PagePaginatedResult<AccessRule>>
A single page of access rules 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, UpdateAccessRuleRequest, CancellationToken)
Updates an existing IP Access Rule for the account.
public Task<AccessRule> UpdateAsync(string ruleId, UpdateAccessRuleRequest request, CancellationToken cancellationToken = default)
Parameters
ruleIdstringThe ID of the rule to update.
requestUpdateAccessRuleRequestThe request containing the fields to update (e.g., changing the notes or mode).
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<AccessRule>
The updated access rule.