Class KeycloakProtectionClient
- Namespace
- Keycloak.AuthServices.Sdk.Protection
- Assembly
- Keycloak.AuthServices.Sdk.dll
Represents a client for interacting with Keycloak Protection API services.
public class KeycloakProtectionClient : IKeycloakProtectionClient, IKeycloakProtectedResourceClient, IKeycloakPolicyClient
- Inheritance
-
KeycloakProtectionClient
- Implements
- Inherited Members
Constructors
KeycloakProtectionClient(HttpClient)
Initializes a new instance of the KeycloakProtectionClient class.
public KeycloakProtectionClient(HttpClient httpClient)
Parameters
httpClient
HttpClientThe HTTP client used for making requests.
Methods
CreatePolicyWithResponseAsync(string, string, Policy, CancellationToken)
Creates a policy
public Task<HttpResponseMessage> CreatePolicyWithResponseAsync(string realm, string resourceId, Policy policy, CancellationToken cancellationToken)
Parameters
realm
stringRealm name (not ID).
resourceId
stringThe resource ID to create the policy for.
policy
PolicyPolicy representation
cancellationToken
CancellationToken
Returns
- Task<HttpResponseMessage>
The HttpResponseMessage of the request
CreateResourceWithResponseAsync(string, Resource, CancellationToken)
Creates resource
public Task<HttpResponseMessage> CreateResourceWithResponseAsync(string realm, Resource resource, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
resource
ResourcecancellationToken
CancellationToken
Returns
DeletePolicyWithResponseAsync(string, string, CancellationToken)
Deletes a policy
public Task<HttpResponseMessage> DeletePolicyWithResponseAsync(string realm, string policyId, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
policyId
stringPolicy ID.
cancellationToken
CancellationToken
Returns
Remarks
DeleteResourceWithResponseAsync(string, string, CancellationToken)
Deletes a resource
public Task<HttpResponseMessage> DeleteResourceWithResponseAsync(string realm, string resourceId, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
resourceId
stringResource ID.
cancellationToken
CancellationToken
Returns
GetPoliciesWithResponseAsync(string, GetPoliciesRequestParameters?, CancellationToken)
Gets all Policies
public Task<HttpResponseMessage> GetPoliciesWithResponseAsync(string realm, GetPoliciesRequestParameters? parameters = null, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
parameters
GetPoliciesRequestParameterscancellationToken
CancellationToken
Returns
- Task<HttpResponseMessage>
The HttpResponseMessage of the request
Remarks
GetPolicyWithResponseAsync(string, string, CancellationToken)
Gets a Policy
public Task<HttpResponseMessage> GetPolicyWithResponseAsync(string realm, string policyId, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
policyId
stringPolicy ID
cancellationToken
CancellationToken
Returns
- Task<HttpResponseMessage>
The HttpResponseMessage of the request
GetResourceWithResponseAsync(string, string, CancellationToken)
Gets resource by Id
public Task<HttpResponseMessage> GetResourceWithResponseAsync(string realm, string resourceId, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
resourceId
stringResource ID.
cancellationToken
CancellationToken
Returns
GetResourcesIdsWithResponseAsync(string, GetResourcesRequestParameters?, CancellationToken)
Searches for resource
public Task<HttpResponseMessage> GetResourcesIdsWithResponseAsync(string realm, GetResourcesRequestParameters? parameters = null, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
parameters
GetResourcesRequestParametersOptional query parameters
cancellationToken
CancellationToken
Returns
GetResourcesWithResponseAsync(string, GetResourcesRequestParameters?, CancellationToken)
Searches for resources
public Task<HttpResponseMessage> GetResourcesWithResponseAsync(string realm, GetResourcesRequestParameters? parameters = null, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
parameters
GetResourcesRequestParametersOptional query parameters
cancellationToken
CancellationToken
Returns
UpdatePolicyWithResponseAsync(string, string, Policy, CancellationToken)
Updates a policy
public Task<HttpResponseMessage> UpdatePolicyWithResponseAsync(string realm, string policyId, Policy policy, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
policyId
stringPolicy ID.
policy
PolicyPolicy object.
cancellationToken
CancellationToken
Returns
Remarks
UpdateResourceWithResponseAsync(string, string, Resource, CancellationToken)
Updates resource
public Task<HttpResponseMessage> UpdateResourceWithResponseAsync(string realm, string resourceId, Resource resource, CancellationToken cancellationToken = default)
Parameters
realm
stringRealm name (not ID).
resourceId
stringResource ID.
resource
ResourcecancellationToken
CancellationToken