blr

package
v0.83.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package blr provides support the HSDP Blob Repository services

Index

Constants

View Source
const (
	APIVersion = "1"
)

Variables

View Source
var (
	ErrNotFound                       = errors.New("entity not found")
	ErrBaseURLCannotBeEmpty           = errors.New("base URL cannot be empty")
	ErrEmptyResult                    = errors.New("empty result")
	ErrInvalidEndpointURL             = errors.New("invalid endpoint URL")
	ErrMissingName                    = errors.New("missing name value")
	ErrMissingDescription             = errors.New("missing description value")
	ErrMalformedInputValue            = errors.New("malformed input value")
	ErrMissingOrganization            = errors.New("missing organization")
	ErrMissingProposition             = errors.New("missing proposition")
	ErrMissingGlobalReference         = errors.New("missing global reference")
	ErrNotImplementedByHSDP           = errors.New("method not implemented by HSDP")
	ErrEmptyResults                   = errors.New("empty results")
	ErrOperationFailed                = errors.New("operation failed")
	ErrCouldNoReadResourceAfterCreate = errors.New("could not read resource after create")
)

Functions

This section is empty.

Types

type AccessURL added in v0.64.0

type AccessURL struct {
	ResourceType string     `json:"resourceType"`
	Actions      []string   `json:"actions"`
	URL          string     `json:"url"`
	URLExpiry    string     `json:"urlExpiry"`
	BlobPartURLs []BlobPart `json:"blobPartUrls,omitempty"`
}

type Attachment

type Attachment struct {
	ContentType string `json:"contentType,omitempty"`
	Language    string `json:"language,omitempty"`
	Hash        string `json:"hash,omitempty"`
	Title       string `json:"title,omitempty"`
	Data        string `json:"data" validate:"required"`
	URL         string `json:"url"`
	Size        int64  `json:"size"`
	Created     string `json:"created,omitempty"`
}

type Blob

type Blob struct {
	ResourceType             string      `json:"resourceType" validate:"required"`
	ID                       string      `json:"id,omitempty"`
	DataType                 string      `json:"dataType" validate:"required"`
	Guid                     string      `json:"guid,omitempty"`
	Tags                     *[]Tag      `json:"tags,omitempty" validate:"omitempty,max=10"`
	AutoGenerateBlobPathName bool        `json:"autoGenerateBlobPathName"`
	BlobPath                 string      `json:"blobPath,omitempty" validate:"omitempty"`
	BlobName                 string      `json:"blobName,omitempty" validate:"omitempty"`
	VirtualPath              string      `json:"virtualPath,omitempty" validate:"omitempty"`
	VirtualName              string      `json:"virtualName,omitempty" validate:"omitempty"`
	Bucket                   string      `json:"bucket,omitempty"`
	Creation                 *string     `json:"creation,omitempty"`
	CreatedBy                string      `json:"createdBy,omitempty"`
	Attachment               *Attachment `json:"attachment,omitempty"`
	UploadOnBehalf           bool        `json:"uploadOnBehalf"`
	ManagingOrganization     string      `json:"managingOrganization,omitempty"`
	PropositionGuid          string      `json:"propositionGuid,omitempty"`
	MultipartEnabled         bool        `json:"multipartEnabled"`
	NoOfParts                *int        `json:"noOfParts,omitempty"`
	State                    *string     `json:"state,omitempty"`
	Meta                     *Meta       `json:"meta,omitempty"`
}

type BlobPart added in v0.64.0

type BlobPart struct {
	PartNumber          int    `json:"partNumber"`
	DataAccessURL       string `json:"dataAccessUrl"`
	DataAccessUrlExpiry string `json:"dataAccessUrlExpiry"`
}

type BlobPartUpload added in v0.64.0

type BlobPartUpload struct {
	ResourceType string       `json:"resourceType"`
	BlobParts    []PartUpload `json:"blobParts"`
}

type BlobPolicy added in v0.64.0

type BlobPolicy struct {
	ResourceType string            `json:"resourceType" validate:"required"`
	Statement    []PolicyStatement `json:"statement" validate:"required"`
}

type BlobStorePolicy added in v0.82.0

type BlobStorePolicy struct {
	ResourceType string                     `json:"resourceType"`
	ID           string                     `json:"id,omitempty"`
	Statement    []BlobStorePolicyStatement `json:"statement"`
}

type BlobStorePolicyStatement added in v0.82.0

