# README
dp-permissions-api SDK
Overview
This API contains a client with convenience functions for interacting with the permissions api from other applications. It also contains reusable structs representing models used as payloads in API endpoints.
Example use of the API SDK
package main
import (
"context"
"github.com/ONSdigital/dp-permissions-api/sdk"
)
func main() {
apiClient := sdk.NewClient("http://localhost:25400")
permissionsBundle, err := c.cache.GetPermissionsBundle(context.Backgroud)
}
Alternative Client instantiation
In the unlikely event that there is a need to use non-default initialisation, it is possible to obtain a new client with customised options and/or underlying http client.
With Options
NB. There are currently no defined options available, this is included for future expansion.
apiClient := sdk.NewClientWithOptions("http://localhost:25400", sdk.Options{})
With Options and a custom http client
import dphttp "github.com/ONSdigital/dp-net/v2/http"
apiClient := sdk.NewClientWithClienter("http://localhost:25400", dphttp.NewClient(), sdk.Options{})
# Functions
NewClient constructs a new APIClient instance with a default http client and Options.
NewClientWithClienter constructs a new APIClient instance.
NewClientWithOptions returns a new APIClient with default http.
# Constants
package level constants.
No description provided by the author
No description provided by the author
# Variables
ErrFailedToParsePermissionsResponse error used when an unexpected response body is returned from the permissions API and it fails to parse.
ErrGetPermissionsResponseBodyNil error used when a nil response is returned from the permissions API.
ErrNotCached error error used when permissions are not found in the cache.
# Structs
APIClient implementation of permissions.Store that gets permission data from the permissions API.
Condition is used within a policy to match additional attributes.
EntityData groups the different entity types into a single parameter.
Options is a struct containing for customised options for the API client.
Policy is the policy model as stored in the permissions API.
# Interfaces
HTTPClient is the interface that defines a client for making HTTP requests.
# Type aliases
Bundle is the optimised lookup table for permissions.
EntityIDToPolicies maps an entity ID to a slice of policies.
Operator is used to define a set of supported Condition operators.