@tulip/node-red-tulip-api
Version:
Node-RED nodes for sending data to the Tulip API
125 lines (117 loc) • 4.1 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('tulip-api-auth', {
category: 'config',
paletteLabel: 'tulip-api-auth',
defaults: {
name: { value: 'tulip-api-auth' },
protocol: {
value: 'https',
required: true,
},
hostname: {
value: '',
required: true,
validate: function (name) {
// Note: this also covers IP addresses.
const validHostname = new RegExp(
'^\\w+([.-]\\w+)*$',
);
return validHostname.test(name);
},
},
port: {
value: null,
required: false,
validate: function (port) {
return port >= 0 && port <= 65535;
},
},
},
credentials: {
apiKey: { type: 'text' },
apiSecret: { type: 'password' },
},
label: function () {
return this.name || 'tulip-api-auth';
},
});
</script>
<script type="text/html" data-template-name="tulip-api-auth">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name" />
</div>
<div class="form-row">
<label for="node-config-input-protocol"><i class="fa fa-globe"></i> Protocol</label>
<select id="node-config-input-protocol">
<option value="https">https</option>
<option value="http">http</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-hostname"><i class="fa fa-link"></i> Factory URL</label>
<input
type="text"
id="node-config-input-hostname"
placeholder="i.e. [your-subdomain].tulip.co"
/>
</div>
<div class="form-row">
<label for="node-config-input-port"> Port (optional)</label>
<input
type="number"
step="1"
id="node-config-input-port"
min="0"
max="65535"
placeholder="default: 80 (HTTP) or 443 (HTTPS)"
/>
</div>
<div class="form-row">
<label for="node-config-input-apiKey"><i class="fa fa-user-circle"></i> API Key</label>
<input type="text" id="node-config-input-apiKey" placeholder="apikey.2_" />
</div>
<div class="form-row">
<label for="node-config-input-apiSecret"><i class="fa fa-key"></i> API Secret</label>
<input type="password" id="node-config-input-apiSecret" />
</div>
<div class="form-tips">
<p><b>Tip:</b> To generate an API token, you can visit:</p>
<ul>
<li>Workspaces enabled: <a>https://[your-factory-url]/settings/api-tokens</a></li>
<li>Workspaces not enabled: <a>https://[your-factory-url]/account-settings/api-tokens</a></li>
</ul>
<p>
and create an API token with the correct permissions. Make sure to write down the API Secret in a
secure location, since you won't be able to view it again.
</p>
</div>
</script>
<script type="text/html" data-help-name="tulip-api-auth">
<p>Configures authentication for the Tulip API.</p>
<h3>Details</h3>
<p>
Each <code>tulip-api-auth</code> node configures authentication for using the Tulip API.
The API credentials should be for an API token on the specified factory instance that has the correct permissions to
make the specified API calls. Each authentication node can be shared between multiple Tulip API nodes.
</p>
<p>
To use the Tulip API, you will first need to create an API token by visiting:
</p>
<ul>
<li>Workspaces enabled: <a>https://[your-factory-url]/settings/api-tokens</a></li>
<li>Workspaces not enabled: <a>https://[your-factory-url]/account-settings/api-tokens</a></li>
</ul>
<p>
Make sure to write down the API Secret in a secure location, since you won't be able to view it again.
</p>
<h3>References</h3>
<ul>
<li>
<a href=https://support.tulip.co/en/articles/4896233-using-node-red-with-edge-mc><b>Using Node-RED with Edge MC</b></a>
</li>
<li>
<b>Tulip API Documentation:</b> available at <a>https://[your-factory-url]/apiDocs</a>.
</li>
</ul>
</script>