type BlobStorePolicyStatement struct {
	Effect    string   `json:"effect"`
	Action    []string `json:"action"`
	Principal []string `json:"principal"`
	Resource  []string `json:"resource"`
}

type BlobsService

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

func (*BlobsService) AbortUpload added in v0.64.0

func (b *BlobsService) AbortUpload(blob Blob) (bool, *Response, error)

func (*BlobsService) CompleteUpload added in v0.64.0

func (b *BlobsService) CompleteUpload(blob Blob, parts BlobPartUpload) (bool, *Response, error)

func (*BlobsService) Create

func (b *BlobsService) Create(blob Blob) (*Blob, *Response, error)

func (*BlobsService) Delete

func (b *BlobsService) Delete(blob Blob) (bool, *Response, error)

func (*BlobsService) DeletePolicy added in v0.64.0

func (b *BlobsService) DeletePolicy(blob Blob) (bool, *Response, error)

func (*BlobsService) Find

func (b *BlobsService) Find(opt *GetBlobOptions, options ...OptionFunc) (*[]Blob, *Response, error)

func (*BlobsService) GetAccessURL added in v0.64.0

func (b *BlobsService) GetAccessURL(blob Blob) (*AccessURL, *Response, error)

func (*BlobsService) GetByID

func (b *BlobsService) GetByID(id string) (*Blob, *Response, error)

func (*BlobsService) GetPolicy added in v0.64.0

func (b *BlobsService) GetPolicy(blob Blob) (*BlobPolicy, *Response, error)

func (*BlobsService) ListParts added in v0.64.0

func (b *BlobsService) ListParts(blob Blob) (*BlobPartUpload, *Response, error)

func (*BlobsService) SetPolicy added in v0.64.0

func (b *BlobsService) SetPolicy(blob Blob, policy BlobPolicy) (bool, *Response, error)

type Bucket added in v0.82.2

type Bucket struct {
	ResourceType                 string            `json:"resourceType" validate:"required"`
	ID                           string            `json:"id,omitempty"`
	Name                         string            `json:"name" validate:"required"`
	EnableHSDPDomain             bool              `json:"enableHSDPDomain"`
	EnableCDN                    bool              `json:"enableCDN"`
	PriceClass                   string            `json:"priceClass,omitempty"`
	CacheControlAge              int               `json:"cacheControlAge,omitempty"`
	PropositionID                Reference         `json:"propositionId" validate:"required"`
	CorsConfiguration            CorsConfiguration `json:"corsConfiguration"`
	EnableCreateOrDeleteBlobMeta bool              `json:"enableCreateOrDeleteBlobMeta"`
}

type Client

type Client struct {
	// HTTP Client used to communicate with IAM API
	*iam.Client

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

	Blobs          *BlobsService
	Configurations *ConfigurationsService
	// contains filtered or unexported fields
}

A Client manages communication with HSDP Blob Repository APIs

func NewClient

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

NewClient returns a new BLR client

func (*Client) Close

func (c *Client) Close()

Close releases allocated resources of clients

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do performs a http request. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) GetBaseURL

func (c *Client) GetBaseURL() string

GetBaseURL returns the base URL as configured

func (*Client) GetEndpointURL

func (c *Client) GetEndpointURL() string

GetEndpointURL returns the Discovery Endpoint URL as configured

func (*Client) NewRequest

func (c *Client) NewRequest(method, requestPath string, opt interface{}, options ...OptionFunc) (*http.Request, error)

func (*Client) SetBaseURL

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

SetBaseURL sets the base URL for API requests

type Config

type Config struct {
	Region      string
	Environment string
	BaseURL     string
	DebugLog    io.Writer
	Retry       int
}

Config contains the configuration of a Client

type ConfigurationsService added in v0.82.0

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

func (*ConfigurationsService) CreateBlobStorePolicy added in v0.82.0

func (b *ConfigurationsService) CreateBlobStorePolicy(policy BlobStorePolicy) (*BlobStorePolicy, *Response, error)

func (*ConfigurationsService) CreateBucket added in v0.82.2

func (b *ConfigurationsService) CreateBucket(bucket Bucket) (*Bucket, *Response, error)

func (*ConfigurationsService) DeleteBlobStorePolicy added in v0.82.0

func (b *ConfigurationsService) DeleteBlobStorePolicy(policy BlobStorePolicy) (bool, *Response, error)

func (*ConfigurationsService) DeleteBucket added in v0.82.2

