api

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package api provides primitives to interact the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var ErrorMissingHash = errors.New("missing consentRecordHash")

ErrorMissingHash is returned when the consentRecordHash parameter is missing

Functions

func NewCheckConsentRequest

func NewCheckConsentRequest(server string, body CheckConsentJSONRequestBody) (*http.Request, error)

NewCheckConsentRequest calls the generic CheckConsent builder with application/json body

func NewCheckConsentRequestWithBody

func NewCheckConsentRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewCheckConsentRequestWithBody generates requests for CheckConsent with any type of body

func NewCreateConsentRequest

func NewCreateConsentRequest(server string, body CreateConsentJSONRequestBody) (*http.Request, error)

NewCreateConsentRequest calls the generic CreateConsent builder with application/json body

func NewCreateConsentRequestWithBody

func NewCreateConsentRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewCreateConsentRequestWithBody generates requests for CreateConsent with any type of body

func NewDeleteConsentRequest

func NewDeleteConsentRequest(server string, consentRecordHash string) (*http.Request, error)

NewDeleteConsentRequest generates requests for DeleteConsent

func NewFindConsentRecordRequest

func NewFindConsentRecordRequest(server string, consentRecordHash string, params *FindConsentRecordParams) (*http.Request, error)

NewFindConsentRecordRequest generates requests for FindConsentRecord

func NewQueryConsentRequest

func NewQueryConsentRequest(server string, body QueryConsentJSONRequestBody) (*http.Request, error)

NewQueryConsentRequest calls the generic QueryConsent builder with application/json body

func NewQueryConsentRequestWithBody

func NewQueryConsentRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewQueryConsentRequestWithBody generates requests for QueryConsent with any type of body

func ParsecheckConsentResponse

func ParsecheckConsentResponse(rsp *http.Response) (*checkConsentResponse, error)

ParsecheckConsentResponse parses an HTTP response from a CheckConsentWithResponse call

func ParsecreateConsentResponse

func ParsecreateConsentResponse(rsp *http.Response) (*createConsentResponse, error)

ParsecreateConsentResponse parses an HTTP response from a CreateConsentWithResponse call

func ParsedeleteConsentResponse

func ParsedeleteConsentResponse(rsp *http.Response) (*deleteConsentResponse, error)

ParsedeleteConsentResponse parses an HTTP response from a DeleteConsentWithResponse call

func ParsefindConsentRecordResponse

func ParsefindConsentRecordResponse(rsp *http.Response) (*findConsentRecordResponse, error)

ParsefindConsentRecordResponse parses an HTTP response from a FindConsentRecordWithResponse call

func ParsequeryConsentResponse

func ParsequeryConsentResponse(rsp *http.Response) (*queryConsentResponse, error)

ParsequeryConsentResponse parses an HTTP response from a QueryConsentWithResponse call

func RegisterHandlers

func RegisterHandlers(router runtime.EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

Types

type CheckConsentJSONRequestBody

type CheckConsentJSONRequestBody checkConsentJSONBody

CheckConsentRequestBody defines body for CheckConsent for application/json ContentType.

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example.
	Server string

	// HTTP client with any customized settings, such as certificate chains.
	Client http.Client

	// A callback for modifying requests which are generated before sending over
	// the network.
	RequestEditor RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func (*Client) CheckConsent

func (c *Client) CheckConsent(ctx context.Context, body CheckConsentJSONRequestBody) (*http.Response, error)

func (*Client) CheckConsentWithBody

func (c *Client) CheckConsentWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)

func (*Client) CreateConsent

func (c *Client) CreateConsent(ctx context.Context, body CreateConsentJSONRequestBody) (*http.Response, error)

func (*Client) CreateConsentWithBody

func (c *Client) CreateConsentWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)

func (*Client) DeleteConsent

func (c *Client) DeleteConsent(ctx context.Context, consentRecordHash string) (*http.Response, error)

func (*Client) FindConsentRecord

func (c *Client) FindConsentRecord(ctx context.Context, consentRecordHash string, params *FindConsentRecordParams) (*http.Response, error)

