design

package
v0.0.0-...-284eadf Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package design contains the generic API machinery code of our adder API generated using goa framework. This generated API accepts HTTP GET/POST/PATCH/PUT/DELETE requests from multiple clients.

Index

Constants

This section is empty.

Variables

View Source
var AuthStatus = a.MediaType("application/vnd.status+json", func() {
	a.Description("The status of the current running instance")
	a.Attributes(func() {
		a.Attribute("commit", d.String, "Commit SHA this build is based on")
		a.Attribute("buildTime", d.String, "The time when built")
		a.Attribute("startTime", d.String, "The time when started")
		a.Attribute("error", d.String, "The error if any")
		a.Required("commit", "buildTime", "startTime")
	})
	a.View("default", func() {
		a.Attribute("commit")
		a.Attribute("buildTime")
		a.Attribute("startTime")
		a.Attribute("error")
	})
})

AuthStatus defines the status of the current running Auth instance

View Source
var AuthToken = a.MediaType("application/vnd.authtoken+json", func() {
	a.TypeName("AuthToken")
	a.Description("JWT Token")
	a.Attributes(func() {
		a.Attribute("token", tokenData)
		a.Required("token")
	})
	a.View("default", func() {
		a.Attribute("token")
	})
})

AuthToken represents an authentication JWT Token

View Source
var JSONAPIError = a.Type("JSONAPIError", func() {
	a.Description(`Error objects provide additional information about problems encountered while
performing an operation. Error objects MUST be returned as an array keyed by errors in the
top level of a JSON API document.

See. also http://jsonapi.org/format/#error-objects.`)

	a.Attribute("id", d.String, "a unique identifier for this particular occurrence of the problem.")
	a.Attribute("links", a.HashOf(d.String, JSONAPILink), `a links object containing the following members:
* about: a link that leads to further details about this particular occurrence of the problem.`)
	a.Attribute("status", d.String, "the HTTP status code applicable to this problem, expressed as a string value.")
	a.Attribute("code", d.String, "an application-specific error code, expressed as a string value.")
	a.Attribute("title", d.String, `a short, human-readable summary of the problem that SHOULD NOT
change from occurrence to occurrence of the problem, except for purposes of localization.`)
	a.Attribute("detail", d.String, `a human-readable explanation specific to this occurrence of the problem.
Like title, this field’s value can be localized.`)
	a.Attribute("source", a.HashOf(d.String, d.Any), `an object containing references to the source of the error,
optionally including any of the following members

* pointer: a JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object,
           or "/data/attributes/title" for a specific attribute].
* parameter: a string indicating which URI query parameter caused the error.`)
	a.Attribute("meta", a.HashOf(d.String, d.Any), "a meta object containing non-standard meta-information about the error")

	a.Required("detail")
})

JSONAPIError represents a JSONAPI error object (see http://jsonapi.org/format/#error-objects)

View Source
var JSONAPIErrors = a.MediaType("application/vnd.jsonapierrors+json", func() {
	a.UseTrait("jsonapi-media-type")
	a.TypeName("JSONAPIErrors")
	a.Description(``)
	a.Attributes(func() {
		a.Attribute("errors", a.ArrayOf(JSONAPIError))
		a.Required("errors")
	})
	a.View("default", func() {
		a.Attribute("errors")
		a.Required("errors")
	})
})

JSONAPIErrors is an array of JSONAPI error objects

View Source
var JSONAPILink = a.Type("JSONAPILink", func() {
	a.Description(`See also http://jsonapi.org/format/#document-links.`)
	a.Attribute("href", d.String, "a string containing the link's URL.", func() {
		a.Example("http://example.com/articles/1/comments")
	})
	a.Attribute("meta", a.HashOf(d.String, d.Any), "a meta object containing non-standard meta-information about the link.")
})

JSONAPILink represents a JSONAPI link object (see http://jsonapi.org/format/#document-links)

View Source
var PublicKeys = a.MediaType("application/vnd.publickeys+json", func() {
	a.TypeName("PublicKeys")
	a.Description("Public Keys")
	a.Attributes(func() {
		a.Attribute("keys", a.ArrayOf(d.Any))
		a.Required("keys")
	})
	a.View("default", func() {
		a.Attribute("keys")
	})
})

PublicKeys represents an public keys payload

View Source
var ResourceMedia = a.MediaType("application/vnd.resource+json", func() {
	a.Description("A Protected Resource")
	a.Attributes(func() {
		a.Attribute("resource_scopes", a.ArrayOf(d.String), "The valid scopes for this resource")
		a.Attribute("icon_uri", d.String, "The URI containing the icon for the resource")
		a.Attribute("name", d.String, "The name of the resource")
		a.Attribute("type", d.String, "The type of resource")
		a.Attribute("parent_resource_id", d.String, "The parent resource (of the same type) to which this resource belongs")
		a.Attribute("resource_id", d.String, "The identifier for this resource. If left blank, one will be generated")
		a.Required("name", "type")
	})
	a.View("default", func() {
		a.Attribute("resource_scopes")
		a.Attribute("icon_uri")
		a.Attribute("name")
		a.Attribute("type")
		a.Attribute("parent_resource_id")
		a.Attribute("resource_id")
	})
})

ResourceMedia represents a protected resource

Functions

func JSONList

func JSONList(name, description string, data *d.UserTypeDefinition, links *d.UserTypeDefinition, meta *d.UserTypeDefinition) *d.MediaTypeDefinition

JSONList creates a UserTypeDefinition

func JSONResourceObject

func JSONResourceObject(name string, attributes *d.UserTypeDefinition, relationships *d.UserTypeDefinition) *d.UserTypeDefinition

JSONResourceObject creates a single resource object

func JSONSingle

func JSONSingle(name, description string, data *d.UserTypeDefinition, links *d.UserTypeDefinition) *d.MediaTypeDefinition

JSONSingle creates a Single

Types

This section is empty.

Jump to

Keyboard shortcuts

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