func (b *ConfigurationsService) DeleteBucket(bucket Bucket) (bool, *Response, error)

func (*ConfigurationsService) FindBlobStorePolicy added in v0.82.0

func (b *ConfigurationsService) FindBlobStorePolicy(opt *GetBlobStorePolicyOptions, options ...OptionFunc) (*[]BlobStorePolicy, *Response, error)

func (*ConfigurationsService) FindBucket added in v0.82.2

func (b *ConfigurationsService) FindBucket(opt *GetBucketOptions, options ...OptionFunc) (*[]Bucket, *Response, error)

func (*ConfigurationsService) GetBlobStorePolicyByID added in v0.82.0

func (b *ConfigurationsService) GetBlobStorePolicyByID(id string) (*BlobStorePolicy, *Response, error)

func (*ConfigurationsService) GetBucketByID added in v0.82.2

func (b *ConfigurationsService) GetBucketByID(id string) (*Bucket, *Response, error)

func (*ConfigurationsService) UpdateBucket added in v0.82.2

func (b *ConfigurationsService) UpdateBucket(bucket Bucket) (*Bucket, *Response, error)

UpdateBucket updates a bucket

type CorsConfiguration added in v0.82.2

type CorsConfiguration struct {
	AllowedOrigins []string `json:"allowedOrigins"`
	AllowedMethods []string `json:"allowedMethods"`
	AllowedHeaders []string `json:"allowedHeaders"`
	ExposeHeaders  []string `json:"exposeHeaders"`
	MaxAgeSeconds  int      `json:"maxAgeSeconds"`
}

type GetBlobOptions

type GetBlobOptions struct {
	HSDPID          *string `url:"hsdpId,omitempty"`
	BlobName        *string `url:"blobName,omitempty"`
	DataType        *string `url:"dataType,omitempty"`
	GUID            *string `url:"guid,omitempty"`
	DefaultRegionID *string `url:"defaultRegionId,omitempty"`
	LastUpdated     *string `url:"_lastUpdated,omitempty"`
	StartDate       *string `url:"startDate,omitempty"`
	EndDate         *string `url:"endDate,omitempty"`
	Include         *string `url:"_include,omitempty"`
	Page            *string `url:"page,omitempty"`
	Count           *int    `url:"_count,omitempty"`
	SingleDownload  *string `url:"singleDownload,omitempty"`
}

type GetBlobStorePolicyOptions added in v0.82.0

type GetBlobStorePolicyOptions struct {
	ID *string `url:"_id,omitempty"`
}

type GetBucketOptions added in v0.82.2

type GetBucketOptions struct {
	ID            *string `url:"_id,omitempty"`
	Name          *string `url:"name,omitempty"`
	PropositionID *string `url:"propositionId,omitempty"`
	Count         *int    `url:"_count,omitempty"`
	Page          *int    `url:"page,omitempty"`
}

GetBucketOptions struct describes search criteria for looking up Bucket

type Meta

type Meta struct {
	LastUpdated time.Time `json:"lastUpdated,omitempty"`
	VersionID   string    `json:"versionId,omitempty"`
}

type OptionFunc

type OptionFunc func(*http.Request) error

OptionFunc is the function signature function for options

type PartUpload added in v0.64.0

type PartUpload struct {
	PartNumber   int    `json:"partNumber"`
	Size         int    `json:"size"`
	LastModified string `json:"lastModified"`
	ETag         string `json:"eTag"`
}

type PolicyStatement added in v0.64.0

type PolicyStatement struct {
	ResourceType string                `json:"resourceType" validate:"required"`
	SID          *string               `json:"sid,omitempty"`
	Principal    PrincipalResourceList `json:"principal" validate:"required"`
	Effect       string                `json:"effect" validate:"required"`
	Action       []string              `json:"action" validate:"required"`
}

type PrincipalResourceList added in v0.64.0

type PrincipalResourceList struct {
	HSDP []string `json:"hsdp" validate:"required,min=1,max=64"`
}

type Reference added in v0.82.2

type Reference struct {
	Reference string `json:"reference"`
	Display   string `json:"display"`
}

type Response

type Response struct {
	*http.Response
}

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

func (*Response) StatusCode added in v0.73.0

func (r *Response) StatusCode() int

type Tag

type Tag struct {
	Key   string `json:"key" validate:"required"`
	Value string `json:"value" validate:"required"`
}

Jump to

Keyboard shortcuts

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