handlers

package
v0.0.0-...-f9f7919 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const AuthUserName string = "_nexodus.UserName"

key for username in gin.Context

View Source
const CacheExp time.Duration = 0

CacheExp Zero expiration means the key has no expiration time.

View Source
const CachePrefix = "user:"
View Source
const SESSION_ID_COOKIE_NAME = "sid"
View Source
const (
	TotalCountHeader = "X-Total-Count"
)

Variables

View Source
var MemberRoles = []string{"owner", "member"}
View Source
var OwnerRoles = []string{"owner"}

Functions

func FilterAndPaginate

func FilterAndPaginate(db *gorm.DB, model interface{}, c *gin.Context, orderBy string) *gorm.DB

func FilterAndPaginateWithQuery

func FilterAndPaginateWithQuery(db *gorm.DB, model interface{}, c *gin.Context, query Query, defaultOrderBy string) *gorm.DB

func KeyUsagesForCertificateOrCertificateRequest

func KeyUsagesForCertificateOrCertificateRequest(isCA bool, usages ...models.KeyUsage) (ku x509.KeyUsage, eku []x509.ExtKeyUsage, err error)

func NewCertPools

func NewCertPools(pemBytes []byte) (*x509.CertPool, *x509.CertPool, error)

NewCertPools creates x509 cert pools from the given PEM bytes.

func NewInternalServerError

func NewInternalServerError(c *gin.Context, logger *zap.SugaredLogger, err error) *models.InternalServerError

func SendInternalServerError

func SendInternalServerError(c *gin.Context, logger *zap.SugaredLogger, err error)

func ValidateCreateSecurityGroupRules

func ValidateCreateSecurityGroupRules(sg models.AddSecurityGroup) error

ValidateCreateSecurityGroupRules validates rules for creating a new security group

func ValidateRule

func ValidateRule(rule models.SecurityRule) error

ValidateRule validates individual rule

func ValidateUpdateSecurityGroupRules

func ValidateUpdateSecurityGroupRules(sg models.UpdateSecurityGroup) error

ValidateUpdateSecurityGroupRules validates rules for updating the security group

func VerifyCertificate

func VerifyCertificate(certPEMBlock []byte, caCertPEMBlock []byte, keyUsages ...x509.ExtKeyUsage) error

Types

type API

