@servisbot/npm-sb-srn

SRN generation SDK for ServisBot

Usage no npm install needed!

<script type="module">
  import servisbotNpmSbSrn from 'https://cdn.skypack.dev/@servisbot/npm-sb-srn';
</script>

README

npm-sb-srn

SRN generation SDK

Overview

npm module to make SRNs "painless"

install

npm install --save @servisbot/npm-sb-srn

Usage

const SRN = require('@servisbot/npm-sb-srn');

const srn = new SRN(args);  // see Environment variables section
assert(srn.isValid());

const srn = SRN.fromString('srn:vault:global:myorg:secretdoc:my-secret-doc-name:78');
assert.equal(srn.getService(), 'vault');
assert.equal(srn.getRegion(), 'global');
assert.equal(srn.getOrganization(), 'myorg');
assert.equal(srn.getResourcetype(), 'secretdoc');
assert.equal(srn.getResource(), 'my-secret-doc-name');
assert.equal(srn.getQualifier(), '78');
assert.equal(srn.generateSRN(), 'srn:vault:global:myorg:secretdoc:my-secret-doc-name:78');

Environment variables

The following environemnt variables will be used if present

SB_SERVICE;
SB_REGION;
SB_RESOURCE_TYPE;
SB_ORGANIZATION;
SB_RESOURCE;
SB_QUALIFIER;

The SRN class will read from the args passed into the constructure and take precidence over env vars if they exist

{
    service,
    region,
    resourcetype,
    organization,
    resource,
    qualifier
}