subscriptions

package
v0.0.0-...-08e7634 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

/subscriptions

The API response for /subscriptions looks as follows (p.s. the UUIDs are fake, so don't try to hack the planet with these).

If you'd like to make your own API requests, you can follow this guide to get you started.

GET:

https://docs.microsoft.com/en-us/rest/api/subscription/2018-03-01-preview/operations/list

➜ curl -s -X GET -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" "https://management.azure.com/subscriptions?api-version=2020-01-01" | jq .
{
  "value": [
    {
      "id": "/subscriptions/b5549535-3215-4868-a289-f80095c9e718",
      "authorizationSource": "RoleBased",
      "managedByTenants": [],
      "subscriptionId": "b5549535-3215-4868-a289-f80095c9e718",
      "tenantId": "b5549535-3215-4868-a289-f80095c9e718",
      "displayName": "Pay-As-You-Go",
      "state": "Enabled",
      "subscriptionPolicies": {
        "locationPlacementId": "Public_2014-09-01",
        "quotaId": "PayAsYouGo_2014-09-01",
        "spendingLimit": "Off"
      }
    }
  ],
  "count": {
    "type": "Total",
    "value": 1
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PostHandler

func PostHandler(pattern string, subs *[]Subscription) echo.HandlerFunc

PostHandler is the POST method handler for /subscriptions POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription?api-version=2018-11-01-preview 202 Accepted

Response: {
	"subscriptionLink": "/subscriptions/d0d6ee57-6530-4fca-93a6-b755a070be35"
}

Types

type Response

type Response struct {
	Value []Subscription `json:"value"`
	Count struct {
		Type  string `json:"type"`
		Value int    `json:"value"`
	} `json:"count"`
}

Response models the subscription response from the API

func NewResponseStub

func NewResponseStub(subscriptionID string) Response

NewResponseStub takes a string ID and returns a basic SubscriptionResponse object TODO: Support passing multiple subscription IDs

type Service

type Service struct {
	Store *lightdb.Store
}

Service satisfies the Service interface, and is used to start and maintain the Subscription Service

func NewService

func NewService(s *lightdb.Store) *Service

NewService is a factory for the SubscriptionService, which satisfies the services.Service interface and provides a default sub TODO Error handling

func (*Service) AddSubscription

func (svc *Service) AddSubscription(s Subscription) error

AddSubscription takes a subscription and adds it to the store

func (*Service) GetBaseSubscriptionID

func (svc *Service) GetBaseSubscriptionID() string

GetBaseSubscriptionID is a SubscriptionService specific helper that returns the initial subscriptionID

func (*Service) GetHandler

func (svc *Service) GetHandler() echo.HandlerFunc

GetHandler is the GET method handler for /subscriptions

func (*Service) GetHandlers

func (svc *Service) GetHandlers() map[string]services.Handler

GetHandlers returns a map of all HTTP Echo handlers that the service needs in order to operate

func (*Service) GetSubscriptions

func (svc *Service) GetSubscriptions() ([]Subscription, error)

GetSubscriptions returns the Stores state

type Subscription

type Subscription struct {
	ID                   string        `json:"id"`
	AuthorizationSource  string        `json:"authorizationSource"`
	ManagedByTenants     []interface{} `json:"managedByTenants"`
	SubscriptionID       string        `json:"subscriptionId"`
	TenantID             string        `json:"tenantId"`
	DisplayName          string        `json:"displayName"`
	State                string        `json:"state"`
	SubscriptionPolicies struct {
		LocationPlacementID string `json:"locationPlacementId"`
		QuotaID             string `json:"quotaId"`
		SpendingLimit       string `json:"spendingLimit"`
	} `json:"subscriptionPolicies"`
}

Subscription is the object we store in our Inventory grab bag to model a subscription

func NewSubscription

func NewSubscription() Subscription

NewSubscription takes a string ID and returns a basic Subscription object It does this by indirectly using the NewSubscriptionResponse factory for the sake of loading in a JSON stub,

and replacing the SubscriptionID in said stub to constructr our Subscription.

Jump to

Keyboard shortcuts

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