type API struct {
	Redis *redis.Client

	URL          string
	URLParsed    *url.URL
	PrivateKey   *rsa.PrivateKey
	Certificates []*x509.Certificate
	SmtpServer   email.SmtpServer
	SmtpFrom     string

	FrontendURL string
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(
	parent context.Context,
	logger *zap.SugaredLogger,
	db *gorm.DB,
	ipam ipam.IPAM,
	fflags *fflags.FFlags,
	store storage.Store,
	signalBus signalbus.SignalBus,
	redis *redis.Client,
	sessionManager *session.Manager,
	caKeyPair CertificateKeyPair,
) (*API, error)

func (*API) AcceptInvitation

func (api *API) AcceptInvitation(c *gin.Context)

AcceptInvitation accepts an invitation @Summary Accept an invitation @Description Accept an invitation to an organization @Id AcceptInvitation @Tags Invitation @Accept json @Produce json @Param id path string true "Invitation ID" @Success 204 @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/invitations/{id}/accept [post]

func (*API) Certs

func (api *API) Certs(c *gin.Context)

Certs gets the jwks that can be used to verify JWTs created by this server. @Summary gets the jwks @Description gets the jwks that can be used to verify JWTs created by this server. @Id Certs @Tags Auth @Accept json @Produce json @Success 200 {object} interface{} @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /device/certs [get]

func (*API) Check

func (api *API) Check(ctx context.Context, checkReq *auth.CheckRequest) (*auth.CheckResponse, error)

Check implements Envoy Authorization service. Proto file: https://github.com/envoyproxy/envoy/blob/main/api/envoy/service/auth/v3/external_auth.proto

We use this to convert the browser cookie to a JWT in the authorization header. This can then be used by envoy to rate limit requests.

func (*API) CreateDevice

func (api *API) CreateDevice(c *gin.Context)

CreateDevice handles adding a new device @Summary Add Devices @Id CreateDevice @Tags Devices @Description Adds a new device @Accept json @Produce json @Param Device body models.AddDevice true "Add Device" @Success 201 {object} models.Device @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 409 {object} models.ConflictsError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices [post]

func (*API) CreateInvitation

func (api *API) CreateInvitation(c *gin.Context)

CreateInvitation creates an invitation @Summary Create an invitation @Description Create an invitation to an organization @Id CreateInvitation @Tags Invitation @Accept json @Produce json @Param Invitation body models.AddInvitation true "Add Invitation" @Success 201 {object} models.Invitation @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/invitations [post]

func (*API) CreateOrganization

func (api *API) CreateOrganization(c *gin.Context)

CreateOrganization creates a new Organization @Summary Create an Organization @Description Creates a named organization with the given CIDR @Id CreateOrganization @Tags Organizations @Accept json @Produce json @Param Organization body models.AddOrganization true "Add Organization" @Success 201 {object} models.Organization @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 405 {object} models.BaseError @Failure 409 {object} models.ConflictsError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/organizations [post]

func (*API) CreateRegKey

func (api *API) CreateRegKey(c *gin.Context)

CreateRegKey creates a RegKey @Summary Create a RegKey @Description Create a RegKey for a vpc @Id CreateRegKey @Tags RegKey @Accept json @Produce json @Param RegKey body models.AddRegKey true "Add RegKey" @Success 201 {object} models.RegKey @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/reg-keys [post]

func (*API) CreateSecurityGroup

func (api *API) CreateSecurityGroup(c *gin.Context)

CreateSecurityGroup handles adding a new SecurityGroup @Summary Add SecurityGroup @Id CreateSecurityGroup @Tags SecurityGroup @Description Adds a new Security Group @Accepts json @Produce json @Param SecurityGroup body models.AddSecurityGroup true "Add SecurityGroup" @Success 201 {object} models.SecurityGroup @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 409 {object} models.ConflictsError @Failure 422 {object} models.ValidationError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/security-groups [post]

func (*API) CreateServiceNetwork

func (api *API) CreateServiceNetwork(c *gin.Context)

CreateServiceNetwork creates a new ServiceNetwork @Summary Create an ServiceNetwork @Description Creates a named serviceNetwork with the given CIDR @Id CreateServiceNetwork @Tags ServiceNetwork @Accept json @Produce json @Param ServiceNetwork body models.AddServiceNetwork true "Add ServiceNetwork" @Success 201 {object} models.ServiceNetwork @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 405 {object} models.BaseError @Failure 409 {object} models.ConflictsError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/service-networks [post]

func (*API) CreateServiceNetworkCertKeyPair

func (api *API) CreateServiceNetworkCertKeyPair(serviceNetwork *models.ServiceNetwork) (string, string, error)

func (*API) CreateSite

func (api *API) CreateSite(c *gin.Context)

CreateSite handles adding a new site @Summary Add Sites @Id CreateSite @Tags Sites @Description Adds a new site @Accept json @Produce json @Param Site body models.AddSite true "Add Site" @Success 201 {object} models.Site @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 409 {object} models.ConflictsError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/sites [post]

func (*API) CreateUserIfNotExists

func (api *API) CreateUserIfNotExists(ctx context.Context, idpId string, userName string, claimsMap map[string]interface{}) (uuid.UUID, error)

func (*API) CreateVPC

func (api *API) CreateVPC(c *gin.Context)

CreateVPC creates a new VPC @Summary Create an VPC @Description Creates a named vpc with the given CIDR @Id CreateVPC @Tags VPC @Accept json @Produce json @Param VPC body models.AddVPC true "Add VPC" @Success 201 {object} models.VPC @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 405 {object} models.BaseError @Failure 409 {object} models.ConflictsError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/vpcs [post]

func (*API) CurrentUserHasRole

func (api *API) CurrentUserHasRole(c *gin.Context, db *gorm.DB, orgIdField string, allowedRoles []string) *gorm.DB

func (*API) DeleteDevice

func (api *API) DeleteDevice(c *gin.Context)

DeleteDevice handles deleting an existing device and associated ipam lease @Summary Delete Device @Description Deletes an existing device and associated IPAM lease @Id DeleteDevice @Tags Devices @Accept json @Produce json @Param id path string true "Device ID" @Success 204 {object} models.Device @Failure 400 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices/{id} [delete]

func (*API) DeleteDeviceMetadata

func (api *API) DeleteDeviceMetadata(c *gin.Context)

DeleteDeviceMetadata Delete all metadata or a specific key on a device @Summary Delete all Device metadata @Id DeleteDeviceMetadata @Tags Devices @Description Delete all metadata for a device @Param id path string true "Device ID" @Success 204 @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices/{id}/metadata [delete]

func (*API) DeleteDeviceMetadataKey

func (api *API) DeleteDeviceMetadataKey(c *gin.Context)

DeleteDeviceMetadataKey Delete all metadata or a specific key on a device @Summary Delete a Device metadata key @Id DeleteDeviceMetadataKey @Tags Devices @Description Delete a metadata key for a device @Param id path string true "Device ID" @Param key path string false "Metadata Key" @Success 204 @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices/{id}/metadata/{key} [delete]

func (*API) DeleteInvitation

func (api *API) DeleteInvitation(c *gin.Context)

DeleteInvitation handles deleting an existing organization and associated ipam prefix @Summary Delete Invitation @Description Deletes an existing invitation @Id DeleteInvitation @Tags Invitation @Accept json @Produce json @Param id path string true "Invitation ID" @Success 204 {object} models.Organization @Failure 400 {object} models.BaseError @Failure 405 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/invitations/{id} [delete]

func (*API) DeleteOrganization

func (api *API) DeleteOrganization(c *gin.Context)

DeleteOrganization handles deleting an existing organization and associated ipam prefix @Summary Delete Organization @Description Deletes an existing organization and associated IPAM prefix @Id DeleteOrganization @Tags Organizations @Accept json @Produce json @Param id path string true "Organization ID" @Success 204 {object} models.Organization @Failure 400 {object} models.BaseError @Failure 405 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/organizations/{id} [delete]

func (*API) DeleteOrganizationUser

func (api *API) DeleteOrganizationUser(c *gin.Context)

DeleteOrganizationUser handles deleting a user from an organization @Summary Delete a Organization User @Description Deletes an existing organization user @Id DeleteOrganizationUser @Tags Organizations @Accept json @Produce json @Param id path string true "Organization ID" @Param uid path string true "User ID" @Success 204 {object} models.UserOrganization @Failure 400 {object} models.ValidationError @Failure 404 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/organizations/{id}/users/{uid} [delete]

func (*API) DeleteRegKey

func (api *API) DeleteRegKey(c *gin.Context)

DeleteRegKey handles deleting a RegKey @Summary Delete RegKey @Description Deletes an existing RegKey @Id DeleteRegKey @Tags RegKey @Accept json @Produce json @Param id path string true "RegKey ID" @Success 204 {object} models.RegKey @Failure 400 {object} models.BaseError @Failure 405 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/reg-keys/{id} [delete]

func (*API) DeleteSecurityGroup

func (api *API) DeleteSecurityGroup(c *gin.Context)

DeleteSecurityGroup handles deleting an existing security group @Summary Delete SecurityGroup @Description Deletes an existing SecurityGroup @Id DeleteSecurityGroup @Tags SecurityGroup @Accepts json @Produce json @Param id path string true "Security Group ID" @Success 204 {object} models.SecurityGroup @Failure 400 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/security-groups/{id} [delete]

func (*API) DeleteServiceNetwork

func (api *API) DeleteServiceNetwork(c *gin.Context)

DeleteServiceNetwork handles deleting an existing serviceNetwork @Summary Delete ServiceNetwork @Description Deletes an existing serviceNetwork @Id DeleteServiceNetwork @Tags ServiceNetwork @Accept json @Produce json @Param id path string true "ServiceNetwork ID" @Success 204 {object} models.ServiceNetwork @Failure 400 {object} models.BaseError @Failure 405 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/service-networks/{id} [delete]

func (*API) DeleteSite

func (api *API) DeleteSite(c *gin.Context)

DeleteSite handles deleting an existing site and associated ipam lease @Summary Delete Site @Description Deletes an existing site and associated IPAM lease @Id DeleteSite @Tags Sites @Accept json @Produce json @Param id path string true "Site ID" @Success 204 {object} models.Site @Failure 400 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/sites/{id} [delete]

func (*API) DeleteUser

func (api *API) DeleteUser(c *gin.Context)

DeleteUser delete a user @Summary Delete User @Description Delete a user @Id DeleteUser @Tags Users @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} models.User @Failure 400 {object} models.ValidationError @Failure 400 {object} models.NotAllowedError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/users/{id} [delete]

