Documentation
¶
Index ¶
- Constants
- type DownloadInfo
- type DownloadService
- type ErrorInfo
- type File
- type FileService
- type HTTPError
- type Link
- type ListOptions
- type Member
- type Metadata
- type MultipartUpload
- type Page
- type PartUploadInitResponse
- type Permissions
- type Project
- type ProjectCreate
- type ProjectService
- type Rate
- type Response
- type SevenBridges
- type Timestamp
- type UploadInfo
- type UploadInitResponse
- type UploadService
- type User
- type UserService
Constants ¶
const ( // KB is number of bytes in KiloByte KB = 1024 // MB is number of bytes in MegaByte MB = 1024 * KB // GB is number of bytes in GigaByte GB = 1024 * MB // TB is number of byte in TeraByte TB = 1024 * GB // PartSize is default number of bytes in one part. PartSize = 10 * MB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DownloadInfo ¶
type DownloadInfo struct {
URL string `json:"url"`
}
DownloadInfo holds information on where file from SevenBridges platform can be download from.
type DownloadService ¶
type DownloadService interface {
Info(ctx context.Context, fileID string) (*DownloadInfo, *Response, error)
Download(ctx context.Context, fileID, destination string) error
}
DownloadService is service for downloading files from SevenBridges platform.
type ErrorInfo ¶
type ErrorInfo struct {
Status int `json:"status"`
Code int `json:"code"`
Message string `json:"message"`
MoreInfo string `json:"more_info"`
}
ErrorInfo holds information about error that occurred on SevenBridges server.
type File ¶
type File struct {
Href string `json:"href"`
ID string `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
Project string `json:"project"`
CreatedOn time.Time `json:"created_on"`
ModifiedOn time.Time `json:"modified_on"`
Origin interface{} `json:"origin"` // TODO: what is this?
Metadata Metadata `json:"metadata"`
}
File contains information about single file on SevenBridges platform.
type FileService ¶
type FileService interface {
// List returns users files (single page).
List(ctx context.Context, projectID string) ([]*File, *Response, error)
// ByID returns singe file by its ID.
ByID(ctx context.Context, fileID string) (*File, *Response, error)
// Delete removes file with provided ID from platform.
Delete(ctx context.Context, fileID string) (*Response, error)
}
FileService is interface that defines operations on files on SevenBridges platform.
type HTTPError ¶
HTTPError is error returned by SevenBridges API that contains additional information about error that occurred.
type Link ¶
Link holds information about navigation between pages in SevenBridges API.
type ListOptions ¶
type ListOptions struct {
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
Fields []string `url:"fields,omitempty,comma"`
}
ListOptions specifies optional parameter to various List methods that support pagination.
func (*ListOptions) IsZero ¶
func (lo *ListOptions) IsZero() bool
IsZero returns true if current value of ListOptions can not be distinguished from zero value.
type Member ¶
type Member struct {
Href *string `json:"href"`
Username *string `json:"username"`
Permissions *Permissions `json:"permissions"`
}
Member contains information about project member with user info and project permission that member has.
type MultipartUpload ¶
type MultipartUpload struct {
Href string `json:"href"`
UploadID string `json:"upload_id"`
Project string `json:"project"`
Name string `json:"name"`
Initiated string `json:"initiated"`
}
MultipartUpload holds information about upload of a file to platform.
type Page ¶
Page is base structure for all paginated responses returned from SevenBridges API.
func NewPage ¶
NewPage creates and returns Page object initialized from provided Response. Link headers from response are read and page information are initialized based on Link header value.
func (*Page) HasNextPage ¶
HasNextPage returns flag indicating if next page exists for paginated resource.
func (*Page) HasPrevPage ¶
HasPrevPage returns flag indicating if previous page exists for paginated resource.
func (*Page) NextPage ¶
func (p *Page) NextPage() *ListOptions
NextPage creates and returns ListOptions for accessing next page of paginated resource.
func (*Page) PrevPage ¶
func (p *Page) PrevPage() *ListOptions
PrevPage creates and returns ListOptions for accessing previous page of paginated resource.
type PartUploadInitResponse ¶
type PartUploadInitResponse struct {
Method string `json:"method"`
URL string `json:"url"`
Expires time.Time `json:"expires"`
Headers map[string]interface{} `json:"headers"`
SuccessCodes []int `json:"success_codes"`
Report map[string]interface{} `json:"report"`
}
PartUploadInitResponse holds API response for upload initialization of a single part request.
type Permissions ¶
type Permissions struct {
Read *bool `json:"read"`
Write *bool `json:"write"`
Copy *bool `json:"copy"`
Execute *bool `json:"execute"`
Admin *bool `json:"admin"`
}
Permissions holds set of permissions of a single user on particular project.
type Project ¶
type Project struct {
Href *string `json:"href"`
ID *string `json:"id"`
Name *string `json:"name"`
Type *string `json:"type"`
BillingGroup *string `json:"billing_group"`
}
Project holds information about project on Seven Bridges platform.
type ProjectCreate ¶
type ProjectCreate struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
BillingGroup *string `json:"billing_group,omitempty"`
}
ProjectCreate is structure that defines body that is required for creating new project on SevenBridges platform.
type ProjectService ¶
type ProjectService interface {
// List returns list of project that current user is member of.
List(ctx context.Context, opt *ListOptions) ([]*Project, *Response, error)
// ListForUser returns all projects owned by accessible to a particular user.
ListForUser(ctx context.Context, username string, opt *ListOptions) ([]*Project, *Response, error)
// ByID Returns project specified by its ID.
ByID(ctx context.Context, projectID string) (*Project, *Response, error)
// Create creates new project with provided information.
Create(ctx context.Context, pc ProjectCreate) (*Project, *Response, error)
// Delete removes project from SBG platform, including all stuff stored in
// project (files, apps, workflows, tasks...).
Delete(ctx context.Context, projectID string) (*Response, error)
// Modify edits project with provided ID with provided data. Not all fields
// for project modification needs to be supplied, only fields that needs to
// be modified.
Modify(ctx context.Context, projectID string, pc ProjectCreate) (*Project, *Response, error)
// Members returns members of provided project
Members(ctx context.Context, projectID string, opt *ListOptions) ([]*Member, *Response, error)
// AddMember adds new member to project with provided ID and member
// information (including permissions).
AddMember(ctx context.Context, projectID string, member *Member) (*Member, *Response, error)
// RemoveMember removes user from project membership.
RemoveMember(ctx context.Context, projectID, username string) (*Response, error)
// GetMember returns member with provided username from project with provided ID.
GetMember(ctx context.Context, projectID, username string) (*Member, *Response, error)
// ChangePermissions updates permissions of a project member in specified
// project. All fields in provided permissions struct has to be filled,
// because any unfilled field will be defaulted to false.
ChangePermissions(ctx context.Context, projectID, username string, permissions Permissions) (*Permissions, *Response, error)
}
ProjectService is interface that defines project related operations available on SevenBridges platform.
type Rate ¶
type Rate struct {
Limit int `json:"limit"`
Remaining int `json:"remaining"`
Reset Timestamp `json:"reset"`
}
Rate tracks info about number of requests sent to SevenBridges server and time when count will be restarted.
type Response ¶
Response is thin wrapper around http.Response holding additional data that might be useful, like query options for next and previous page for paginated responses.
NextPage, PrevPage and TotalMatchingQuery are not guarantied to be populated. It is only populated for paginated responses.
Rate holds information about request rate returned by server for this request.
type SevenBridges ¶
type SevenBridges struct {
User UserService
Project ProjectService
Files FileService
Download DownloadService
Upload UploadService
// contains filtered or unexported fields
}
SevenBridges is main entry point for communicating with SevenBridges API.
func New ¶
func New(baseURL, token string) *SevenBridges
New returns new instance of SevenBridges that can be used to issue requests to Seven Bridges API.
type Timestamp ¶
Timestamp is serialization helper that know how to serialize to and from timestamp format for JSON serialization. It is only alias for time.Time that implements Marshaler and Unmarshaler interfaces so it is always safe to convert it to time.Time if time arithmetics is needed.
func (Timestamp) MarshalJSON ¶
MarshalJSON marshals timestamp to its timestamp value and returns it as byte array.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON unmarshals provided byte array, treats it as a string that contains timestamp and is Unix timestamp of a specific time and populates t with that value.
type UploadInfo ¶
type UploadInfo struct {
// Path is path to file that should be uploaded on local filesystem.
Path string
// Name is desired name of uploaded file. If not provided, same name
// as on local file system will be used.
Name string `json:"name"`
// Overwrite is flag marking if upload should be continued even if file
// with same name exists on platform.
Overwrite bool
// Project is ID of project to which to upload file.
Project string `json:"project"`
// contains filtered or unexported fields
}
UploadInfo holds information about file that is being uploads, its destination and various options.
type UploadInitResponse ¶
type UploadInitResponse struct {
Name string `json:"name"`
Size int64 `json:"size"`
PartSize int64 `json:"part_size"`
ParallelUploads bool `json:"parallel_uploads"`
Href string `json:"href"`
UploadID string `json:"upload_id"`
Project string `json:"project"`
}
UploadInitResponse holds information about upload that is in progress with all necessary information.
type UploadService ¶
type UploadService interface {
// Upload uploads file to SevenBridges platform. Which files is uploaded
// and to which project can be defined in provided options.
Upload(ctx context.Context, info UploadInfo) error
// List returns all ongoing uploads.
List(ctx context.Context) ([]*MultipartUpload, *Response, error)
// About stops upload with provided ID. Note that this has nothing to do
// with current running process, this only aborts upload on server.
// User should be careful which upload it is safe to abort.
Abort(ctx context.Context, uploadID string) (*Response, error)
}
UploadService is a service for uploading files to SevenBridges platform.
type User ¶
type User struct {
Href string `json:"href"`
Username string `json:"username"`
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Affiliation string `json:"affiliation"`
Phone string `json:"phone"`
Address string `json:"address"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
ZipCode string `json:"zip_code"`
}
User holds information about user available on SevenBridges platform.
type UserService ¶
type UserService interface {
// Me returns user information about user whose authentication token has
// been used to communication with SevenBridges API.
Me(ctx context.Context) (*User, *Response, error)
// User returns information about user with provided username.
User(ctx context.Context, username string) (*User, *Response, error)
}
UserService is interface for accessing user information on SevenBridges platform.