dash

package
v0.0.0-...-4dafefa Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

Device

PANTAHUB Dash

Start Service

Start your server:

./pantahub-serv

Login

TOKEN=`http localhost:12365/auth/login username=user1 password=user1 | json token`

... will store access token in TOKEN for requests below

Get Dash Content

http localhost:12365/dash/ Authorization:" Bearer $TOKEN"
HTTP/1.1 200 OK
Content-Length: 1239
Content-Type: application/json; charset=utf-8
Date: Wed, 12 Jul 2017 15:35:08 GMT
X-Powered-By: go-json-rest

{
    "nick": "user1",
    "prn": "prn:pantahub.com:auth:/user1",
    "subscription": {
        "billing": {
            "AmountDue": 0,
            "Currency": "USD",
            "Type": "Monthly",
            "VatRegion": "World"
        },
        "plan-id": "AlphaTester",
        "quota-stats": {
            "BANDWIDTH": {
                "Actual": 0,
                "Max": 5,
                "Name": "BANDWIDTH",
                "Unit": "GiB"
            },
            "BILLINGPERIOD": {
                "Actual": 0,
                "Max": 30,
                "Name": "BILLINGPERIOD",
                "Unit": "Days"
            },
            "DEVICES": {
                "Actual": 12,
                "Max": 25,
                "Name": "DEVICES",
                "Unit": "Piece"
            },
            "OBJECTS": {
                "Actual": 0,
                "Max": 5,
                "Name": "OBJECTS",
                "Unit": "GiB"
            }
        }
    },
    "top-devices": [
        {
            "message": "Device changed at 2017-06-30 00:19:26.79 +0200 CEST",
            "nick": "honest_collie",
            "prn": "prn:::devices:/5947ca58c4a28b000e8204f4",
            "type": "INFO"
        },
        {
            "message": "Device changed at 2017-06-21 13:42:39.484 +0200 CEST",
            "nick": "polished_stallion",
            "prn": "prn:::devices:/5947c794c4a28b000e82048b",
            "type": "INFO"
        },
        {
            "message": "Device changed at 2017-06-19 19:36:56.974 +0200 CEST",
            "nick": "bursting_manatee",
            "prn": "prn:::devices:/593821ddeb775d2154a4d7c2",
            "type": "INFO"
        },
        {
            "message": "Device changed at 2017-06-19 19:36:41.096 +0200 CEST",
            "nick": "refined_walleye",
            "prn": "prn:::devices:/593d7f67eb775d2154a4f2e3",
            "type": "INFO"
        },
        {
            "message": "Device changed at 2017-06-19 19:36:19.71 +0200 CEST",
            "nick": "nice_pangolin",
            "prn": "prn:::devices:/591b6cc27a6e8e197041e83a",
            "type": "INFO"
        }
    ]
}

Documentation

Index

Constants

View Source
const (
	// QuotaObjects type of quota used by objects
	QuotaObjects = QuotaType("OBJECTS")

	// QuotaBandwidth type of quota used by bandwith metrics
	QuotaBandwidth = QuotaType("BANDWIDTH")

	// QuotaDevices type of quota used by devices
	QuotaDevices = QuotaType("DEVICES")

	// QuotaBillingDays type of quota used for billing period
	QuotaBillingDays = QuotaType("BILLINGPERIOD")
)

Variables

View Source
var (
	// StandardBilling default billing info for standard plans
	StandardBilling = BillingInfo{
		Type:      "Monthly",
		AmountDue: 0,
		Currency:  "USD",
		VatRegion: "World",
	}

	// StandardPlans define standard plans
	StandardPlans = map[string]Plan{
		"AlphaTester": {
			Name: "AlphaTester",
			Quotas: map[QuotaType]Quota{
				QuotaObjects: {
					Name: QuotaObjects,
					Max:  2,
					Unit: "GiB",
				},
				QuotaBandwidth: {
					Name: QuotaBandwidth,
					Max:  2,
					Unit: "GiB",
				},
				QuotaDevices: {
					Name: QuotaDevices,
					Max:  25,
					Unit: "Piece",
				},
				QuotaBillingDays: {
					Name: QuotaBillingDays,
					Max:  30,
					Unit: "Days",
				},
			},
			Billing: BillingInfo{
				Type:      "Monthly",
				AmountDue: 0,
				Currency:  "USD",
				VatRegion: "World",
			},
		},
		"VIP": {
			Name: "VIP",
			Quotas: map[QuotaType]Quota{
				QuotaObjects: {
					Name: QuotaObjects,
					Max:  25,
					Unit: "GiB",
				},
				QuotaBandwidth: {
					Name: QuotaBandwidth,
					Max:  50,
					Unit: "GiB",
				},
				QuotaDevices: {
					Name: QuotaDevices,
					Max:  100,
					Unit: "Piece",
				},
				QuotaBillingDays: {
					Name: QuotaBillingDays,
					Max:  30,
					Unit: "Days",
				},
			},
			Billing: BillingInfo{
				Type:      "Monthly",
				AmountDue: 0,
				Currency:  "USD",
				VatRegion: "World",
			},
		},
	}
)

Functions

This section is empty.

Types

type App

type App struct {
	API *rest.Api
	// contains filtered or unexported fields
}

App define a new rest application for dash

func New

func New(jwtMiddleware *jwt.JWTMiddleware,
	subService subscriptions.SubscriptionService,
	mongoClient *mongo.Client) *App

New create a dash rest application

type BillingInfo

type BillingInfo struct {
	Type      string
	AmountDue float32
	Currency  string
	VatRegion string
}

BillingInfo billing information, how amount to be charged, current and vat

type DeviceInfo

type DeviceInfo struct {
	DeviceID     string    `json:"device-id"`
	Nick         string    `json:"nick"`
	Prn          string    `json:"prn"`
	Message      string    `json:"message"`
	Type         string    `json:"type"`
	Status       string    `json:"status"`
	LastActivity time.Time `json:"last-activity"`
}

DeviceInfo define the payload for device information

type DiskQuotaUsageResult

type DiskQuotaUsageResult struct {
	ID    string  `json:"id" bson:"_id"`
	Total float64 `json:"total"`
}

DiskQuotaUsageResult define disk usage metrics

type ModelError

type ModelError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ModelError error payload (code, message)

type Plan

type Plan struct {
	Name    string
	Quotas  map[QuotaType]Quota
	Billing BillingInfo
}

Plan definition of a billing plan

type PlanQuotas

type PlanQuotas map[QuotaType]QuotaValue

PlanQuotas map with thefinitions of all plans

type Quota

type Quota struct {
	Name   QuotaType
	Actual float64
	Max    float64
	Unit   string
}

Quota definition of a quota

type QuotaType

type QuotaType string

QuotaType type of quota

type QuotaValue

type QuotaValue string

QuotaValue quota value

type SubscriptionInfo

type SubscriptionInfo struct {
	PlanID     string              `json:"plan-id"`
	Billing    BillingInfo         `json:"billing"`
	QuotaStats map[QuotaType]Quota `json:"quota-stats"`
}

SubscriptionInfo subscription information

type Summary

type Summary struct {
	Prn        string           `json:"prn"`
	Nick       string           `json:"nick"`
	Sub        SubscriptionInfo `json:"subscription"`
	TopDevices []DeviceInfo     `json:"top-devices"`
}

Summary user dashboard summary including their top devices and subscription

Jump to

Keyboard shortcuts

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