https://github.com/mathieumack/ckan.netclient
Unoficial .net client for CKAN API
https://github.com/mathieumack/ckan.netclient
Last synced: about 2 months ago
JSON representation
Unoficial .net client for CKAN API
- Host: GitHub
- URL: https://github.com/mathieumack/ckan.netclient
- Owner: mathieumack
- License: mit
- Created: 2022-07-22T07:14:01.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-13T14:49:22.000Z (over 3 years ago)
- Last Synced: 2025-01-26T05:41:07.664Z (over 1 year ago)
- Language: C#
- Size: 43 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CKan.NetClient
This library let you to interact with a CKan server APIs with dedicated clients.
==========
# IC
[](https://sonarcloud.io/summary/new_code?id=mathieumack_CKan.NetClient)
[](https://github.com/mathieumack/CKan.NetClient/actions/workflows/ci.yml)
[](https://nuget.org/packages/CKan.NetClient.Unofficial)
# Onboarding Instructions
## Installation
1. Add nuget package:
> Install-Package CKan.NetClient.Unoficial
2. CI configuration. In your startup file, you must register an HttpClient by using the HttpClientFactory and next register the custom CKan client by calling the AddCKanClient method.
```c#
private void Register(this IServiceCollection services)
{
// Define the baseUri of your organization :
var baseUri = "https://sample.com/ckan";
// Register the HttpClientFactory :
services.AddHttpClient()
// Register the CKanClient object :
services.AddCKanClient(baseUri);
}
```
> If you have a named HttpClient, you can use it.
Ex : You can use it to mock Http calls :
```c#
private void Register(this IServiceCollection services)
{
// Register the HttpClientFactory :
services.AddHttpClient("customName")
.ConfigurePrimaryHttpMessageHandler(() =>
{
// custom handler
});
// Register the CKanClient object with the named http client
services.AddCKanClient(baseUri, "customName");
}
```
3. Now in your application you can use the CKanClient object from the DI or directly from the service provider :
```c#
public CkanClient GetClient(IServiceProvider serviceProvider)
{
return serviceProvider.GetRequiredService();
}
public class MyHttpController
{
private readonly CkanClient client;
public MyHttpController(CkanClient client)
{
this.client = client;
}
}
```
## API calls
Each API has his own client that let you to read and manipulate datas.
Each API is linked to an interface named : I\Client.
Ex for groups :
```c#
public IGroupsClient GetGroupsClient(CkanClient client)
{
return serviceProvider.GetClient();
}
```
This interface let you to read groups, get group details, ...
### List of available clients :
* Groups : IGroupsClient
* Organizations : IOrganizationsClient
* Packages : IPackagesClient
* Tags : ITagsClient
### Common supported functions :
Only read operations are avaiable yet. But more functions will be developped soon. Do not hesitate to participate.
# Documentation : I want more
Do not hesitate to check unit tests on the solution. It's a good way to check client calls and samples.
Do not hesitate to contribute.
# Support / Contribute
> If you have any questions, problems or suggestions, create an issue or fork the project and create a Pull Request.