importapi

package
v2.206.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 12 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an import api client which can be used to make requests to the API

func New

func New(importAPIURL string) *Client

New creates new instance of Client with a give import api url

func (*Client) Checker

func (c *Client) Checker(ctx context.Context, check *health.CheckState) error

Checker calls import api health endpoint and returns a check object to the caller.

func (*Client) GetImportJob

func (c *Client) GetImportJob(ctx context.Context, importJobID, serviceToken string) (importJob ImportJob, err error)

GetImportJob asks the Import API for the details for an Import job

func (*Client) IncreaseProcessedInstanceCount

func (c *Client) IncreaseProcessedInstanceCount(ctx context.Context, jobID, serviceToken, instanceID string) (procInst []ProcessedInstances, err error)

func (*Client) UpdateImportJobState

func (c *Client) UpdateImportJobState(ctx context.Context, jobID, serviceToken string, newState State) error

UpdateImportJobState tells the Import API that the state has changed of an Import job

type ErrInvalidAPIResponse

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

ErrInvalidAPIResponse is returned when the api does not respond with a valid status

func NewAPIResponse

func NewAPIResponse(resp *http.Response, uri string) (e *ErrInvalidAPIResponse)

NewAPIResponse creates an error response, optionally adding body to e when status is 404

func (ErrInvalidAPIResponse) Code

func (e ErrInvalidAPIResponse) Code() int

Code returns the status code received from the api if an error is returned

func (ErrInvalidAPIResponse) Error

func (e ErrInvalidAPIResponse) Error() string

Error should be called by the user to print out the stringified version of the error

type ImportJob

type ImportJob struct {
	JobID     string               `json:"id"`
	Links     LinkMap              `json:"links,omitempty"`
	Processed []ProcessedInstances `json:"processed_instances,omitempty"`
}

ImportJob comes from the Import API and links an import job to its (other) instances

type InstanceLink struct {
	ID   string `json:"id"`
	Link string `json:"href"`
}

InstanceLink identifies an (instance or import-job) by id and url (from Import API)

type LinkMap

type LinkMap struct {
	Instances []InstanceLink `json:"instances"`
}

LinkMap is an array of instance links associated with am import job

type ProcessedInstances

type ProcessedInstances struct {
	ID             string `json:"id,omitempty"`
	RequiredCount  int    `json:"required_count,omitempty"`
	ProcessedCount int    `json:"processed_count,omitempty"`
}

ProcessedInstances holds the ID and the number of code lists that have been processed during an import process for an instance

type State added in v2.4.5

type State int

State - iota enum of possible states

const (
	StateCreated State = iota
	StateSubmitted
	StateCompleted
	StateFailed
)

Possible values for a State of the resource

func (State) Json added in v2.4.5

func (s State) Json() *stateData

Json returns a json type with 'state' key and the string corresponding to the provided state as value e.g. {"state": "created"}

func (State) String added in v2.4.5

func (s State) String() string

String returns the string representation of a state

Jump to

Keyboard shortcuts

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