func (*API) DeleteUserFromOrganization

func (api *API) DeleteUserFromOrganization(c *gin.Context)

DeleteUserFromOrganization removes a user from an organization @Summary Remove a User from an Organization @Description Deletes an existing organization associated to a user @Id DeleteUserFromOrganization @Tags Users @Accept json @Produce json @Param id path string true "User ID" @Param organization path string true "Organization ID" @Success 204 {object} models.User @Failure 400 {object} models.BaseError @Failure 400 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/users/{id}/organizations/{organization} [delete]

func (*API) DeleteVPC

func (api *API) DeleteVPC(c *gin.Context)

DeleteVPC handles deleting an existing vpc and associated ipam prefix @Summary Delete VPC @Description Deletes an existing vpc and associated IPAM prefix @Id DeleteVPC @Tags VPC @Accept json @Produce json @Param id path string true "VPC ID" @Success 204 {object} models.VPC @Failure 400 {object} models.BaseError @Failure 405 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/vpcs/{id} [delete]

func (*API) DeviceIsOwnedByCurrentUser

func (api *API) DeviceIsOwnedByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) FlagCheck

func (api *API) FlagCheck(c *gin.Context, name string) bool

func (*API) GarbageCollect

func (api *API) GarbageCollect(c *gin.Context)

