|
| 1 | +using NETCore.Keycloak.Client.Exceptions; |
| 2 | +using NETCore.Keycloak.Client.Models; |
| 3 | +using NETCore.Keycloak.Client.Models.Organizations; |
| 4 | + |
| 5 | +namespace NETCore.Keycloak.Client.HttpClients.Abstraction; |
| 6 | + |
| 7 | +/// <summary> |
| 8 | +/// Keycloak organizations REST client. |
| 9 | +/// <see href="https://www.keycloak.org/docs-api/latest/rest-api/index.html#_organizations"/> |
| 10 | +/// </summary> |
| 11 | +public interface IKcOrganizations |
| 12 | +{ |
| 13 | + /// <summary> |
| 14 | + /// Creates a new organization in a specified Keycloak realm. |
| 15 | + /// |
| 16 | + /// POST /{realm}/organizations |
| 17 | + /// </summary> |
| 18 | + /// <param name="realm">The Keycloak realm where the organization will be created.</param> |
| 19 | + /// <param name="accessToken">The access token used for authentication.</param> |
| 20 | + /// <param name="organization">The organization representation to create.</param> |
| 21 | + /// <param name="cancellationToken">Optional cancellation token.</param> |
| 22 | + /// <returns> |
| 23 | + /// A <see cref="KcResponse{T}"/> indicating the result of the operation. |
| 24 | + /// </returns> |
| 25 | + /// <exception cref="KcException">Thrown if any required parameter is null, empty, or invalid.</exception> |
| 26 | + Task<KcResponse<object>> CreateAsync( |
| 27 | + string realm, |
| 28 | + string accessToken, |
| 29 | + KcOrganization organization, |
| 30 | + CancellationToken cancellationToken = default); |
| 31 | + |
| 32 | + /// <summary> |
| 33 | + /// Updates an existing organization in a specified Keycloak realm. |
| 34 | + /// |
| 35 | + /// PUT /{realm}/organizations/{organizationId} |
| 36 | + /// </summary> |
| 37 | + /// <param name="realm">The Keycloak realm where the organization exists.</param> |
| 38 | + /// <param name="accessToken">The access token used for authentication.</param> |
| 39 | + /// <param name="organizationId">The ID of the organization to update.</param> |
| 40 | + /// <param name="organization">The updated organization representation.</param> |
| 41 | + /// <param name="cancellationToken">Optional cancellation token.</param> |
| 42 | + /// <returns> |
| 43 | + /// A <see cref="KcResponse{T}"/> indicating the result of the operation. |
| 44 | + /// </returns> |
| 45 | + /// <exception cref="KcException">Thrown if any required parameter is null, empty, or invalid.</exception> |
| 46 | + Task<KcResponse<object>> UpdateAsync( |
| 47 | + string realm, |
| 48 | + string accessToken, |
| 49 | + string organizationId, |
| 50 | + KcOrganization organization, |
| 51 | + CancellationToken cancellationToken = default); |
| 52 | + |
| 53 | + /// <summary> |
| 54 | + /// Deletes an organization from a specified Keycloak realm. |
| 55 | + /// |
| 56 | + /// DELETE /{realm}/organizations/{organizationId} |
| 57 | + /// </summary> |
| 58 | + /// <param name="realm">The Keycloak realm where the organization exists.</param> |
| 59 | + /// <param name="accessToken">The access token used for authentication.</param> |
| 60 | + /// <param name="organizationId">The ID of the organization to delete.</param> |
| 61 | + /// <param name="cancellationToken">Optional cancellation token.</param> |
| 62 | + /// <returns> |
| 63 | + /// A <see cref="KcResponse{T}"/> indicating the result of the operation. |
| 64 | + /// </returns> |
| 65 | + /// <exception cref="KcException">Thrown if any required parameter is null, empty, or invalid.</exception> |
| 66 | + Task<KcResponse<object>> DeleteAsync( |
| 67 | + string realm, |
| 68 | + string accessToken, |
| 69 | + string organizationId, |
| 70 | + CancellationToken cancellationToken = default); |
| 71 | + |
| 72 | + /// <summary> |
| 73 | + /// Retrieves a specific organization by its ID from a specified Keycloak realm. |
| 74 | + /// |
| 75 | + /// GET /{realm}/organizations/{organizationId} |
| 76 | + /// </summary> |
| 77 | + /// <param name="realm">The Keycloak realm to query.</param> |
| 78 | + /// <param name="accessToken">The access token used for authentication.</param> |
| 79 | + /// <param name="organizationId">The ID of the organization to retrieve.</param> |
| 80 | + /// <param name="cancellationToken">Optional cancellation token.</param> |
| 81 | + /// <returns> |
| 82 | + /// A <see cref="KcResponse{T}"/> containing the <see cref="KcOrganization"/> details. |
| 83 | + /// </returns> |
| 84 | + /// <exception cref="KcException">Thrown if any required parameter is null, empty, or invalid.</exception> |
| 85 | + Task<KcResponse<KcOrganization>> GetAsync( |
| 86 | + string realm, |
| 87 | + string accessToken, |
| 88 | + string organizationId, |
| 89 | + CancellationToken cancellationToken = default); |
| 90 | + |
| 91 | + /// <summary> |
| 92 | + /// Retrieves a list of organizations from a specified Keycloak realm, optionally filtered by criteria. |
| 93 | + /// |
| 94 | + /// GET /{realm}/organizations |
| 95 | + /// </summary> |
| 96 | + /// <param name="realm">The Keycloak realm from which organizations will be listed.</param> |
| 97 | + /// <param name="accessToken">The access token used for authentication.</param> |
| 98 | + /// <param name="filter">Optional filter criteria.</param> |
| 99 | + /// <param name="cancellationToken">Optional cancellation token.</param> |
| 100 | + /// <returns> |
| 101 | + /// A <see cref="KcResponse{T}"/> containing an enumerable of <see cref="KcOrganization"/> objects. |
| 102 | + /// </returns> |
| 103 | + /// <exception cref="KcException">Thrown if any required parameter is null, empty, or invalid.</exception> |
| 104 | + Task<KcResponse<IEnumerable<KcOrganization>>> ListAsync( |
| 105 | + string realm, |
| 106 | + string accessToken, |
| 107 | + KcOrganizationFilter filter = null, |
| 108 | + CancellationToken cancellationToken = default); |
| 109 | + |
| 110 | + /// <summary> |
| 111 | + /// Retrieves the count of organizations in a specified Keycloak realm, optionally filtered. |
| 112 | + /// |
| 113 | + /// GET /{realm}/organizations/count |
| 114 | + /// </summary> |
| 115 | + /// <param name="realm">The Keycloak realm to query.</param> |
| 116 | + /// <param name="accessToken">The access token used for authentication.</param> |
| 117 | + /// <param name="filter">Optional filter criteria.</param> |
| 118 | + /// <param name="cancellationToken">Optional cancellation token.</param> |
| 119 | + /// <returns> |
| 120 | + /// A <see cref="KcResponse{T}"/> with the count of organizations. |
| 121 | + /// </returns> |
| 122 | + /// <exception cref="KcException">Thrown if any required parameter is null, empty, or invalid.</exception> |
| 123 | + Task<KcResponse<long>> CountAsync( |
| 124 | + string realm, |
| 125 | + string accessToken, |
| 126 | + KcOrganizationFilter filter = null, |
| 127 | + CancellationToken cancellationToken = default); |
| 128 | +} |
0 commit comments