How to use the globals.API_ROOT function in globals

To help you get started, we’ve selected a few globals examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cyverse / troposphere / troposphere / static / js / models / InstanceVolumeActionRequest.js View on Github external
url: function() {
        var instance = this.get("instance"),
            instanceId = instance.get("uuid"),
            providerId = instance.get("provider").uuid,
            identityId = instance.get("identity").uuid;

        return (
            globals.API_ROOT +
            "/provider/" +
            providerId +
            "/identity/" +
            identityId +
            "/instance/" +
            instanceId +
            "/action"
        );
    }
});
github cyverse / troposphere / troposphere / static / js / models / InstanceActionRequest.js View on Github external
url: function() {
        var instance = this.get("instance"),
            instanceId = instance.get("uuid"),
            providerId = instance.get("provider").uuid,
            identityId = instance.get("identity").uuid;

        return (
            globals.API_ROOT +
            "/provider/" +
            providerId +
            "/identity/" +
            identityId +
            "/instance/" +
            instanceId +
            "/action"
        );
    }
});
github cyverse / troposphere / troposphere / static / js / models / Profile.js View on Github external
import Backbone from "backbone";
import globals from "globals";

export default Backbone.Model.extend({
    url: globals.API_ROOT + "/profile",

    parse: function(response) {
        var attributes = response;

        attributes.id = response.username;
        attributes.userid = response.username;
        /**
         * FIXME: several values are missing from Profile
         *
         * ideally, we need to evaluate if the following
         * should be included in the Profile model
         *
         * "email": "lenards@cyverse.org",
         * "groups": "[]",
         * "is_expired": false,
         * "is_staff": true,
github cyverse / troposphere / troposphere / static / js / models / Volume.js View on Github external
fetchFromCloud: function(cb) {
        var volumeId = this.get("uuid"),
            providerId = this.get("provider").uuid,
            identityId = this.get("identity").uuid;

        var url =
            globals.API_ROOT +
            "/provider/" +
            providerId +
            "/identity/" +
            identityId +
            "/volume/" +
            volumeId;

        Backbone.sync("read", this, {
            url: url
        }).done(
            function(attrs, status, response) {
                this.set("status", attrs.status || "Unknown");
                this.set(
                    "state",
                    new VolumeState({
                        status_raw: attrs.status
github cyverse / troposphere / troposphere / static / js / models / Volume.js View on Github external
createOnV1Endpoint: function(options, cb) {
        if (!options.name) throw new Error("Missing name");
        if (!options.size) throw new Error("Missing size");

        var providerId = this.get("provider").uuid,
            identityId = this.get("identity").uuid,
            name = options.name,
            size = options.size;

        var url =
            globals.API_ROOT +
            "/provider/" +
            providerId +
            "/identity/" +
            identityId +
            "/volume";

        return Backbone.sync("create", this, {
            url: url,
            attrs: {
                name: name,
                size: size
            }
        });
    }
});
github cyverse / troposphere / troposphere / static / js / collections / InstanceHistoryCollection.js View on Github external
define(function (require) {
  "use strict";

  var InstanceCollection = require('./InstanceCollection'),
      InstanceHistory = require('models/InstanceHistory'),
      globals = require('globals');

  return InstanceCollection.extend({
    model: InstanceHistory,

    url: globals.API_ROOT + '/instance_history',

    parse: function (response) {
      this.meta = {
        count: response.count,
        next: response.next,
        previous: response.previous
      };

      return response.results;
    },

    comparator: function (a, b) {
      return b.get('start_date').diff(a.get('start_date'), "seconds");
    }

  });
github cyverse / troposphere / troposphere / static / js / actions / volume / destroy.js View on Github external
destroy: function(payload, options) {
        var volume = payload.volume,
            project = payload.project,
            volumeState = new VolumeState({
                status_raw: "deleting"
            }),
            originalState = volume.get("state"),
            identity = volume.get("identity"),
            provider = volume.get("provider"),
            url =
                globals.API_ROOT +
                "/provider/" +
                provider.uuid +
                "/identity/" +
                identity.uuid +
                "/volume/" +
                volume.get("uuid");

        volume.set({
            state: volumeState
        });
        Utils.dispatch(VolumeConstants.UPDATE_VOLUME, {
            volume: volume
        });

        volume
            .destroy({
github cyverse / troposphere / troposphere / static / js / models / Instance.js View on Github external
throw new Error("Missing allocation_source_uuid");
        }

        var providerId = this.get("provider").uuid,
            identityId = this.get("identity").uuid,
            name = options.name,
            size = options.size_alias,
            machine = options.machine_alias,
            scriptIDs = options.scripts
                ? options.scripts.map(function(script) {
                      return script.id;
                  })
                : [];

        var url =
            globals.API_ROOT +
            "/provider/" +
            providerId +
            "/identity/" +
            identityId +
            "/instance";

        let attrs = {
            name: name,
            machine_alias: machine,
            size_alias: size,
            scripts: scriptIDs
        };

        attrs.allocation_source_uuid = options.allocation_source_uuid;

        return Backbone.sync("create", this, {
github cyverse / troposphere / troposphere / static / js / actions / instance / destroy.js View on Github external
destroy: function(payload, options) {
        if (!payload.instance) throw new Error("Missing instance");

        var instance = payload.instance,
            originalState = instance.get("state"),
            instanceState = new InstanceState({
                status_raw: originalState.get("status_raw"),
                status: originalState.get("status"),
                activity: "deleting"
            }),
            identity = instance.get("identity"),
            provider = instance.get("provider"),
            url =
                globals.API_ROOT +
                "/provider/" +
                provider.uuid +
                "/identity/" +
                identity.uuid +
                "/instance/" +
                instance.get("uuid");

        instance.set({
            state: instanceState
        });
        instance.set({
            end_date: new Date()
        });

        Utils.dispatch(InstanceConstants.UPDATE_INSTANCE, {
            instance: instance