GarbageCollect cleans up old soft deleted records @Summary Cleans up old soft deleted records @Description Cleans up old soft deleted records @Id GarbageCollect @Tags Private @Accept json @Produce json @Param retention query string false "how long to retain deleted records. defaults to '24h'" @Success 204 @Failure 400 {object} models.ValidationError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /admin/gc [post]

func (*API) GetCurrentUserID

func (api *API) GetCurrentUserID(c *gin.Context) uuid.UUID

func (*API) GetDevice

func (api *API) GetDevice(c *gin.Context)

GetDevice gets a device by ID @Summary Get Devices @Description Gets a device by ID @Id GetDevice @Tags Devices @Accept json @Produce json @Param id path string true "Device ID" @Success 200 {object} models.Device @Failure 401 {object} models.BaseError @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices/{id} [get]

func (*API) GetDeviceMetadataKey

func (api *API) GetDeviceMetadataKey(c *gin.Context)

GetDeviceMetadataKey Get value for a metadata key on a device @Summary Get Device Metadata @Id GetDeviceMetadataKey @Tags Devices @Description Get metadata for a device @Param id path string true "Device ID" @Param key path string true "Metadata Key" @Accept json @Produce json @Success 200 {object} models.DeviceMetadata @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices/{id}/metadata/{key} [get]

func (*API) GetFeatureFlag

func (api *API) GetFeatureFlag(c *gin.Context)

GetFeatureFlag gets a feature flag by name @Summary Get Feature Flag @Description Gets a Feature Flag by name @Id GetFeatureFlag @Tags FFlag @Accept json @Produce json @Param name path string true "feature flag name" @Success 200 {object} map[string]bool @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/fflags/{name} [get]

func (*API) GetInvitation

func (api *API) GetInvitation(c *gin.Context)

GetInvitation gets a specific Invitation @Summary Get Invitation @Description Gets an Invitation by Invitation ID @Id GetInvitation @Tags Invitation @Accept json @Produce json @Param id path string true "Invitation ID" @Success 200 {object} models.Invitation @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/invitations/{id} [get]

func (*API) GetOrganizationUser

func (api *API) GetOrganizationUser(c *gin.Context)

GetOrganizationUser gets a specific Organization User @Summary Get Organization User @Description Gets a Organization User by Organization ID and User ID @Id GetOrganizationUser @Tags Organizations @Accept json @Produce json @Param id path string true "Organization ID" @Param uid path string true "User ID" @Success 200 {object} models.UserOrganization @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/organizations/{id}/users/{uid} [get]

func (*API) GetOrganizations

func (api *API) GetOrganizations(c *gin.Context)

GetOrganizations gets a specific Organization @Summary Get Organizations @Description Gets a Organization by Organization ID @Id GetOrganizations @Tags Organizations @Accept json @Produce json @Param id path string true "Organization ID" @Success 200 {object} models.Organization @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/organizations/{id} [get]

func (*API) GetRegKey

func (api *API) GetRegKey(c *gin.Context)

GetRegKey gets a specific RegKey @Summary Get a RegKey @Description Gets a RegKey by RegKey ID @Id GetRegKey @Tags RegKey @Accept json @Produce json @Param id path string true "RegKey ID" @Success 200 {object} models.RegKey @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/reg-keys/{id} [get]