func (*Client) QueryConsent

func (c *Client) QueryConsent(ctx context.Context, body QueryConsentJSONRequestBody) (*http.Response, error)

func (*Client) QueryConsentWithBody

func (c *Client) QueryConsentWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// CreateConsent request  with any body
	CreateConsentWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)

	CreateConsent(ctx context.Context, body CreateConsentJSONRequestBody) (*http.Response, error)

	// CheckConsent request  with any body
	CheckConsentWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)

	CheckConsent(ctx context.Context, body CheckConsentJSONRequestBody) (*http.Response, error)

	// QueryConsent request  with any body
	QueryConsentWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)

	QueryConsent(ctx context.Context, body QueryConsentJSONRequestBody) (*http.Response, error)

	// DeleteConsent request
	DeleteConsent(ctx context.Context, consentRecordHash string) (*http.Response, error)

	// FindConsentRecord request
	FindConsentRecord(ctx context.Context, consentRecordHash string, params *FindConsentRecordParams) (*http.Response, error)
}

The interface specification for the client above.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string) *ClientWithResponses

NewClientWithResponses returns a ClientWithResponses with a default Client:

func NewClientWithResponsesAndRequestEditorFunc

func NewClientWithResponsesAndRequestEditorFunc(server string, reqEditorFn RequestEditorFn) *ClientWithResponses

NewClientWithResponsesAndRequestEditorFunc takes in a RequestEditorFn callback function and returns a ClientWithResponses with a default Client:

func (*ClientWithResponses) CheckConsentWithBodyWithResponse

func (c *ClientWithResponses) CheckConsentWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*checkConsentResponse, error)

CheckConsentWithBodyWithResponse request with arbitrary body returning *CheckConsentResponse

func (*ClientWithResponses) CheckConsentWithResponse

func (c *ClientWithResponses) CheckConsentWithResponse(ctx context.Context, body CheckConsentJSONRequestBody) (*checkConsentResponse, error)

func (*ClientWithResponses) CreateConsentWithBodyWithResponse

func (c *ClientWithResponses) CreateConsentWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*createConsentResponse, error)

CreateConsentWithBodyWithResponse request with arbitrary body returning *CreateConsentResponse

func (*ClientWithResponses) CreateConsentWithResponse

func (c *ClientWithResponses) CreateConsentWithResponse(ctx context.Context, body CreateConsentJSONRequestBody) (*createConsentResponse, error)

func (*ClientWithResponses) DeleteConsentWithResponse

func (c *ClientWithResponses) DeleteConsentWithResponse(ctx context.Context, consentRecordHash string) (*deleteConsentResponse, error)

DeleteConsentWithResponse request returning *DeleteConsentResponse

func (*ClientWithResponses) FindConsentRecordWithResponse

func (c *ClientWithResponses) FindConsentRecordWithResponse(ctx context.Context, consentRecordHash string, params *FindConsentRecordParams) (*findConsentRecordResponse, error)

FindConsentRecordWithResponse request returning *FindConsentRecordResponse

func (*ClientWithResponses) QueryConsentWithBodyWithResponse

func (c *ClientWithResponses) QueryConsentWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*queryConsentResponse, error)

QueryConsentWithBodyWithResponse request with arbitrary body returning *QueryConsentResponse

func (*ClientWithResponses) QueryConsentWithResponse

func (c *ClientWithResponses) QueryConsentWithResponse(ctx context.Context, body QueryConsentJSONRequestBody) (*queryConsentResponse, error)

type ConsentCheckRequest

type ConsentCheckRequest struct {
	Actor     Identifier `json:"actor"`
	Custodian Identifier `json:"custodian"`
	DataClass string     `json:"dataClass"`
	Subject   Identifier `json:"subject"`
	ValidAt   *string    `json:"validAt,omitempty"`
}

ConsentCheckRequest defines model for ConsentCheckRequest.

type ConsentCheckResponse

type ConsentCheckResponse struct {
	ConsentGiven *string `json:"consentGiven,omitempty"`
	Limitations  *string `json:"limitations,omitempty"`
}

