Skip to content

Commit f482ed0

Browse files
committed
Add SDK Documentation
1 parent 891ecdf commit f482ed0

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ API for managing access control permissions for Digital Publishing API resources
44

55
### Getting started
66

7-
* Load inital roles into your local mongodb using the `import-script` utility in the import-script folder. Follow the steps in the [README](./import-script/README.md).
7+
* Load inital roles into your local mongodb using the `import-script` utility in the import-script folder. Follow the
8+
steps in the [README](./import-script/README.md).
89
* Run `make debug`
910

1011
### Dependencies
@@ -34,6 +35,10 @@ API for managing access control permissions for Digital Publishing API resources
3435
| DEFAULT_OFFSET | 0 | Default offset for pagination |
3536
| DEFAULT_MAXIMUM_LIMIT | 1000 | Default maximum limit for pagination |
3637

38+
### SDK Package
39+
40+
[An SDK for the API is available as a subpackage in `/sdk`](sdk/README.md)
41+
3742
### Contributing
3843

3944
See [CONTRIBUTING](CONTRIBUTING.md) for details.

sdk/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
dp-permissions-api SDK
2+
======================
3+
4+
## Overview
5+
6+
This API contains a client with convenience functions for interacting with the permissions api from other applications.
7+
It also contains reusable structs representing models used as payloads in API endpoints.
8+
9+
## Example use of the API SDK
10+
11+
```go
12+
package main
13+
14+
import (
15+
"context"
16+
"github.com/ONSdigital/dp-permissions-api/sdk"
17+
)
18+
19+
func main() {
20+
apiClient := sdk.NewClient("http://localhost:25400")
21+
22+
permissionsBundle, err := c.cache.GetPermissionsBundle(context.Backgroud)
23+
}
24+
```
25+
26+
## Alternative Client instantiation
27+
28+
In the unlikely event that there is a need to use non-default initialisation, it is possible to obtain a new client with
29+
customised options and/or underlying http client.
30+
31+
### With Options
32+
33+
NB. There are currently no defined options available, this is included for future expansion.
34+
35+
```go
36+
apiClient := sdk.NewClientWithOptions("http://localhost:25400", sdk.Options{})
37+
```
38+
39+
### With Options and a custom http client
40+
41+
```go
42+
import dphttp "github.com/ONSdigital/dp-net/v2/http"
43+
44+
apiClient := sdk.NewClientWithClienter("http://localhost:25400", dphttp.NewClient(), sdk.Options{})
45+
```

0 commit comments

Comments
 (0)