func (*API) GetSecurityGroup

func (api *API) GetSecurityGroup(c *gin.Context)

GetSecurityGroup gets a Security Group by ID @Summary Get SecurityGroup @Description Gets a security group by ID @Id GetSecurityGroup @Tags SecurityGroup @Accepts json @Produce json @Param id path string true "Security Group ID" @Success 200 {object} models.SecurityGroup @Failure 401 {object} models.BaseError @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/security-groups/{id} [get]

func (*API) GetServiceNetwork

func (api *API) GetServiceNetwork(c *gin.Context)

GetServiceNetwork gets a specific ServiceNetwork @Summary Get ServiceNetworks @Description Gets a ServiceNetwork by ServiceNetwork ID @Id GetServiceNetwork @Tags ServiceNetwork @Accept json @Produce json @Param id path string true "ServiceNetwork ID" @Success 200 {object} models.ServiceNetwork @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/service-networks/{id} [get]

func (*API) GetSite

func (api *API) GetSite(c *gin.Context)

GetSite gets a site by ID @Summary Get Sites @Description Gets a site by ID @Id GetSite @Tags Sites @Accept json @Produce json @Param id path string true "Site ID" @Success 200 {object} models.Site @Failure 401 {object} models.BaseError @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/sites/{id} [get]

func (*API) GetUser

func (api *API) GetUser(c *gin.Context)

GetUser gets a user @Summary Get User @Description Gets a user @Id GetUser @Tags Users @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} models.User @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/users/{id} [get]

func (*API) GetVPC

func (api *API) GetVPC(c *gin.Context)

GetVPC gets a specific VPC @Summary Get VPCs @Description Gets a VPC by VPC ID @Id GetVPC @Tags VPC @Accept json @Produce json @Param id path string true "VPC ID" @Success 200 {object} models.VPC @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/vpcs/{id} [get]

func (*API) InvitationIsForCurrentUser

func (api *API) InvitationIsForCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) InvitationIsForCurrentUserOrOrgOwner

func (api *API) InvitationIsForCurrentUserOrOrgOwner(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) IsMemberOfOrg

func (api *API) IsMemberOfOrg(c *gin.Context, orgId uuid.UUID) (bool, error)

IsMemberOfOrg checks if the current user is a member of the organization, returns true if he is.

func (*API) IsOwnerOfOrg

func (api *API) IsOwnerOfOrg(c *gin.Context, orgId uuid.UUID) (bool, error)

IsOwnerOfOrg checks if the current user is a owner of the organization, returns true if he is.

func (*API) JSONWebKeySet

func (api *API) JSONWebKeySet() ([]byte, error)

func (*API) ListDeviceMetadata

func (api *API) ListDeviceMetadata(c *gin.Context)

ListDeviceMetadata lists metadata for a device @Summary List Device Metadata @Id ListDeviceMetadata @Tags Devices @Description Lists metadata for a device @Param id path string true "Device ID" @Param gt_revision query uint64 false "greater than revision" @Accept json @Produce json @Success 200 {object} []models.DeviceMetadata @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices/{id}/metadata [get]

func (*API) ListDevices

func (api *API) ListDevices(c *gin.Context)

ListDevices lists all devices @Summary List Devices @Description Lists all devices @Id ListDevices @Tags Devices @Accept json @Produce json @Success 200 {object} []models.Device @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices [get]

func (*API) ListDevicesInVPC

func (api *API) ListDevicesInVPC(c *gin.Context)

ListDevicesInVPC lists all devices in an VPC @Summary List Devices @Description Lists all devices for this VPC @Id ListDevicesInVPC @Tags VPC @Accept json @Produce json @Param gt_revision query uint64 false "greater than revision" @Param id path string true "VPC ID" @Success 200 {object} []models.Device @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/vpcs/{id}/devices [get]

func (*API) ListFeatureFlags

func (api *API) ListFeatureFlags(c *gin.Context)

ListFeatureFlags lists all feature flags @Summary List Feature Flags @Description Lists all feature flags @Id ListFeatureFlags @Tags FFlag @Accept json @Produce json @Success 200 {object} map[string]bool @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/fflags [get]

func (*API) ListInvitations

func (api *API) ListInvitations(c *gin.Context)

ListInvitations lists invitations @Summary List Invitations @Description Lists all invitations @Id ListInvitations @Tags Invitation @Accept json @Produce json @Success 200 {object} []models.Invitation @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/invitations [get]

