cadre

package module
v0.0.0-...-ad7ca9c Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: MIT Imports: 15 Imported by: 1

README

= cadre
Matt Nicholls <transientvariable@protonmail.com>
:keywords: golang,schema
:experimental: true
:icons: font
:iconfont-cdn: //cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.1/css/fontawesome.min.css
:imagesdir: docs/image
:sectanchors: true
:source-highlighter: prettify

ifdef::env-github[]
:tip-caption: :bulb:
:note-caption: :information_source:
:important-caption: :heavy_exclamation_mark:
:caution-caption: :fire:
:warning-caption: :warning:
endif::[]

CAUTION: WIP


== Overview

Common schema definitions that define the _shape_ of various things.

== Installation

.Prerequisites
* The link:https://golang.org/dl/[Golang Runtime], version 1.24.x or later

[source%nowrap,bash]
----
❯ go get -u github.com/transientvariable/cadre
----

== License
This project is licensed under the link:LICENSE[MIT License].

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Accessed   *time.Time `json:"accessed,omitempty"`
	Attributes []string   `json:"attributes,omitempty"`
	CID        string     `json:"cid,omitempty"`
	Ctime      *time.Time `json:"ctime,omitempty"`
	Created    *time.Time `json:"created,omitempty"`
	Directory  string     `json:"directory,omitempty"`
	Extension  string     `json:"extension,omitempty"`
	GID        string     `json:"gid,omitempty"`
	Group      string     `json:"group,omitempty"`
	Hash       *ecs.Hash  `json:"hash,omitempty"`
	Inode      string     `json:"inode,omitempty"`
	MimeType   string     `json:"mime_type,omitempty"`
	Mode       string     `json:"mode,omitempty"`
	Mtime      *time.Time `json:"mtime,omitempty"`
	Name       string     `json:"name,omitempty"`
	Owner      string     `json:"owner,omitempty"`
	Path       string     `json:"path,omitempty"`
	Size       int64      `json:"size,omitempty"`
	Type       string     `json:"type,omitempty"`
	UID        string     `json:"uid,omitempty"`
	URL        string     `json:"url,omitempty"`
	// contains filtered or unexported fields

} // @name File

File godoc @Description Represents metadata for a file/object on a local/remote file system or storage service.

func (*File) Content

func (f *File) Content() ([]byte, error)

Content returns the File content. If the size of the File content > 0, then the returned byte slice will be a copy of the content, otherwise it will be the zero value.

func (*File) FileMode

func (f *File) FileMode() gofs.FileMode

FileMode returns the os.FileMode for the File.

func (*File) HashOf

func (f *File) HashOf(alg string) string

HashOf returns the value for the specified hash algorithm for the File.

The zero-value will be returned if the File Hash is nil, the provided algorithm is empty, or does not match one of the algorithms for File.Hash.

func (*File) IsDir

func (f *File) IsDir() bool

IsDir returns whether the File represents a regular file or directory.

func (*File) SetContent

func (f *File) SetContent(c []byte) error

SetContent sets the File content. If the size of the provided content > 0, then File content will be set to a copy.

func (*File) ToMap

func (f *File) ToMap() (map[string]any, error)

ToMap converts the File fields and their values to a map.

type Organization

type Organization struct {
	Active       bool           `json:"active"`
	Created      *time.Time     `json:"created"`
	BillingEmail sql.NullString `json:"billing_email,omitempty"`
	ID           uuid.UUID      `json:"id"`
	Name         string         `json:"name,omitempty"`
	StoragePath  []string       `json:"storage_path,omitempty"`
	Updated      *time.Time     `json:"updated"`
}

Organization defines the properties for an organization.

func (*Organization) String

func (o *Organization) String() string

String returns a string representation of the Organization.

func (*Organization) Validate

func (o *Organization) Validate(result *validation.Result)

Validate performs validation of an Organization.

type OrganizationUser

type OrganizationUser struct {
	OrgID  uuid.UUID `json:"org_id"`
	UserID uuid.UUID `json:"user_id"`
	Role   string    `json:"role"`
}

OrganizationUser ...

func (*OrganizationUser) String

func (o *OrganizationUser) String() string

String returns a string representation of the OrganizationUser.

type Team

type Team struct {
	ID      uuid.UUID  `json:"id"`
	Name    string     `json:"name"`
	Creator uuid.UUID  `json:"creator"`
	Created *time.Time `json:"created"`
	Updated *time.Time `json:"updated"`
}

Team ...

func (*Team) String

func (t *Team) String() string

String returns a human-readable string representation of the Team.

func (*Team) ToMap

func (t *Team) ToMap() (map[string]any, error)

ToMap converts the Team fields and their values to a map.

type TeamUser

type TeamUser struct {
	ID      uuid.UUID  `json:"id"`
	UserID  uuid.UUID  `json:"user_id"`
	TeamID  uuid.UUID  `json:"team_id"`
	Created *time.Time `json:"created"`
	Updated *time.Time `json:"updated"`
}

TeamUser defines the attributes for a single mapping of a User to a Team.

func (*TeamUser) String

func (t *TeamUser) String() string

String returns a human-readable string representation of the TeamUser mapping.

func (*TeamUser) ToMap

func (t *TeamUser) ToMap() (map[string]any, error)

ToMap converts the TeamUser fields and their values to a map.

type User

type User struct {
	Active        bool           `json:"active"`
	Created       *time.Time     `json:"created"`
	DisplayName   sql.NullString `json:"display_name,omitempty"`
	Email         string         `json:"email"`
	EmailVerified bool           `json:"email_verified"`
	FullName      sql.NullString `json:"full_name,omitempty"`
	ID            uuid.UUID      `json:"id"`
	LastLogin     *time.Time     `json:"last_login,omitempty"`
	Updated       *time.Time     `json:"updated"`
}

User defines the properties for a user.

func (*User) String

func (u *User) String() string

String returns a human-readable string representation of the User.

func (*User) ToMap

func (u *User) ToMap() (map[string]any, error)

ToMap converts the User fields and their values to a map.

func (*User) Validate

func (u *User) Validate(result *validation.Result)

Validate performs validation of a User.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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