Table of Contents

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 HttpClient

The 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 string

Realm name (not ID).

resourceId string

The resource ID to create the policy for.

policy Policy

Policy 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 string

Realm name (not ID).

resource Resource
cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

DeletePolicyWithResponseAsync(string, string, CancellationToken)

Deletes a policy

public Task<HttpResponseMessage> DeletePolicyWithResponseAsync(string realm, string policyId, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

policyId string

Policy ID.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

Remarks

DeleteResourceWithResponseAsync(string, string, CancellationToken)

Deletes a resource

public Task<HttpResponseMessage> DeleteResourceWithResponseAsync(string realm, string resourceId, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

resourceId string

Resource ID.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

GetPoliciesWithResponseAsync(string, GetPoliciesRequestParameters?, CancellationToken)

Gets all Policies

public Task<HttpResponseMessage> GetPoliciesWithResponseAsync(string realm, GetPoliciesRequestParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

parameters GetPoliciesRequestParameters
cancellationToken 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 string

Realm name (not ID).

policyId string

Policy 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 string

Realm name (not ID).

resourceId string

Resource ID.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

GetResourcesIdsWithResponseAsync(string, GetResourcesRequestParameters?, CancellationToken)

Searches for resource

public Task<HttpResponseMessage> GetResourcesIdsWithResponseAsync(string realm, GetResourcesRequestParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

parameters GetResourcesRequestParameters

Optional query parameters

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

GetResourcesWithResponseAsync(string, GetResourcesRequestParameters?, CancellationToken)

Searches for resources

public Task<HttpResponseMessage> GetResourcesWithResponseAsync(string realm, GetResourcesRequestParameters? parameters = null, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

parameters GetResourcesRequestParameters

Optional query parameters

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

UpdatePolicyWithResponseAsync(string, string, Policy, CancellationToken)

Updates a policy

public Task<HttpResponseMessage> UpdatePolicyWithResponseAsync(string realm, string policyId, Policy policy, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

policyId string

Policy ID.

policy Policy

Policy object.

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

Remarks

UpdateResourceWithResponseAsync(string, string, Resource, CancellationToken)

Updates resource

public Task<HttpResponseMessage> UpdateResourceWithResponseAsync(string realm, string resourceId, Resource resource, CancellationToken cancellationToken = default)

Parameters

realm string

Realm name (not ID).

resourceId string

Resource ID.

resource Resource
cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>

Remarks