func (*API) ListMetadataInVPC

func (api *API) ListMetadataInVPC(c *gin.Context)

ListMetadataInVPC lists metadata for all devices in the vpc @Summary List Device Metadata @Id ListMetadataInVPC @Tags VPC @Description Lists metadata for a device @Param id path string true "VPC ID" @Param gt_revision query uint64 false "greater than revision" @Param prefix query []string false "used to filter down to the specified key prefixes" @Param key query string false "used to filter down to the specified key" @Accept json @Produce json @Success 200 {object} []models.DeviceMetadata @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/vpcs/{id}/metadata [get]

func (*API) ListOrganizationUsers

func (api *API) ListOrganizationUsers(c *gin.Context)

ListOrganizationUsers lists the users of an organization @Summary List Organization Users @Description Lists all the users of an organization @Id ListOrganizationUsers @Tags Organizations @Accept json @Produce json @Param id path string true "Organization ID" @Success 200 {object} []models.UserOrganization @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/organizations/{id}/users [get]

func (*API) ListOrganizations

func (api *API) ListOrganizations(c *gin.Context)

ListOrganizations lists all Organizations @Summary List Organizations @Description Lists all Organizations @Id ListOrganizations @Tags Organizations @Accept json @Produce json @Success 200 {object} []models.Organization @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/organizations [get]

func (*API) ListRegKeys

func (api *API) ListRegKeys(c *gin.Context)

ListRegKeys lists reg keys @Summary List reg keys @Description Lists all reg keys @Id ListRegKeys @Tags RegKey @Accept json @Produce json @Success 200 {object} []models.RegKey @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/reg-keys [get]

func (*API) ListSecurityGroups

func (api *API) ListSecurityGroups(c *gin.Context)

ListSecurityGroups lists all Security Groups @Summary List Security Groups @Description Lists all Security Groups @Id ListSecurityGroups @Tags SecurityGroup @Accepts json @Produce json @Param gt_revision query uint64 false "greater than revision" @Success 200 {object} []models.SecurityGroup @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/security-groups [get]

func (*API) ListSecurityGroupsInVPC

func (api *API) ListSecurityGroupsInVPC(c *gin.Context)

ListSecurityGroupsInVPC lists all Security Groups in a VPC @Summary List Security Groups in a VPC @Description Lists all Security Groups in a VPC @Id ListSecurityGroupsInVPC @Tags VPC @Accepts json @Produce json @Param gt_revision query uint64 false "greater than revision" @Param id path string true "VPC ID" @Success 200 {object} []models.SecurityGroup @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/vpcs/{id}/security-groups [get]

func (*API) ListServiceNetworks

func (api *API) ListServiceNetworks(c *gin.Context)

ListServiceNetworks lists all ServiceNetworks @Summary List ServiceNetworks @Description Lists all ServiceNetworks @Id ListServiceNetworks @Tags ServiceNetwork @Accept json @Produce json @Success 200 {object} []models.ServiceNetwork @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/service-networks [get]

func (*API) ListSites

func (api *API) ListSites(c *gin.Context)

ListSites lists all sites @Summary List Sites @Description Lists all sites @Id ListSites @Tags Sites @Accept json @Produce json @Success 200 {object} []models.Site @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/sites [get]

func (*API) ListSitesInServiceNetwork

func (api *API) ListSitesInServiceNetwork(c *gin.Context)

ListSitesInServiceNetwork lists all sites in an ServiceNetwork @Summary List Sites @Description Lists all sites for this ServiceNetwork @Id ListSitesInServiceNetwork @Tags ServiceNetwork @Accept json @Produce json @Param gt_revision query uint64 false "greater than revision" @Param id path string true "Service Network ID" @Success 200 {object} []models.Site @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/ServiceNetworks/{id}/sites [get]

func (*API) ListUsers

func (api *API) ListUsers(c *gin.Context)

ListUsers lists users @Summary List Users @Description Lists all users @Id ListUsers @Tags Users @Accept json @Produce json @Success 200 {object} []models.User @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/users [get]

func (*API) ListVPCs

func (api *API) ListVPCs(c *gin.Context)

ListVPCs lists all VPCs @Summary List VPCs @Description Lists all VPCs @Id ListVPCs @Tags VPC @Accept json @Produce json @Success 200 {object} []models.VPC @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/vpcs [get]

