api: google.golang.org/api/google-api-go-generator/internal/disco Index | Files

package disco

import "google.golang.org/api/google-api-go-generator/internal/disco"

Package disco represents Google API discovery documents.

Index

Package Files

disco.go

type Auth Uses

type Auth struct {
    OAuth2Scopes []Scope
}

Auth represents the auth section of a discovery document. Only OAuth2 information is retained.

func (*Auth) UnmarshalJSON Uses

func (a *Auth) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Document Uses

type Document struct {
    ID                string             `json:"id"`
    Name              string             `json:"name"`
    Version           string             `json:"version"`
    Title             string             `json:"title"`
    RootURL           string             `json:"rootUrl"`
    ServicePath       string             `json:"servicePath"`
    BasePath          string             `json:"basePath"`
    DocumentationLink string             `json:"documentationLink"`
    Auth              Auth               `json:"auth"`
    Features          []string           `json:"features"`
    Methods           MethodList         `json:"methods"`
    Schemas           map[string]*Schema `json:"schemas"`
    Resources         ResourceList       `json:"resources"`
}

A Document is an API discovery document.

func NewDocument Uses

func NewDocument(bytes []byte) (*Document, error)

NewDocument unmarshals the bytes into a Document. It also validates the document to make sure it is error-free.

type Kind Uses

type Kind int

Kind classifies a Schema.

const (
    // SimpleKind is the category for any JSON Schema that maps to a
    // primitive Go type: strings, numbers, booleans, and "any" (since it
    // maps to interface{}).
    SimpleKind Kind = iota

    // StructKind is the category for a JSON Schema that declares a JSON
    // object without any additional (arbitrary) properties.
    StructKind

    // MapKind is the category for a JSON Schema that declares a JSON
    // object with additional (arbitrary) properties that have a non-"any"
    // schema type.
    MapKind

    // AnyStructKind is the category for a JSON Schema that declares a
    // JSON object with additional (arbitrary) properties that can be any
    // type.
    AnyStructKind

    // ArrayKind is the category for a JSON Schema that declares an
    // "array" type.
    ArrayKind

    // ReferenceKind is the category for a JSON Schema that is a reference
    // to another JSON Schema.  During code generation, these references
    // are resolved using the API.schemas map.
    // See https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.28
    // for more details on the format.
    ReferenceKind
)

type MediaUpload Uses

type MediaUpload struct {
    Accept    []string
    MaxSize   string
    Protocols map[string]Protocol
}

type Method Uses

type Method struct {
    Name                  string
    ID                    string
    Path                  string
    HTTPMethod            string
    Description           string
    Parameters            ParameterList
    ParameterOrder        []string
    Request               *Schema
    Response              *Schema
    Scopes                []string
    MediaUpload           *MediaUpload
    SupportsMediaDownload bool

    JSONMap map[string]interface{} `json:"-"`
}

A Method holds information about a resource method.

func (*Method) UnmarshalJSON Uses

func (m *Method) UnmarshalJSON(data []byte) error

type MethodList Uses

type MethodList []*Method

func (*MethodList) UnmarshalJSON Uses

func (ml *MethodList) UnmarshalJSON(data []byte) error

type Parameter Uses

type Parameter struct {
    Name string
    Schema
    Required bool
    Repeated bool
    Location string
}

A Parameter holds information about a method parameter.

type ParameterList Uses

type ParameterList []*Parameter

func (*ParameterList) UnmarshalJSON Uses

func (pl *ParameterList) UnmarshalJSON(data []byte) error

type Property Uses

type Property struct {
    Name   string
    Schema *Schema
}

type PropertyList Uses

type PropertyList []*Property

func (*PropertyList) UnmarshalJSON Uses

func (pl *PropertyList) UnmarshalJSON(data []byte) error

type Protocol Uses

type Protocol struct {
    Multipart bool
    Path      string
}

type Resource Uses

type Resource struct {
    Name      string
    FullName  string // {parent.FullName}.{Name}
    Methods   MethodList
    Resources ResourceList
}

A Resource holds information about a Google API Resource.

type ResourceList Uses

type ResourceList []*Resource

func (*ResourceList) UnmarshalJSON Uses

func (rl *ResourceList) UnmarshalJSON(data []byte) error

type Schema Uses

type Schema struct {
    ID                   string // union types not supported
    Type                 string // union types not supported
    Format               string
    Description          string
    Properties           PropertyList
    ItemSchema           *Schema `json:"items"` // array of schemas not supported
    AdditionalProperties *Schema // boolean not supported
    Ref                  string  `json:"$ref"`
    Default              string
    Pattern              string
    Enums                []string `json:"enum"`
    // Google extensions to JSON Schema
    EnumDescriptions []string
    Variant          *Variant

    RefSchema *Schema `json:"-"` // Schema referred to by $ref
    Name      string  `json:"-"` // Schema name, if top level
    Kind      Kind    `json:"-"`
}

A Schema holds a JSON Schema as defined by https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1. We only support the subset of JSON Schema needed for Google API generation.

func (*Schema) ElementSchema Uses

func (s *Schema) ElementSchema() *Schema

ElementSchema returns the schema for the element type of s. For maps, this is the schema of the map values. For arrays, it is the schema of the array item type.

ElementSchema panics if called on a schema that is not of kind map or array.

func (*Schema) IsIntAsString Uses

func (s *Schema) IsIntAsString() bool

IsIntAsString reports whether the schema represents an integer value formatted as a string.

type Scope Uses

type Scope struct {
    URL         string
    Description string
}

A Scope is an OAuth2 scope.

type Variant Uses

type Variant struct {
    Discriminant string
    Map          []*VariantMapItem
}

type VariantMapItem Uses

type VariantMapItem struct {
    TypeValue string `json:"type_value"`
    Ref       string `json:"$ref"`
}

Package disco imports 5 packages (graph) and is imported by 4 packages. Updated 2019-06-26. Refresh now. Tools for package owners.