models

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventGroupJoinRequest     EventType = "GROUP_JOIN_REQUEST"
	EventServiceExpiryRequest EventType = "SERVICE_EXPIRY_REQUEST"
	EventGroupExitRequest     EventType = "GROUP_EXIT_REQUEST"

	EventTypeRequestApproved EventType = "REQUEST_APPROVED"
	EventTypeRequestRejected EventType = "REQUEST_REJECTED"
	EventTypeRequestDeleted  EventType = "REQUEST_DELETED"

	EventCatalogCreate EventType = "CATALOG_CREATE"
	EventCatalogUpdate EventType = "CATALOG_UPDATE"
	EventCatalogDelete EventType = "CATALOG_DELETE"
	EventCatalogRetire EventType = "CATALOG_RETIRE"

	EventServiceCreate EventType = "SERVICE_CREATE"
	EventServiceUpdate EventType = "SERVICE_UPDATE"
	EventServiceDelete EventType = "SERVICE_DELETE"

	EventLogLevelINFO  EventLogLevel = "INFO"
	EventLogLevelERROR EventLogLevel = "ERROR"
)
View Source
const (
	RequestStateNew            RequestStateType = "NEW"
	RequestStateApproved       RequestStateType = "APPROVED"
	RequestStateRejected       RequestStateType = "REJECTED"
	RequestAddToGroup          RequestType      = "GROUP"
	RequestExitFromGroup       RequestType      = "GROUP_EXIT"
	RequestExtendServiceExpiry RequestType      = "SERVICE_EXPIRY"
)

Variables

View Source
var ExcludeGroups []string

ExcludeGroups is a list of groups to exclude from the list of groups

Functions

func IsMemberOfGroup added in v0.3.0

func IsMemberOfGroup(ctx context.Context, name string) bool

Types

type Capacity

type Capacity struct {
	CPU    float64 `json:"cpu" bson:"cpu,omitempty"`
	Memory int     `json:"memory" bson:"memory,omitempty"`
}

type Catalog