func (*API) Live

func (api *API) Live(c *gin.Context)

Live checks if the service is live @Summary Checks if the service is live @Description Checks if the service is live @Id Live @Tags Private @Accept json @Produce json @Success 200 @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /private/live [post]

func (*API) Logger

func (api *API) Logger(ctx context.Context) *zap.SugaredLogger

func (*API) NewInternalServerError

func (api *API) NewInternalServerError(c *gin.Context, err error) *models.InternalServerError

func (*API) OrganizationIsOwnedByCurrentUser

func (api *API) OrganizationIsOwnedByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) OrganizationIsReadableByCurrentUser

func (api *API) OrganizationIsReadableByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) Ready

func (api *API) Ready(c *gin.Context)

Ready checks if the service is ready to accept requests @Summary Checks if the service is ready to accept requests @Description Checks if the service is ready to accept requests @Id Ready @Tags Private @Accept json @Produce json @Success 200 @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /private/ready [post]

func (*API) RegKeyIsForCurrentUser

func (api *API) RegKeyIsForCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) RegKeyIsForCurrentUserOrOrgOwner

func (api *API) RegKeyIsForCurrentUserOrOrgOwner(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) SecurityGroupIsReadableByCurrentUser

func (api *API) SecurityGroupIsReadableByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) SecurityGroupIsWriteableByCurrentUser

func (api *API) SecurityGroupIsWriteableByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) SendEmail

func (api *API) SendEmail(message email.Message) error

func (*API) SendInternalServerError

func (api *API) SendInternalServerError(c *gin.Context, err error)

func (*API) ServiceNetworkIsOwnedByCurrentUser

func (api *API) ServiceNetworkIsOwnedByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) ServiceNetworkIsReadableByCurrentUser

func (api *API) ServiceNetworkIsReadableByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) SignCSR

func (api *API) SignCSR(c *gin.Context)

SignCSR signs a certificate signing request @Summary Signs a certificate signing request @Description Signs a certificate signing request @Id SignCSR @Tags CA @Accept json @Produce json @Param CertificateSigningRequest body models.CertificateSigningRequest true "Certificate signing request" @Success 201 {object} models.CertificateSigningResponse @Failure 400 {object} models.ValidationError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/ca/sign [post]

func (*API) SiteIsOwnedByCurrentUser

func (api *API) SiteIsOwnedByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) UpdateDevice

func (api *API) UpdateDevice(c *gin.Context)

UpdateDevice updates a Device @Summary Update Devices @Description Updates a device by ID @Id UpdateDevice @Tags Devices @Accept json @Produce json @Param id path string true "Device ID" @Param update body models.UpdateDevice true "Device Update" @Success 200 {object} models.Device @Failure 401 {object} models.BaseError @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices/{id} [patch]

func (*API) UpdateDeviceMetadataKey

func (api *API) UpdateDeviceMetadataKey(c *gin.Context)

UpdateDeviceMetadataKey Set value for a metadata key on a device @Summary Set Device Metadata by key @Id UpdateDeviceMetadataKey @Tags Devices @Description Set metadata key for a device @Param id path string true "Device ID" @Param key path string false "Metadata Key" @Param value body any true "Metadata Value" @Accept json @Produce json @Success 200 {object} models.DeviceMetadata @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/devices/{id}/metadata/{key} [put]

func (*API) UpdateRegKey

func (api *API) UpdateRegKey(c *gin.Context)

UpdateRegKey updates a RegKey @Summary Update RegKey @Description Updates a RegKey by ID @Id UpdateRegKey @Tags RegKey @Accepts json @Produce json @Param id path string true "RegKey ID" @Param update body models.UpdateRegKey true "RegKey Update" @Success 200 {object} models.RegKey @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 422 {object} models.ValidationError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/reg-keys/{id} [patch]

func (*API) UpdateSecurityGroup

func (api *API) UpdateSecurityGroup(c *gin.Context)

UpdateSecurityGroup updates a Security Group @Summary Update Security Group @Description Updates a Security Group by ID @Id UpdateSecurityGroup @Tags SecurityGroup @Accepts json @Produce json @Param id path string true "Security Group ID" @Param update body models.UpdateSecurityGroup true "Security Group Update" @Success 200 {object} models.SecurityGroup @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 422 {object} models.ValidationError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/security-groups/{id} [patch]

func (*API) UpdateServiceNetwork