ConsentCheckResponse defines model for ConsentCheckResponse.

type ConsentQueryRequest

type ConsentQueryRequest struct {
	Actor     *Identifier     `json:"actor,omitempty"`
	Custodian *Identifier     `json:"custodian,omitempty"`
	Page      *PageDefinition `json:"page,omitempty"`
	Subject   *Identifier     `json:"subject,omitempty"`
	ValidAt   *string         `json:"validAt,omitempty"`
}

ConsentQueryRequest defines model for ConsentQueryRequest.

type ConsentQueryResponse

type ConsentQueryResponse struct {
	Page         PageDefinition   `json:"page"`
	Results      []PatientConsent `json:"results"`
	TotalResults int              `json:"totalResults"`
}

ConsentQueryResponse defines model for ConsentQueryResponse.

type ConsentRecord

type ConsentRecord struct {
	DataClasses        []string  `json:"dataClasses"`
	PreviousRecordHash *string   `json:"previousRecordHash,omitempty"`
	RecordHash         string    `json:"recordHash"`
	ValidFrom          ValidFrom `json:"validFrom"`
	ValidTo            *ValidTo  `json:"validTo,omitempty"`
	Version            *int      `json:"version,omitempty"`
}

ConsentRecord defines model for ConsentRecord.

func FromConsentRecord

func FromConsentRecord(consentRecord pkg.ConsentRecord) ConsentRecord

FromConsentRecord converts the DB type to api type

func (ConsentRecord) ToConsentRecord

func (cr ConsentRecord) ToConsentRecord() (pkg.ConsentRecord, error)

ToConsentRecord converts the API consent record object to the internal DB object

type CreateConsentJSONRequestBody

type CreateConsentJSONRequestBody createConsentJSONBody

CreateConsentRequestBody defines body for CreateConsent for application/json ContentType.

type FindConsentRecordParams

type FindConsentRecordParams struct {
	Latest *bool `json:"latest,omitempty"`
}

FindConsentRecordParams defines parameters for FindConsentRecord.

type HttpClient

type HttpClient struct {
	ServerAddress string
	Timeout       time.Duration
	Logger        *logrus.Entry
	// contains filtered or unexported fields
}

HttpClient holds the server address and other basic settings for the http client

func (HttpClient) ConsentAuth

func (hb HttpClient) ConsentAuth(ctx context.Context, custodian string, subject string, actor string, dataClass string, checkpoint *time.Time) (bool, error)

ConsentAuth checks if there is an active consent for a given custodian, subject, actor, dataClass and an optional moment in time (checkpoint)

func (HttpClient) DeleteConsentRecordByHash

func (hb HttpClient) DeleteConsentRecordByHash(context context.Context, consentRecordHash string) (bool, error)

func (HttpClient) FindConsentRecordByHash

func (hb HttpClient) FindConsentRecordByHash(context context.Context, consentRecordHash string, latest bool) (pkg.ConsentRecord, error)

FindConsentRecordByHash returns a ConsentRecord based on a hash. A latest flag can be added to indicate a record may only be returned if it's the latest in the chain.

func (HttpClient) QueryConsent

func (hb HttpClient) QueryConsent(context context.Context, actor *string, custodian *string, subject *string, validAt *time.Time) ([]pkg.PatientConsent, error)

QueryConsent returns PatientConsent records based on a combination of actor, custodian and subject. The only constraint is that either actor or custodian must not be empty.

func (HttpClient) RecordConsent

func (hb HttpClient) RecordConsent(ctx context.Context, consent []pkg.PatientConsent) error

RecordConsent currently only supports the creation of a single record

type Identifier

type Identifier string

Identifier defines model for Identifier.

type PageDefinition

type PageDefinition struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
}

PageDefinition defines model for PageDefinition.

type PatientConsent

type PatientConsent struct {
	Actor     Identifier      `json:"actor"`
	Custodian Identifier      `json:"custodian"`
	Id        string          `json:"id"`
	Records   []ConsentRecord `json:"records"`
	Subject   Identifier      `json:"subject"`
}