type Catalog struct {
	ID          string        `json:"id"`
	Type        string        `json:"type"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Capacity    Capacity      `json:"capacity"`
	Retired     bool          `json:"retired"`
	Expiry      int           `json:"expiry"`
	VM          VM            `json:"vm"`
	Status      CatalogStatus `json:"status"`
}

type CatalogStatus

type CatalogStatus struct {
	Ready   bool   `json:"ready"`
	Message string `json:"message,omitempty"`
}

type Event added in v0.3.0

type Event struct {
	// ID is the event identifier
	ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	// EventType is the event type
	Type EventType `json:"type" bson:"type"`
	// CreatedAt is the time the event was created
	CreatedAt time.Time `json:"created_at" bson:"created_at"`
	// Originator is the user that created the event
	Originator string `json:"originator" bson:"originator"`
	// UserID is the user that the event is about
	UserID string `json:"user_id" bson:"user_id"`
	// UserEmail is the user email that the event is about
	UserEmail string `json:"user_email" bson:"user_email"`
	// Notify is a flag to indicate if the user should be notified
	Notify bool `json:"notify" bson:"notify"`
	// NotifyAdmin is a flag to indicate if the admin should be notified
	NotifyAdmin bool `json:"notify_admin" bson:"notify_admin"`
	// Notified is a flag to indicate if the user has been notified
	Notified bool `json:"notified" bson:"notified"`
	// Log contains all the event information
	Log EventLog `json:"log" bson:"log"`
}

func NewEvent added in v0.3.0

func NewEvent(ctx context.Context, userid, originator string, typ EventType) (*Event, error)

func (*Event) ComposeMailBody added in v0.3.0

func (e *Event) ComposeMailBody() (string, error)

func (*Event) SetLog added in v0.3.0

func (e *Event) SetLog(level EventLogLevel, message string)

func (*Event) SetNotified added in v0.3.0

func (e *Event) SetNotified(b bool)

SetNotified sets the notified flag

func (*Event) SetNotifiyBoth added in v0.3.0

func (e *Event) SetNotifiyBoth()

SetNotifiyBoth sets both Notify and NotifyAdmin to true

func (*Event) SetNotify added in v0.3.0

func (e *Event) SetNotify()

SetNotify sets the notify flag

func (*Event) SetNotifyAdmin added in v0.3.0

func (e *Event) SetNotifyAdmin()

SetNotifyAdmin sets the notify admin flag

func (*Event) SetType added in v0.3.0

func (e *Event) SetType(t EventType)

SetType sets the event type

func (*Event) SetUserID added in v0.3.0

func (e *Event) SetUserID(id string)

SetUserID sets the user id

type EventLog added in v0.3.0

type EventLog struct {
	Level   EventLogLevel `json:"level" bson:"level"`
	Message string        `json:"message" bson:"message"`
}

type EventLogLevel added in v0.3.0

type EventLogLevel string

type EventResponse added in v0.3.0

type EventResponse struct {
	// TotalPages is the total number of pages
	TotalPages int64 `json:"total_pages"`
	// TotalItems is the total number of items
	TotalItems int64 `json:"total_items"`
	// Events is the list of events
	Events []Event `json:"events"`
	// Links contains the links for the current page, next page and last page
	Links Links `json:"links"`
}

type EventType added in v0.3.0

type EventType string

type Group

type Group struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// Membership is a flag to indicate if the user is a member of the group
	Membership bool     `json:"membership"`
	Quota      Capacity `json:"quota"`
}

type GroupAdmission

type GroupAdmission struct {
	GroupID   string `json:"group_id" bson:"group_id,omitempty"`
	Group     string `json:"group" bson:"group,omitempty"`
	Requester string `json:"requester" bson:"requester,omitempty"`
}

type Key

type Key struct {
	ID      primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	UserID  string             `json:"user_id" bson:"user_id,omitempty"`
	Name    string             `json:"name" bson:"name,omitempty"`
	Content string             `json:"content" bson:"content,omitempty"`
}

func GetNewKey

func GetNewKey() Key
type Links struct {
	// Get the current page link
	Self string `json:"self"`
	// Get the next page link
	Next string `json:"next,omitempty"`
	// Get the last page link
	Last string `json:"last,omitempty"`
}

type NewRequest

type NewRequest struct {
	Justification string `json:"justification"`
}

func GetNewRequest

func GetNewRequest() NewRequest

type Quota

type Quota struct {
	ID       primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	GroupID  string             `json:"group_id" bson:"group_id"`
	Capacity Capacity           `json:"capacity" bson:"capacity"`
}

type Request

type Request struct {
	ID             primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	UserID         string             `json:"user_id" bson:"user_id,omitempty"`
	Justification  string             `json:"justification" bson:"justification,omitempty"`
	Comment        string             `json:"comment" bson:"comment,omitempty"`
	CreatedAt      time.Time          `json:"created_at" bson:"created_at,omitempty"`
	State          RequestStateType   `json:"state" bson:"state,omitempty"`
	RequestType    RequestType        `json:"type" bson:"type,omitempty"`
	GroupAdmission *GroupAdmission    `json:"group,omitempty" bson:"group,omitempty"`
	ServiceExpiry  *ServiceExpiry     `json:"service,omitempty" bson:"service,omitempty"`
}

func GetRequest

func GetRequest() Request

func GetRequests

func GetRequests() []Request

type RequestStateType

type RequestStateType string

type RequestType

type RequestType string

type Service

type Service struct {
	ID          string        `json:"id"`
	UserID      string        `json:"user_id"`
	Name        string        `json:"name"`
	DisplayName string        `json:"display_name"`
	CatalogName string        `json:"catalog_name"`
	Expiry      time.Time     `json:"expiry"`
	Status      ServiceStatus `json:"status"`
}

Service will have the details of the user provisioned service from catalog

type ServiceExpiry

type ServiceExpiry struct {
	Name   string    `json:"name" bson:"name,omitempty"`
	Expiry time.Time `json:"expiry" bson:"expiry,omitempty"`
}

type ServiceStatus

type ServiceStatus struct {
	State      string `json:"state"`
	Message    string `json:"message"`
	AccessInfo string `json:"access_info"`
}

type User

type User struct {
	ID        string   `json:"id"`
	Username  string   `json:"username"`
	FirstName string   `json:"firstname"`
	LastName  string   `json:"lastname"`
	Email     string   `json:"email"`
	Groups    []string `json:"groups"`
}

type VM

type VM struct {
	CRN           string   `json:"crn"`
	ProcessorType string   `json:"processor_type"`
	SystemType    string   `json:"system_type"`
	Image         string   `json:"image"`
	Network       string   `json:"network"`
	Capacity      Capacity `json:"capacity"`
}

Jump to

Keyboard shortcuts

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