func (api *API) UpdateServiceNetwork(c *gin.Context)

UpdateServiceNetwork updates a ServiceNetwork @Summary Update ServiceNetworks @Description Updates a serviceNetwork by ID @Id UpdateServiceNetwork @Tags ServiceNetwork @Accept json @Produce json @Param id path string true "ServiceNetwork ID" @Param update body models.UpdateServiceNetwork true "ServiceNetwork Update" @Success 200 {object} models.ServiceNetwork @Failure 401 {object} models.BaseError @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/service-networks/{id} [patch]

func (*API) UpdateSite

func (api *API) UpdateSite(c *gin.Context)

UpdateSite updates a Site @Summary Update Sites @Description Updates a site by ID @Id UpdateSite @Tags Sites @Accept json @Produce json @Param id path string true "Site ID" @Param update body models.UpdateSite true "Site Update" @Success 200 {object} models.Site @Failure 401 {object} models.BaseError @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/sites/{id} [patch]

func (*API) UpdateVPC

func (api *API) UpdateVPC(c *gin.Context)

UpdateVPC updates a VPC @Summary Update VPCs @Description Updates a vpc by ID @Id UpdateVPC @Tags VPC @Accept json @Produce json @Param id path string true "VPC ID" @Param update body models.UpdateVPC true "VPC Update" @Success 200 {object} models.VPC @Failure 401 {object} models.BaseError @Failure 400 {object} models.BaseError @Failure 404 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/vpcs/{id} [patch]

func (*API) UserIsCurrentUser

func (api *API) UserIsCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) VPCIsOwnedByCurrentUser

func (api *API) VPCIsOwnedByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) VPCIsReadableByCurrentUser

func (api *API) VPCIsReadableByCurrentUser(c *gin.Context, db *gorm.DB) *gorm.DB

func (*API) WatchEvents

func (api *API) WatchEvents(c *gin.Context)

WatchEvents lets you watch for resource change events @Summary Watch events occurring in the control plane @Description Watches events occurring in the control plane @Id Watch @Tags Events @Accept json @Produce json @Param Watches body []models.Watch true "List of events to watch" @Success 200 {object} models.WatchEvent @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/events [post]

func (*API) WatchEventsInVPC

func (api *API) WatchEventsInVPC(c *gin.Context)

WatchEventsInVPC lets you watch for resource change events @Summary Watch events occurring in the vpc @Description Watches events occurring in the vpc @Id WatchEvents @Tags VPC @Accept json @Produce json @Param public_key query string false "connect as the device with the given public key, device will be considered to be online for the duration of this request" @Param Watches body []models.Watch true "List of events to watch" @Param id path string true "VPC ID" @Success 200 {object} models.WatchEvent @Failure 400 {object} models.BaseError @Failure 401 {object} models.BaseError @Failure 429 {object} models.BaseError @Failure 500 {object} models.InternalServerError "Internal Server Error" @Router /api/vpc/{id}/events [post]

type AgentTracker

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

One of these exists off of the top-level API object.

func New

func New(logger *zap.Logger) (*AgentTracker, error)

func (*AgentTracker) Connected

func (at *AgentTracker) Connected(api *API, c *gin.Context, agentIdPtr *uuid.UUID, fn func())

type ApiResponseError

type ApiResponseError struct {
	Status int
	Body   any
}

func NewApiResponseError

func NewApiResponseError(status int, body any) *ApiResponseError

func NxodusClaims

func NxodusClaims(c *gin.Context, tx *gorm.DB) (*models.NexodusClaims, *ApiResponseError)

func (ApiResponseError) Error

func (e ApiResponseError) Error() string

type CertificateKeyPair

type CertificateKeyPair struct {
	Certificate    *x509.Certificate
	Key            any
	CertificatePem []byte
}

func ParseCertificateKeyPair

func ParseCertificateKeyPair(certPEMBlock, keyPEMBlock []byte) (result CertificateKeyPair, err error)

type Query

type Query struct {
	Sort   string `form:"sort"`
	Filter string `form:"filter"`
	Range  string `form:"range"`
}

func (*Query) GetFilter

func (q *Query) GetFilter() (map[string]interface{}, error)

func (*Query) GetRange

func (q *Query) GetRange() (int, int, error)

func (*Query) GetSort

func (q *Query) GetSort() (string, error)

func (*Query) SetFilter

func (q *Query) SetFilter(f map[string]interface{}) error

type Watch

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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