names

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Location = "global"

Location is included in resource names immediately following the project_id.

Variables

This section is empty.

Functions

func ExportableName added in v0.5.8

func ExportableName(name string, projectID string) string

ExportableName returns a name suitable for export. Its project and location are removed, making it project-local, and any revision ID is removed since revision ids cannot be imported.

Note that currently revision ids are only removed from trailing segments. That's all that we need now, but support for removing internal revision ids could be added if needed.

Also note: this would be a nice function to add to the Name interface but that might require improving the regularity of access to ProjectIDs for different types of Names.

func GenerateID

func GenerateID() string

GenerateID generates a random resource ID.

func ValidateRevisionTag added in v0.5.8

func ValidateRevisionTag(tag string) error

ValidateRevisionTag returns an error if the provided revision tag is invalid.

Types

type Api

type Api struct {
	ProjectID string
	ApiID     string
}

Api represents a resource name for an API.

func ParseApi

func ParseApi(name string) (Api, error)

ParseApi parses the name of an Api.

func ParseApiCollection added in v0.3.6

func ParseApiCollection(name string) (Api, error)

ParseApiCollection parses the name of an api collection.

func (Api) Artifact

func (a Api) Artifact(id string) Artifact

Artifact returns an artifact with the provided ID and this resource as its parent.

func (Api) Deployment added in v0.3.9

func (a Api) Deployment(id string) Deployment

Deployment returns an API deployment with the provided ID and this resource as its parent.

func (Api) Parent

func (a Api) Parent() string

Parent returns this resource's parent project resource name.

func (Api) Project

func (a Api) Project() Project

Project returns the name of this resource's parent project.

func (Api) String

func (a Api) String() string

func (Api) Validate

func (a Api) Validate() error

Validate returns an error if the resource name is invalid. For backward compatibility, names should only be validated at creation time.

func (Api) Version

func (a Api) Version(id string) Version

Version returns an API version with the provided ID and this resource as its parent.

type Artifact

type Artifact struct {
	// contains filtered or unexported fields
}

Artifact represents a resource name for an artifact.

func ParseArtifact

func ParseArtifact(name string) (Artifact, error)

ParseArtifact parses the name of an artifact.

func ParseArtifactCollection added in v0.3.6

func ParseArtifactCollection(name string) (Artifact, error)

ParseArtifactCollection parses the name of an artifact collection.

func (Artifact) ApiID

func (a Artifact) ApiID() string

ApiID returns the artifact's API ID, or empty string if it doesn't have one.

func (Artifact) ArtifactID

func (a Artifact) ArtifactID() string

ArtifactID returns the artifact's ID.

func (Artifact) DeploymentID added in v0.3.9

func (a Artifact) DeploymentID() string

DeploymentID returns the artifact's deployment ID, or empty string if it doesn't have one.

func (Artifact) Parent

func (a Artifact) Parent() string

Parent returns the resource name of the artifact's parent.

func (Artifact) ProjectID

func (a Artifact) ProjectID() string

ProjectID returns the artifact's project ID, or empty string if it doesn't have one.

func (Artifact) RevisionID added in v0.5.7

func (a Artifact) RevisionID() string

RevisionID returns the artifact's revision ID, or empty string if it doesn't have one.

func (Artifact) SpecID

func (a Artifact) SpecID() string

SpecID returns the artifact's spec ID, or empty string if it doesn't have one.

func (Artifact) String

func (a Artifact) String() string

func (Artifact) Validate

func (a Artifact) Validate() error

Validate returns an error if the resource name is invalid. For backward compatibility, names should only be validated at creation time.

func (Artifact) VersionID

func (a Artifact) VersionID() string

VersionID returns the artifact's version ID, or empty string if it doesn't have one.

type Deployment added in v0.3.9

type Deployment struct {
	ProjectID    string
	ApiID        string
	DeploymentID string
}

Deployment represents a resource name for an API deployment.

func ParseDeployment added in v0.3.9

func ParseDeployment(name string) (Deployment, error)

ParseDeployment parses the name of a deployment.

func ParseDeploymentCollection added in v0.3.9

func ParseDeploymentCollection(name string) (Deployment, error)

func (Deployment) Api added in v0.3.9

func (d Deployment) Api() Api

Api returns the parent API for this resource.

func (Deployment) Artifact added in v0.3.9

func (d Deployment) Artifact(id string) Artifact

Artifact returns an artifact with the provided ID and this resource as its parent.

func (Deployment) Normal added in v0.3.9

func (d Deployment) Normal() Deployment

Normal returns the resource name with normalized identifiers.

func (Deployment) Parent added in v0.3.9

func (d Deployment) Parent() string

Parent returns this resource's parent API resource name.

func (Deployment) Project added in v0.3.9

func (d Deployment) Project() Project

Project returns the parent project for this resource.

func (Deployment) Revision added in v0.3.9

func (d Deployment) Revision(id string) DeploymentRevision

Revision returns an API deployment revision with the provided ID and this resource as its parent.

func (Deployment) String added in v0.3.9

func (d Deployment) String() string

func (Deployment) Validate added in v0.3.9

func (d Deployment) Validate() error

Validate returns an error if the resource name is invalid. For backward compatibility, names should only be validated at creation time.

type DeploymentRevision added in v0.3.9

type DeploymentRevision struct {
	ProjectID    string
	ApiID        string
	DeploymentID string
	RevisionID   string
}

DeploymentRevision represents a resource name for an API deployment revision.

func ParseDeploymentRevision added in v0.3.9

func ParseDeploymentRevision(name string) (DeploymentRevision, error)

ParseDeploymentRevision parses the name of a deployment.

func ParseDeploymentRevisionCollection added in v0.5.7

func ParseDeploymentRevisionCollection(name string) (DeploymentRevision, error)

func (DeploymentRevision) Api added in v0.5.7

func (d DeploymentRevision) Api() Api

Api returns the parent API for this resource.

func (DeploymentRevision) Artifact added in v0.5.7

func (s DeploymentRevision) Artifact(id string) Artifact

Artifact returns an artifact with the provided ID and this resource as its parent.

func (DeploymentRevision) Deployment added in v0.3.9

func (s DeploymentRevision) Deployment() Deployment

Deployment returns the parent deployment for this resource.

func (DeploymentRevision) Parent added in v0.5.7

func (s DeploymentRevision) Parent() string

Parent returns this resource's parent API resource name.

func (DeploymentRevision) Project added in v0.5.7

func (d DeploymentRevision) Project() Project

Project returns the parent project for this resource.

func (DeploymentRevision) String added in v0.3.9

func (s DeploymentRevision) String() string

type Name added in v0.3.6

type Name interface {
	String() string // all names have a string representation.
}

Name is an interface that represents resource names.

func Parse added in v0.5.9

func Parse(name string) (Name, error)

Parse attempts to parse a string into an resource name.

func ParseResourceCollection added in v0.5.9

func ParseResourceCollection(name string) (Name, error)

Parse attempts to parse a string into a resource collection name.

func ParseResourceEntity added in v0.5.9

func ParseResourceEntity(name string) (Name, error)

Parse attempts to parse a string into a single resource name.

type Project

type Project struct {
	ProjectID string
}

Project represents a resource name for a project.

func ParseProject

func ParseProject(name string) (Project, error)

ParseProject parses the name of a project.

func ParseProjectCollection added in v0.3.6

func ParseProjectCollection(name string) (Project, error)

ParseProjectCollection parses the name of a project collection.

func ParseProjectWithLocation

func ParseProjectWithLocation(name string) (Project, error)

ParseProjectWithLocation parses the name of a project.

func (Project) Api

func (p Project) Api(id string) Api

Api returns an API with the provided ID and this resource as its parent.

func (Project) Artifact

func (p Project) Artifact(id string) Artifact

Artifact returns an artifact with the provided ID and this resource as its parent.

func (Project) String

func (p Project) String() string

func (Project) Validate

func (p Project) Validate() error

Validate returns an error if the resource name is invalid. For backward compatibility, names should only be validated at creation time.

type Spec

type Spec struct {
	ProjectID string
	ApiID     string
	VersionID string
	SpecID    string
}

Spec represents a resource name for an API spec.

func ParseSpec

func ParseSpec(name string) (Spec, error)

ParseSpec parses the name of a spec.

func ParseSpecCollection added in v0.3.6

func ParseSpecCollection(name string) (Spec, error)

ParseSpecCollection parses the name of a spec collection.

func (Spec) Api

func (s Spec) Api() Api

Api returns the parent API for this resource.

func (Spec) Artifact

func (s Spec) Artifact(id string) Artifact

Artifact returns an artifact with the provided ID and this resource as its parent.

func (Spec) Normal

func (s Spec) Normal() Spec

Normal returns the resource name with normalized identifiers.

func (Spec) Parent

func (s Spec) Parent() string

Parent returns this resource's parent version resource name.

func (Spec) Project

func (s Spec) Project() Project

Project returns the parent project for this resource.

func (Spec) Revision

func (s Spec) Revision(id string) SpecRevision

Revision returns an API spec revision with the provided ID and this resource as its parent.

func (Spec) String

func (s Spec) String() string

func (Spec) Validate

func (s Spec) Validate() error

Validate returns an error if the resource name is invalid. For backward compatibility, names should only be validated at creation time.

func (Spec) Version

func (s Spec) Version() Version

Version returns the parent API version for this resource.

type SpecRevision

type SpecRevision struct {
	ProjectID  string
	ApiID      string
	VersionID  string
	SpecID     string
	RevisionID string
}

SpecRevision represents a resource name for an API spec revision.

func ParseSpecRevision

func ParseSpecRevision(name string) (SpecRevision, error)

ParseSpecRevision parses the name of a spec.

func ParseSpecRevisionCollection added in v0.5.7

func ParseSpecRevisionCollection(name string) (SpecRevision, error)

ParseSpecRevisionCollection parses the name of a spec revision collection.

func (SpecRevision) Api added in v0.5.7

func (s SpecRevision) Api() Api

Api returns the parent API for this resource.

func (SpecRevision) Artifact added in v0.5.7

func (s SpecRevision) Artifact(id string) Artifact

Artifact returns an artifact with the provided ID and this resource as its parent.

func (SpecRevision) Parent added in v0.5.7

func (s SpecRevision) Parent() string

Parent returns this resource's parent version resource name.

func (SpecRevision) Project added in v0.5.7

func (s SpecRevision) Project() Project

Project returns the parent project for this resource.

func (SpecRevision) Spec

func (s SpecRevision) Spec() Spec

Spec returns the parent spec for this resource.

func (SpecRevision) String

func (s SpecRevision) String() string

func (SpecRevision) Version added in v0.5.7

func (s SpecRevision) Version() Version

Version returns the parent API version for this resource.

type Version

type Version struct {
	ProjectID string
	ApiID     string
	VersionID string
}

Version represents a resource name for an API version.

func ParseVersion

func ParseVersion(name string) (Version, error)

ParseVersion parses the name of a version.

func ParseVersionCollection added in v0.3.6

func ParseVersionCollection(name string) (Version, error)

ParseVersionCollection parses the name of a version collection.

func (Version) Api

func (v Version) Api() Api

Api returns the parent API for this resource.

func (Version) Artifact

func (v Version) Artifact(id string) Artifact

Artifact returns an artifact with the provided ID and this resource as its parent.

func (Version) Parent

func (v Version) Parent() string

Parent returns this resource's parent API resource name.

func (Version) Project

func (v Version) Project() Project

Project returns the parent project for this resource.

func (Version) Spec

func (v Version) Spec(id string) Spec

Spec returns an API spec with the provided ID and this resource as its parent.

func (Version) String

func (v Version) String() string

func (Version) Validate

func (v Version) Validate() error

Validate returns an error if the resource name is invalid. For backward compatibility, names should only be validated at creation time.

Jump to

Keyboard shortcuts

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