names

package
v0.0.0-...-c824f4b Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Overview

Package names provides AIP resource generic name, which allows to extract the resource name parts from the resource name.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Composer

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

Composer is a resource name composer.

func (*Composer) Name

func (c *Composer) Name() string

Name returns the composed resource name.

func (*Composer) Reset

func (c *Composer) Reset()

Reset resets the composer.

func (*Composer) WriteEmptyPart

func (c *Composer) WriteEmptyPart()

WriteEmptyPart writes an empty resource name part.

func (*Composer) WriteIntPart

func (c *Composer) WriteIntPart(part int)

WriteIntPart writes a resource name part from an integer.

func (*Composer) WriteIntResource

func (c *Composer) WriteIntResource(resource string, id int)

WriteIntResource writes the resource plural name along with the identifier.

func (*Composer) WritePart

func (c *Composer) WritePart(part string)

WritePart writes a resource name part.

func (*Composer) WriteResource

func (c *Composer) WriteResource(resource, id string)

WriteResource writes the resource plural name along with the identifier.

func (*Composer) WriteUintPart

func (c *Composer) WriteUintPart(part uint)

WriteUintPart writes a resource name part from an unsigned integer.

func (*Composer) WriteUintResource

func (c *Composer) WriteUintResource(resource string, id uint)

WriteUintResource writes the resource plural name along with the identifier.

type Name

type Name string

Name is the generic resource name type. It is used to extract the resource name parts from the resource name. I.e.: 'projects/{project}/keys/{key} ->

	Name.Part(0) = projects
	Name.Part(1) = {project}
	Name.Part(2) = keys
	Name.Part(3) = {key}
 	Name.Part(4) = ""
	Name.Part(-1) = {key}
	Name.Part(-2) = keys
	Name.Part(-3) = {project}
	Name.Part(-4) = projects
	Name.Part(-5) = ""

func (Name) Part

func (n Name) Part(i int) string

Part returns the i-th part of the resource name. The index i is zero-based, so the first part of the name has index 0. If i is negative, the part is counted from the end of the name (i.e. -1 is the last part). The function call is safe for out-of-range indices, thus, it can be used to iterate over the name parts. If the index is out of range, the function returns an empty string.

func (Name) Parts

func (n Name) Parts() int

Parts returns the number of parts in the resource name.

Jump to

Keyboard shortcuts

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