# README

BloxID

This package, bloxid, implements typed guids for identifying resource objects globally in the system. Resources are not specific to services/applications but must contain an entity type.

Typed guids have the advantage of being globally unique, easily readable, and strongly typed for authorization and logging. The trailing characters provide sufficient entropy to make each resource universally unique.

bloxid package provides methods for generating and parsing versioned typed guids.

bloxid supports different schemes for the unique entity id portion of the bloxid

  • extrinsic
  • hashid
  • random

bloxids are Fully Qualified Names (FQN), dot separated, and composed of the following parts:

  <version>
  |     <entity_domain>
  |     |   <entity_type>
  |     |   |     <entity_realm>
  |     |   |     |        <entity_id>
  |     |   |     |        |
  blox0.iam.group.us-com-1.tshwyq3mfkgqqcfa76a5hbr2uaayzw3h

At Infoblox, the entity_id is unique within that realm, domain, and type combination.

Scheme - extrinsic

create bloxid from extrinsic id

v0, err := NewV0("",
            WithEntityDomain("iam"),
            WithEntityType("user"),
            WithRealm("us-com-1"),
            WithSchemer(WithExtrinsic("123456")),
        )
// v0.String(): "blox0.iam.user.us-com-1.ivmfiurrgiztinjweaqcaiba"
// v0.Decoded(): "123456"

parse bloxid to retrieve extrinsic id

parsed, err := NewV0("blox0.iam.user.us-com-1.ivmfiurrgiztinjweaqcaiba")
// parsed.Decoded(): "123456"

Scheme - hashid

create bloxid from hashid

v0, err := NewV0("",
            WithEntityDomain("infra"),
            WithEntityType("host"),
            WithRealm("us-com-1"),
            WithSchemer(WithHashIDInt64(1)),
            WithHashIDSalt("test"),
        )
// v0.String(): "blox0.infra.host.us-com-1.jbeuiwrsmq3tkmzwmuzwcojsmrqwemrtgy3tqzbvhbsdizjvhe2dkn3cgzrdizlb"
// v0.HashIDInt64(): 1

parse bloxid to retrieve hashid

parsed, err := NewV0("blox0.infra.host.us-com-1.jbeuiwrsmq3tkmzwmuzwcojsmrqwemrtgy3tqzbvhbsdizjvhe2dkn3cgzrdizlb",
    WithHashIDSalt("test")
)
// parsed.HashIDInt64(): 1

Scheme - random

create bloxid from generated random id

v0, err := NewV0("",
            WithEntityDomain("iam"),
            WithEntityType("group"),
            WithRealm("us-com-1"),
        )
// v0.String(): "blox0.iam.group.us-com-1.tshwyq3mfkgqqcfa76a5hbr2uaayzw3h"
// v0.Encoded(): "tshwyq3mfkgqqcfa76a5hbr2uaayzw3h"
// v0.Decoded(): "9c8f6c436c2a8d0808a0ff81d3863aa0018cdb67"

parse bloxid to retrieve the unique entity id portion of the bloxid

parsed, err := NewV0("blox0.iam.group.us-com-1.tshwyq3mfkgqqcfa76a5hbr2uaayzw3h")
// parsed.Encoded(): "tshwyq3mfkgqqcfa76a5hbr2uaayzw3h"
// parsed.Decoded(): "9c8f6c436c2a8d0808a0ff81d3863aa0018cdb67"

create bloxid from unique entity id portion of a previously generated bloxid with random scheme

v0, err := NewV0("",
            WithEntityDomain("iam"),
            WithEntityType("group"),
            WithRealm("us-com-1"),
            WithSchemer(WithRandomEncodedID("tshwyq3mfkgqqcfa76a5hbr2uaayzw3h")),
        )
// v0.String(): "blox0.iam.group.us-com-1.tshwyq3mfkgqqcfa76a5hbr2uaayzw3h"
// v0.Encoded(): "tshwyq3mfkgqqcfa76a5hbr2uaayzw3h"
// v0.Decoded(): "9c8f6c436c2a8d0808a0ff81d3863aa0018cdb67"

# Functions

NewV0 parse a string into a typed guid, return an error if the string fails validation.
No description provided by the author
No description provided by the author
WithExtrinsicID supplies a locally unique ID that is not randomly generated.
No description provided by the author
No description provided by the author
WithRandomEncodedID supplies the unique id portion of a previously generated random scheme bloxid.
No description provided by the author
No description provided by the author

# Constants

deprecated but kept for back compat.
must be divisible by 2 without remainder.
must be even number and multiple of 40 bits.
must be divisible by 8 without remainder.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

V0 represents a typed guid.
V0Options required options to create a typed guid.

# Interfaces

ID implements the interface for parsing a resource identifier.
Schemer defines the interface required for encoding/decoding different schemes.

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author