meta

package
v0.0.0-...-e117400 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package meta contains the meta description of the GCE cloud types to generate code for.

Index

Constants

View Source
const (
	// Zonal key type.
	Zonal = "zonal"
	// Regional key type.
	Regional = "regional"
	// Global key type.
	Global = "global"
)
View Source
const (
	// NoGet prevents the Get() method from being generated.
	NoGet = 1 << iota
	// NoList prevents the List() method from being generated.
	NoList = 1 << iota
	// NoDelete prevents the Delete() method from being generated.
	NoDelete = 1 << iota
	// NoInsert prevents the Insert() method from being generated.
	NoInsert = 1 << iota
	// CustomOps specifies that an empty interface xxxOps will be generated to
	// enable custom method calls to be attached to the generated service
	// interface.
	CustomOps = 1 << iota
	// AggregatedList will generated a method for AggregatedList().
	AggregatedList = 1 << iota

	// ReadOnly specifies that the given resource is read-only and should not
	// have insert() or delete() methods generated for the wrapper.
	ReadOnly = NoDelete | NoInsert

	// VersionGA is the API version in compute.v1.
	VersionGA Version = "ga"
	// VersionAlpha is the API version in computer.v0.alpha.
	VersionAlpha Version = "alpha"
	// VersionBeta is the API version in computer.v0.beta.
	VersionBeta Version = "beta"
)

Variables

View Source
var AllServices = []*ServiceInfo{
	&ServiceInfo{
		Object:      "Address",
		Service:     "Addresses",
		Resource:    "addresses",
		keyType:     Regional,
		serviceType: reflect.TypeOf(&ga.AddressesService{}),
	},
	&ServiceInfo{
		Object:      "Address",
		Service:     "Addresses",
		Resource:    "addresses",
		version:     VersionAlpha,
		keyType:     Regional,
		serviceType: reflect.TypeOf(&alpha.AddressesService{}),
	},
	&ServiceInfo{
		Object:      "Address",
		Service:     "Addresses",
		Resource:    "addresses",
		version:     VersionBeta,
		keyType:     Regional,
		serviceType: reflect.TypeOf(&beta.AddressesService{}),
	},
	&ServiceInfo{
		Object:      "Address",
		Service:     "GlobalAddresses",
		Resource:    "addresses",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.GlobalAddressesService{}),
	},
	&ServiceInfo{
		Object:      "BackendService",
		Service:     "BackendServices",
		Resource:    "backendServices",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.BackendServicesService{}),
		additionalMethods: []string{
			"GetHealth",
			"Update",
		},
	},
	&ServiceInfo{
		Object:            "BackendService",
		Service:           "BackendServices",
		Resource:          "backendServices",
		version:           VersionAlpha,
		keyType:           Global,
		serviceType:       reflect.TypeOf(&alpha.BackendServicesService{}),
		additionalMethods: []string{"Update"},
	},
	&ServiceInfo{
		Object:      "BackendService",
		Service:     "RegionBackendServices",
		Resource:    "backendServices",
		version:     VersionAlpha,
		keyType:     Regional,
		serviceType: reflect.TypeOf(&alpha.RegionBackendServicesService{}),
		additionalMethods: []string{
			"GetHealth",
			"Update",
		},
	},
	&ServiceInfo{
		Object:      "Disk",
		Service:     "Disks",
		Resource:    "disks",
		keyType:     Zonal,
		serviceType: reflect.TypeOf(&ga.DisksService{}),
	},
	&ServiceInfo{
		Object:      "Disk",
		Service:     "Disks",
		Resource:    "disks",
		version:     VersionAlpha,
		keyType:     Zonal,
		serviceType: reflect.TypeOf(&alpha.DisksService{}),
	},
	&ServiceInfo{
		Object:      "Disk",
		Service:     "RegionDisks",
		Resource:    "disks",
		version:     VersionAlpha,
		keyType:     Regional,
		serviceType: reflect.TypeOf(&alpha.DisksService{}),
	},
	&ServiceInfo{
		Object:      "Firewall",
		Service:     "Firewalls",
		Resource:    "firewalls",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.FirewallsService{}),
		additionalMethods: []string{
			"Update",
		},
	},
	&ServiceInfo{
		Object:      "ForwardingRule",
		Service:     "ForwardingRules",
		Resource:    "forwardingRules",
		keyType:     Regional,
		serviceType: reflect.TypeOf(&ga.ForwardingRulesService{}),
	},
	&ServiceInfo{
		Object:      "ForwardingRule",
		Service:     "ForwardingRules",
		Resource:    "forwardingRules",
		version:     VersionAlpha,
		keyType:     Regional,
		serviceType: reflect.TypeOf(&alpha.ForwardingRulesService{}),
	},
	&ServiceInfo{
		Object:      "ForwardingRule",
		Service:     "GlobalForwardingRules",
		Resource:    "forwardingRules",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.GlobalForwardingRulesService{}),
		additionalMethods: []string{
			"SetTarget",
		},
	},
	&ServiceInfo{
		Object:      "HealthCheck",
		Service:     "HealthChecks",
		Resource:    "healthChecks",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.HealthChecksService{}),
		additionalMethods: []string{
			"Update",
		},
	},
	&ServiceInfo{
		Object:      "HealthCheck",
		Service:     "HealthChecks",
		Resource:    "healthChecks",
		version:     VersionAlpha,
		keyType:     Global,
		serviceType: reflect.TypeOf(&alpha.HealthChecksService{}),
		additionalMethods: []string{
			"Update",
		},
	},
	&ServiceInfo{
		Object:      "HttpHealthCheck",
		Service:     "HttpHealthChecks",
		Resource:    "httpHealthChecks",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.HttpHealthChecksService{}),
		additionalMethods: []string{
			"Update",
		},
	},
	&ServiceInfo{
		Object:      "HttpsHealthCheck",
		Service:     "HttpsHealthChecks",
		Resource:    "httpsHealthChecks",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.HttpsHealthChecksService{}),
		additionalMethods: []string{
			"Update",
		},
	},
	&ServiceInfo{
		Object:      "InstanceGroup",
		Service:     "InstanceGroups",
		Resource:    "instanceGroups",
		keyType:     Zonal,
		serviceType: reflect.TypeOf(&ga.InstanceGroupsService{}),
		additionalMethods: []string{
			"AddInstances",
			"ListInstances",
			"RemoveInstances",
			"SetNamedPorts",
		},
	},
	&ServiceInfo{
		Object:      "Instance",
		Service:     "Instances",
		Resource:    "instances",
		keyType:     Zonal,
		serviceType: reflect.TypeOf(&ga.InstancesService{}),
		additionalMethods: []string{
			"AttachDisk",
			"DetachDisk",
		},
	},
	&ServiceInfo{
		Object:      "Instance",
		Service:     "Instances",
		Resource:    "instances",
		version:     VersionBeta,
		keyType:     Zonal,
		serviceType: reflect.TypeOf(&beta.InstancesService{}),
		additionalMethods: []string{
			"AttachDisk",
			"DetachDisk",
		},
	},
	&ServiceInfo{
		Object:      "Instance",
		Service:     "Instances",
		Resource:    "instances",
		version:     VersionAlpha,
		keyType:     Zonal,
		serviceType: reflect.TypeOf(&alpha.InstancesService{}),
		additionalMethods: []string{
			"AttachDisk",
			"DetachDisk",
			"UpdateNetworkInterface",
		},
	},
	&ServiceInfo{
		Object:      "NetworkEndpointGroup",
		Service:     "NetworkEndpointGroups",
		Resource:    "networkEndpointGroups",
		version:     VersionAlpha,
		keyType:     Zonal,
		serviceType: reflect.TypeOf(&alpha.NetworkEndpointGroupsService{}),
		additionalMethods: []string{
			"AttachNetworkEndpoints",
			"DetachNetworkEndpoints",
		},
		options: AggregatedList,
	},
	&ServiceInfo{
		Object:   "Project",
		Service:  "Projects",
		Resource: "projects",
		keyType:  Global,

		options:     NoGet | NoList | NoInsert | NoDelete | CustomOps,
		serviceType: reflect.TypeOf(&ga.ProjectsService{}),
	},
	&ServiceInfo{
		Object:      "Region",
		Service:     "Regions",
		Resource:    "regions",
		keyType:     Global,
		options:     ReadOnly,
		serviceType: reflect.TypeOf(&ga.RegionsService{}),
	},
	&ServiceInfo{
		Object:      "Route",
		Service:     "Routes",
		Resource:    "routes",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.RoutesService{}),
	},
	&ServiceInfo{
		Object:      "SslCertificate",
		Service:     "SslCertificates",
		Resource:    "sslCertificates",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.SslCertificatesService{}),
	},
	&ServiceInfo{
		Object:      "TargetHttpProxy",
		Service:     "TargetHttpProxies",
		Resource:    "targetHttpProxies",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.TargetHttpProxiesService{}),
		additionalMethods: []string{
			"SetUrlMap",
		},
	},
	&ServiceInfo{
		Object:      "TargetHttpsProxy",
		Service:     "TargetHttpsProxies",
		Resource:    "targetHttpsProxies",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.TargetHttpsProxiesService{}),
		additionalMethods: []string{
			"SetSslCertificates",
			"SetUrlMap",
		},
	},
	&ServiceInfo{
		Object:      "TargetPool",
		Service:     "TargetPools",
		Resource:    "targetPools",
		keyType:     Regional,
		serviceType: reflect.TypeOf(&ga.TargetPoolsService{}),
		additionalMethods: []string{
			"AddInstance",
			"RemoveInstance",
		},
	},
	&ServiceInfo{
		Object:      "UrlMap",
		Service:     "UrlMaps",
		Resource:    "urlMaps",
		keyType:     Global,
		serviceType: reflect.TypeOf(&ga.UrlMapsService{}),
		additionalMethods: []string{
			"Update",
		},
	},
	&ServiceInfo{
		Object:      "Zone",
		Service:     "Zones",
		Resource:    "zones",
		keyType:     Global,
		options:     ReadOnly,
		serviceType: reflect.TypeOf(&ga.ZonesService{}),
	},
}

AllServices are a list of all the services to generate code for. Keep this list in lexiographical order by object type.

View Source
var AllServicesByGroup map[string]*ServiceGroup

AllServicesByGroup is a map of service name to ServicesGroup.

AllVersions is a list of all versions of the GCE API.

Functions

func KeysToMap

func KeysToMap(keys ...Key) map[Key]bool

KeysToMap creates a map[Key]bool from a list of keys.

Types

type Key

type Key struct {
	Name   string
	Zone   string
	Region string
}

Key for a GCP resource.

func GlobalKey

func GlobalKey(name string) *Key

GlobalKey returns the key for a global resource.

func RegionalKey

func RegionalKey(name, region string) *Key

RegionalKey returns the key for a regional resource.

func ZonalKey

func ZonalKey(name, zone string) *Key

ZonalKey returns the key for a zonal resource.

func (Key) String

func (k Key) String() string

String returns a string representation of the key.

func (*Key) Type

func (k *Key) Type() KeyType

Type returns the type of the key.

func (*Key) Valid

func (k *Key) Valid(typeName string) bool

Valid is true if the key is valid.

type KeyType

type KeyType string

KeyType is the type of the key.

type Method

type Method struct {
	*ServiceInfo

	ReturnType string
	// contains filtered or unexported fields
}

Method is used to generate the calling code non-standard methods.

func (*Method) CallArgs

func (mr *Method) CallArgs() string

func (*Method) FcnArgs

func (mr *Method) FcnArgs() string

func (*Method) InterfaceFunc

func (mr *Method) InterfaceFunc() string

func (*Method) MockHook

func (mr *Method) MockHook() string

func (*Method) MockHookName

func (mr *Method) MockHookName() string

func (*Method) Name

func (mr *Method) Name() string

type ServiceGroup

type ServiceGroup struct {
	Alpha *ServiceInfo
	Beta  *ServiceInfo
	GA    *ServiceInfo
}

ServiceGroup is a grouping of the same service but at different API versions.

func (*ServiceGroup) HasAlpha

func (sg *ServiceGroup) HasAlpha() bool

func (*ServiceGroup) HasBeta

func (sg *ServiceGroup) HasBeta() bool

func (*ServiceGroup) HasGA

func (sg *ServiceGroup) HasGA() bool

func (*ServiceGroup) Service

func (sg *ServiceGroup) Service() string

type ServiceInfo

type ServiceInfo struct {
	// Object is the Go name of the object type that the service deals
	// with. Example: "ForwardingRule".
	Object string
	// Service is the Go name of the service struct i.e. where the methods
	// are defined. Examples: "GlobalForwardingRules".
	Service string
	// Resource is the plural noun of the resource in the compute API URL (e.g.
	// "forwardingRules").
	Resource string
	// contains filtered or unexported fields
}

ServiceInfo defines the entry for a Service that code will be generated for.

func (*ServiceInfo) AggregatedList

func (i *ServiceInfo) AggregatedList() bool

AggregatedList is true if the method is to be generated.

func (*ServiceInfo) AggregatedListField

func (i *ServiceInfo) AggregatedListField() string

AggregatedListField is the name of the field used for the aggregated list call. This is typically the same as the name of the service, but can be customized by setting the aggregatedListField field.

func (*ServiceInfo) FQObjectType

func (i *ServiceInfo) FQObjectType() string

FQObjectType is fully qualified name of the object (e.g. compute.Instance).

func (*ServiceInfo) Field

func (i *ServiceInfo) Field() string

Field is the name of the GCE struct.

func (*ServiceInfo) GCEWrapType

func (i *ServiceInfo) GCEWrapType() string

GCEWrapType is the name of the GCE wrapper type.

func (*ServiceInfo) GenerateCustomOps

func (i *ServiceInfo) GenerateCustomOps() bool

GenerateCustomOps is true if we should generated a xxxOps interface for adding additional methods to the generated interface.

func (*ServiceInfo) GenerateDelete

func (i *ServiceInfo) GenerateDelete() bool

GenerateDelete is true if the method is to be generated.

func (*ServiceInfo) GenerateGet

func (i *ServiceInfo) GenerateGet() bool

GenerateGet is true if the method is to be generated.

func (*ServiceInfo) GenerateInsert

func (i *ServiceInfo) GenerateInsert() bool

GenerateInsert is true if the method is to be generated.

func (*ServiceInfo) GenerateList

func (i *ServiceInfo) GenerateList() bool

GenerateList is true if the method is to be generated.

func (*ServiceInfo) KeyIsGlobal

func (i *ServiceInfo) KeyIsGlobal() bool

KeyIsGlobal is true if the key is global.

func (*ServiceInfo) KeyIsRegional

func (i *ServiceInfo) KeyIsRegional() bool

KeyIsRegional is true if the key is regional.

func (*ServiceInfo) KeyIsZonal

func (i *ServiceInfo) KeyIsZonal() bool

KeyIsZonal is true if the key is zonal.

func (*ServiceInfo) MakeKey

func (i *ServiceInfo) MakeKey(name, location string) string

MakeKey returns the call used to create the appropriate key type.

func (*ServiceInfo) Methods

func (i *ServiceInfo) Methods() []*Method

Methods returns a list of additional methods to generate code for.

func (*ServiceInfo) MockField

func (i *ServiceInfo) MockField() string

MockField is the name of the field in the mock struct.

func (*ServiceInfo) MockWrapType

func (i *ServiceInfo) MockWrapType() string

MockWrapType is the name of the concrete mock for this type.

func (*ServiceInfo) ObjectAggregatedListType

func (i *ServiceInfo) ObjectAggregatedListType() string

ObjectAggregatedListType is the compute List type for the object (contains Items field).

func (*ServiceInfo) ObjectListType

func (i *ServiceInfo) ObjectListType() string

ObjectListType is the compute List type for the object (contains Items field).

func (*ServiceInfo) Version

func (i *ServiceInfo) Version() Version

Version returns the version of the Service, defaulting to GA if APIVersion is empty.

func (*ServiceInfo) VersionTitle

func (i *ServiceInfo) VersionTitle() string

VersionTitle returns the capitalized golang CamelCase name for the version.

func (*ServiceInfo) WrapType

func (i *ServiceInfo) WrapType() string

WrapType is the name of the wrapper service type.

func (*ServiceInfo) WrapTypeOps

func (i *ServiceInfo) WrapTypeOps() string

WrapTypeOps is the name of the additional operations type.

type Version

type Version string

Version of the API (ga, alpha, beta).

Jump to

Keyboard shortcuts

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