PatientConsent defines model for PatientConsent.

func FromPatientConsent

func FromPatientConsent(pc pkg.PatientConsent) PatientConsent

FromPatientConsent converts a pkg.PatientConsent to a PatientConsent

func FromPatientConsents

func FromPatientConsents(pc []pkg.PatientConsent) []PatientConsent

FromPatientConsent converts a slice of pkg.PatientConsent to a slice of api.PatientConsent

func (PatientConsent) ToPatientConsent

func (sc PatientConsent) ToPatientConsent() (pkg.PatientConsent, error)

ToPatientConsent converts the api PatientConsent struct to an internal PatientConsent

type QueryConsentJSONRequestBody

type QueryConsentJSONRequestBody queryConsentJSONBody

QueryConsentRequestBody defines body for QueryConsent for application/json ContentType.

type RequestEditorFn

type RequestEditorFn func(req *http.Request, ctx context.Context) error

RequestEditorFn is the function signature for the RequestEditor callback function

type ServerInterface

type ServerInterface interface {
	// Create a new consent record for a C-S-A combination.// (POST /consent)
	CreateConsent(ctx echo.Context) error
	// Send a request for checking if the given combination exists// (POST /consent/check)
	CheckConsent(ctx echo.Context) error
	// Do a query for available consent// (POST /consent/query)
	QueryConsent(ctx echo.Context) error
	// Remove a consent record for a C-S-A combination.// (DELETE /consent/{consentRecordHash})
	DeleteConsent(ctx echo.Context, consentRecordHash string) error
	// Retrieve a consent record by hash, use latest query param to only return a value if the given consent record is the latest in the chain.// (GET /consent/{consentRecordHash})
	FindConsentRecord(ctx echo.Context, consentRecordHash string, params FindConsentRecordParams) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) CheckConsent

func (w *ServerInterfaceWrapper) CheckConsent(ctx echo.Context) error

CheckConsent converts echo context to params.

func (*ServerInterfaceWrapper) CreateConsent

func (w *ServerInterfaceWrapper) CreateConsent(ctx echo.Context) error

CreateConsent converts echo context to params.

func (*ServerInterfaceWrapper) DeleteConsent

func (w *ServerInterfaceWrapper) DeleteConsent(ctx echo.Context) error

DeleteConsent converts echo context to params.

func (*ServerInterfaceWrapper) FindConsentRecord

func (w *ServerInterfaceWrapper) FindConsentRecord(ctx echo.Context) error

FindConsentRecord converts echo context to params.

func (*ServerInterfaceWrapper) QueryConsent

func (w *ServerInterfaceWrapper) QueryConsent(ctx echo.Context) error

QueryConsent converts echo context to params.

type ValidFrom

type ValidFrom string

ValidFrom defines model for ValidFrom.

type ValidTo

type ValidTo string

ValidTo defines model for ValidTo.

type Wrapper

type Wrapper struct {
	Cs *pkg.ConsentStore
}

Wrapper implements the ServerInterface for the base ConsentStore

func (*Wrapper) CheckConsent

func (w *Wrapper) CheckConsent(ctx echo.Context) error

CheckConsent checks if a given resource is allowed for a given actor, subject, custodian triple

func (*Wrapper) CreateConsent

func (w *Wrapper) CreateConsent(ctx echo.Context) error

CreateConsent creates or updates a PatientConsent in the consent store

func (*Wrapper) DeleteConsent

func (w *Wrapper) DeleteConsent(ctx echo.Context, consentRecordHash string) error

DeleteConsent deletes the consentRecord for a given consentRecordHash

func (*Wrapper) FindConsentRecord

func (w *Wrapper) FindConsentRecord(ctx echo.Context, consentRecordHash string, params FindConsentRecordParams) error

FindConsentRecord returns a ConsentRecord based on a hash. A latest flag can be added to indicate a record may only be returned if it's the latest in the chain.

func (*Wrapper) QueryConsent

func (w *Wrapper) QueryConsent(ctx echo.Context) error

QueryConsent finds given consent for a combination of actor, subject and/or custodian

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL