cdl

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package cdl provides support for interacting with HSDP Clinical Data Lake services

Index

Constants

View Source
const (
	ROLE_STUDYMANAGER     = "STUDYMANAGER"
	ROLE_MONITOR          = "MONITOR"
	ROLE_UPLOADER         = "UPLOADER"
	ROLE_DATA_SCIENTIST   = "DATASCIENTIST"
	ROLE_RESEARCH_MANAGER = "RESEARCHMANAGER"
)
View Source
const (
	APIVersion = "3"
)

Variables

View Source
var (
	ErrCDLURLCannotBeEmpty = errors.New("base CDL URL cannot be empty")
	ErrEmptyResult         = errors.New("empty result")
)

Errors

Functions

This section is empty.

Types

type BundleEntry

type BundleEntry struct {
	FullURL  string          `json:"fullUrl,omitempty"`
	Resource LabelDefinition `json:"resource,omitempty"`
}

type Client

type Client struct {

	// User agent used when communicating with the HSDP Notification API
	UserAgent string

	Study              *StudyService
	DataTypeDefinition *DatatypeDefinitionService
	LabelDefinition    *LabelDefinitionService
	ExportRoute        *ExportRouteService
	// contains filtered or unexported fields
}

A Client manages communication with HSDP CDL API

func NewClient

func NewClient(iamClient *iam.Client, config *Config) (*Client, error)

NewClient returns a new HSDP CDL API client. A configured IAM client must be provided as the underlying API requires an IAM token

func (*Client) Close

func (c *Client) Close()

Close releases allocated resources of clients

func (*Client) GetCDLStoreURL

func (c *Client) GetCDLStoreURL() string

GetCDLStoreURL returns the base CDL Store base URL as configured

func (*Client) GetCDLURL

func (c *Client) GetCDLURL() string

GetCDLURL returns the base CDL Store base URL as configured

func (*Client) GetEndpointURL

func (c *Client) GetEndpointURL() string

GetEndpointURL returns the CDL Store URL including the tenant ID

func (*Client) SetCDLStoreURL

func (c *Client) SetCDLStoreURL(urlStr string) error

SetCDLStoreURL sets the CDL store URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.

func (*Client) SetCDLURL

func (c *Client) SetCDLURL(urlStr string) error

SetCDLURL sets the Notification URL for API requests

func (*Client) SetEndpointURL

func (c *Client) SetEndpointURL(urlStr string) error

SetEndpointURL sets the CDL endpoint URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.

func (*Client) TokenRefresh

func (c *Client) TokenRefresh() error

TokenRefresh forces a refresh of the IAM access token

type Config

type Config struct {
	Region         string
	Environment    string
	OrganizationID string `validate:"required"`
	CDLURL         string
	CDLStore       string
	DebugLog       io.Writer
	Retry          int
}

Config contains the configuration of a client

type DataTypeDefinition

type DataTypeDefinition struct {
	ID          string          `json:"id,omitempty"`
	Name        string          `json:"name,omitempty"`
	Description string          `json:"description,omitempty"`
	JsonSchema  json.RawMessage `json:"jsonSchema,omitempty"`
	CreatedOn   string          `json:"createdOn,omitempty"`
	CreatedBy   string          `json:"createdBy,omitempty"`
	UpdatedOn   string          `json:"updatedOn,omitempty"`
	UpdatedBy   string          `json:"updatedBy,omitempty"`
}

type DatatypeDefinitionService

type DatatypeDefinitionService struct {
	// contains filtered or unexported fields
}

func (*DatatypeDefinitionService) CreateDataTypeDefinition

func (dtd *DatatypeDefinitionService) CreateDataTypeDefinition(dataTypeDefinition DataTypeDefinition) (*DataTypeDefinition, *Response, error)

func (*DatatypeDefinitionService) GetDataTypeDefinitionByID

func (dtd *DatatypeDefinitionService) GetDataTypeDefinitionByID(id string) (*DataTypeDefinition, *Response, error)

func (*DatatypeDefinitionService) GetDataTypeDefinitions

func (dtd *DatatypeDefinitionService) GetDataTypeDefinitions(opt *GetOptions, options ...OptionFunc) ([]DataTypeDefinition, *Response, error)

func (*DatatypeDefinitionService) UpdateDataTypeDefinition

func (dtd *DatatypeDefinitionService) UpdateDataTypeDefinition(dataTypeDefinition DataTypeDefinition) (*DataTypeDefinition, *Response, error)

type Destination

type Destination struct {
	CDLResearchStudy ExportResearchStudyDestination `json:"cdlResearchStudy" validate:"required"`
}

type ExportAllowedField

type ExportAllowedField struct {
	DataObject []ExportDataObject `json:"dataObject,omitempty"`
}

type ExportDataObject

type ExportDataObject struct {
	Type        string        `json:"type"`
	ExportLabel []ExportLabel `json:"label,omitempty"`
}

type ExportLabel

type ExportLabel struct {
	Name             string `json:"name,omitempty"`
	ApprovalRequired bool   `json:"approvalRequired,omitempty"`
}

type ExportResearchStudyDestination

type ExportResearchStudyDestination struct {
	Endpoint string `json:"endpoint" validate:"required"`
}

type ExportResearchStudySource

type ExportResearchStudySource struct {
	Endpoint string              `json:"endpoint" validate:"required"`
	Allowed  *ExportAllowedField `json:"allowed,omitempty"`
}

type ExportRoute

type ExportRoute struct {
	ID              string               `json:"id,omitempty"`
	ExportRouteName string               `json:"name" validate:"required"`
	Description     string               `json:"description,omitempty"`
	DisplayName     string               `json:"displayName" validate:"required"`
	Source          Source               `json:"source" validate:"required"`
	AutoExport      bool                 `json:"autoExport,omitempty"`
	Destination     Destination          `json:"destination" validate:"required"`
	ServiceAccount  ExportServiceAccount `json:"serviceAccount" validate:"required"`
	CreatedBy       string               `json:"createdBy,omitempty"`
	CreatedOn       string               `json:"createdOn,omitempty"`
	UpdatedBy       string               `json:"updatedBy,omitempty"`
	UpdatedOn       string               `json:"updatedOn,omitempty"`
}

type ExportRouteBundleEntry

type ExportRouteBundleEntry struct {
	FullURL  string      `json:"fullUrl,omitempty"`
	Resource ExportRoute `json:"resource,omitempty"`
}

type ExportRouteBundleResponse

type ExportRouteBundleResponse struct {
	ResourceType string                   `json:"resourceType,omitempty"`
	ID           string                   `json:"id,omitempty"`
	Type         string                   `json:"type,omitempty"`
	Link         []LinkElementType        `json:"link,omitempty"`
	Entry        []ExportRouteBundleEntry `json:"entry" validate:"required"`
}

type ExportRouteService

type ExportRouteService struct {
	// contains filtered or unexported fields
}

func (*ExportRouteService) CreateExportRoute

func (exp *ExportRouteService) CreateExportRoute(exportRoute ExportRoute) (*ExportRoute, *Response, error)

func (*ExportRouteService) DeleteExportRouteByID

func (exp *ExportRouteService) DeleteExportRouteByID(exportRouteId string) (*Response, error)

func (*ExportRouteService) GetExportRouteByID

func (exp *ExportRouteService) GetExportRouteByID(exportRouteId string) (*ExportRoute, *Response, error)

func (*ExportRouteService) GetExportRoutes

func (exp *ExportRouteService) GetExportRoutes(page int, options ...OptionFunc) ([]ExportRoute, *ExportRouteBundleResponse, *Response, error)

type ExportServiceAccount

type ExportServiceAccount struct {
	CDLServiceAccount ExportServiceAccountDetails `json:"cdlServiceAccount" validate:"required"`
}

type ExportServiceAccountDetails

type ExportServiceAccountDetails struct {
	ServiceID           string `json:"serviceId" validate:"required"`
	PrivateKey          string `json:"privateKey" validate:"required"`
	AccessTokenEndPoint string `json:"accessTokenEndPoint" validate:"required"`
	TokenEndPoint       string `json:"tokenEndPoint" validate:"required"`
}

type GetOptions

type GetOptions struct {
	Page *int `url:"page,omitempty"`
}

GetOptions describes the fields on which you can search for studies

type LabelDefBundleResponse

type LabelDefBundleResponse struct {
	ResourceType string          `json:"resourceType,omitempty"`
	Id           string          `json:"id,omitempty"`
	Type         string          `json:"type,omitempty"`
	Link         json.RawMessage `json:"link,omitempty"`
	Entry        []BundleEntry   `json:"entry" validate:"required"`
}

type LabelDefinition

type LabelDefinition struct {
	ID           string            `json:"id,omitempty"`
	LabelDefName string            `json:"labelDefName" validate:"labelDefValidationHandler"`
	Description  string            `json:"description,omitempty"`
	LabelScope   LabelScope        `json:"labelScope" validate:"labelDefValidationHandler"`
	Label        string            `json:"label" validate:"required"`
	Type         string            `json:"type" validate:"required"`
	Labels       []LabelsArrayElem `json:"labels" validate:"labelDefValidationHandler"`
	CreatedBy    string            `json:"createdBy,omitempty"`
	CreatedOn    string            `json:"createdOn,omitempty"`
}

type LabelDefinitionService

type LabelDefinitionService struct {
	// contains filtered or unexported fields
}

func (*LabelDefinitionService) CreateLabelDefinition

func (l *LabelDefinitionService) CreateLabelDefinition(studyId string, labelDef LabelDefinition) (*LabelDefinition, *Response, error)

func (*LabelDefinitionService) DeleteLabelDefinitionById

func (l *LabelDefinitionService) DeleteLabelDefinitionById(studyId string, labelDefId string) (*Response, error)

func (*LabelDefinitionService) GetLabelDefinitionByID

func (l *LabelDefinitionService) GetLabelDefinitionByID(studyId string, labelDefId string) (*LabelDefinition, *Response, error)

func (*LabelDefinitionService) GetLabelDefinitions

func (l *LabelDefinitionService) GetLabelDefinitions(studyId string, opt *GetOptions, options ...OptionFunc) ([]LabelDefinition, *Response, error)

type LabelScope

type LabelScope struct {
	Type string `json:"type" validate:"required"`
}

type LabelsArrayElem

type LabelsArrayElem struct {
	Label string `json:"label" validate:"required"`
}

type LinkElementType

type LinkElementType struct {
	Relation string `json:"relation"`
	URL      string `json:"url"`
}

type OptionFunc

type OptionFunc func(*http.Request) error

OptionFunc is the function signature function for options

type Period

type Period struct {
	End string `json:"end"`
}

type Response

type Response struct {
	*http.Response
	Link []LinkElementType
}

Response is a HSDP IAM API response. This wraps the standard http.Response returned from HSDP IAM and provides convenient access to things like errors

func (*Response) StatusCode

func (r *Response) StatusCode() int

type RoleAssignment

type RoleAssignment struct {
	IAMUserUUID string `json:"IAMuserUUID"`
	Roles       []struct {
		Role string `json:"role"`
	} `json:"roles"`
}

type RoleAssignmentResult

type RoleAssignmentResult []RoleAssignment

func (RoleAssignmentResult) Roles

func (r RoleAssignmentResult) Roles(userUUID string) []string

type RoleRequest

type RoleRequest struct {
	IAMUserUUID string `json:"IAMuserUUID" validate:"required"`
	Email       string `json:"email" validate:"required"`
	Role        string `json:"role" validate:"required"`
	InstituteID string `json:"instituteID"`
}

func (RoleRequest) Equal

func (r RoleRequest) Equal(other RoleRequest) bool

Equal compares role requests

func (RoleRequest) EqualEnough

func (r RoleRequest) EqualEnough(other RoleRequest) bool

EqualEnough returns true if user and role match up

type Source

type Source struct {
	CDLResearchStudy ExportResearchStudySource `json:"cdlResearchStudy" validate:"required"`
}

type Study

type Study struct {
	ID                        string `json:"id,omitempty"`
	Title                     string `json:"title" validate:"required"`
	Description               string `json:"description,omitempty"`
	Organization              string `json:"organization,omitempty"`
	StudyOwner                string `json:"studyOwner" validate:"required"`
	Period                    Period `json:"period" validate:"required"`
	DataProtectedFromDeletion bool   `json:"dataProtectedFromDeletion,omitempty"`
}

type StudyService

type StudyService struct {
	// contains filtered or unexported fields
}

func (*StudyService) CreateStudy

func (s *StudyService) CreateStudy(study Study) (*Study, *Response, error)

func (*StudyService) GetAllStudies

func (s *StudyService) GetAllStudies(options ...OptionFunc) ([]Study, *Response, error)

func (*StudyService) GetPermissions

func (s *StudyService) GetPermissions(study Study, opt *GetOptions, options ...OptionFunc) (RoleAssignmentResult, *Response, error)

func (*StudyService) GetStudies

func (s *StudyService) GetStudies(opt *GetOptions, options ...OptionFunc) ([]Study, *Response, error)

func (*StudyService) GetStudyByID

func (s *StudyService) GetStudyByID(id string) (*Study, *Response, error)

func (*StudyService) GetStudyByTitle

func (s *StudyService) GetStudyByTitle(title string, options ...OptionFunc) (*Study, *Response, error)

func (*StudyService) GrantPermission

func (s *StudyService) GrantPermission(study Study, request RoleRequest, options ...OptionFunc) (bool, *Response, error)

func (*StudyService) RevokePermission

func (s *StudyService) RevokePermission(study Study, request RoleRequest, options ...OptionFunc) (bool, *Response, error)

func (*StudyService) UpdateStudy

func (s *StudyService) UpdateStudy(study Study) (*Study, *Response, error)

Jump to

Keyboard shortcuts

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