Example #1
0
    def GET(self):  # pylint: disable=R0201
        """
      Returns list of supported Clouwdwatch regions

      ::

          GET /_metrics/cloudwatch/regions

      Returns:

      ::

          { 'region-name': 'region-description',...}

      Sample output:

      ::

          {
            "ap-northeast-1": "Asia Pacific (Tokyo) Region",
            "ap-southeast-1": "Asia Pacific (Singapore) Region",
            "ap-southeast-2": "Asia Pacific (Sydney) Region",
            "eu-west-1": "EU (Ireland) Region",
            "sa-east-1": "South America (Sao Paulo) Region",
            "us-east-1": "US East (Northern Virginia) Region",
            "us-west-1": "US West (Northern California) Region",
            "us-west-2": "US West (Oregon) Region"
          }
    """
        adapter = datasource_adapter_factory.createCloudwatchDatasourceAdapter(
        )
        AuthenticatedBaseHandler.addStandardHeaders()
        return utils.jsonEncode(dict(adapter.describeRegions()))
Example #2
0
  def GET(self): # pylint: disable=R0201
    """
      Returns list of supported Clouwdwatch regions

      ::

          GET /_metrics/cloudwatch/regions

      Returns:

      ::

          { 'region-name': 'region-description',...}

      Sample output:

      ::

          {
            "ap-northeast-1": "Asia Pacific (Tokyo) Region",
            "ap-southeast-1": "Asia Pacific (Singapore) Region",
            "ap-southeast-2": "Asia Pacific (Sydney) Region",
            "eu-west-1": "EU (Ireland) Region",
            "sa-east-1": "South America (Sao Paulo) Region",
            "us-east-1": "US East (Northern Virginia) Region",
            "us-west-1": "US West (Northern California) Region",
            "us-west-2": "US West (Oregon) Region"
          }
    """
    adapter = datasource_adapter_factory.createCloudwatchDatasourceAdapter()
    AuthenticatedBaseHandler.addStandardHeaders()
    return utils.jsonEncode(dict(adapter.describeRegions()))
Example #3
0
  def updateSettings(self, section=None):
    if section != "usertrack":
      # Everything but usertrack requires authentication...
      apikey = AuthenticatedBaseHandler.extractAuthHeader()
      authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

      if authResult is False:
        AuthenticatedBaseHandler.raiseAuthFailure()

    dirty = False
    data = web.data()
    if data:
      sections = {}
      if section:
        sections = {section: utils.jsonDecode(data)}
      else:
        sections = utils.jsonDecode(data)

      config = HTMItAppConfig(mode=HTMItAppConfig.MODE_OVERRIDE_ONLY)

      for s in sections:
        if s in self.validSections():
          for key in sections[s]:
            if not config.has_section(s):
              config.add_section(s)
            config.set(s, key, sections[s][key])
            dirty = True
        else:
          return False
      if dirty:
        config.save()

      return dirty
    def updateSettings(self, section=None):
        if section != "usertrack":
            # Everything but usertrack requires authentication...
            apikey = AuthenticatedBaseHandler.extractAuthHeader()
            authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

            if authResult is False:
                AuthenticatedBaseHandler.raiseAuthFailure()

        dirty = False
        data = web.data()
        if data:
            sections = {}
            if section:
                sections = {section: utils.jsonDecode(data)}
            else:
                sections = utils.jsonDecode(data)

            config = HTMItAppConfig(mode=HTMItAppConfig.MODE_OVERRIDE_ONLY)

            for s in sections:
                if s in self.validSections():
                    for key in sections[s]:
                        if not config.has_section(s):
                            config.add_section(s)
                        config.set(s, key, sections[s][key])
                        dirty = True
                else:
                    return False
            if dirty:
                config.save()

            return dirty
Example #5
0
  def getAllSettings(self):
    # Make sure we have the latest version of configuration
    htm.it.app.config.loadConfig()

    apikey = AuthenticatedBaseHandler.extractAuthHeader()
    authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

    if authResult is False:
      AuthenticatedBaseHandler.raiseAuthFailure()

    res = {}
    for section in self.validSections():
      res[section] = {}
      for key, value in htm.it.app.config.items(section):
        if key not in HIDDEN_SETTINGS.get(section, set()):
          res[section][key] = value
    return res
    def getAllSettings(self):
        # Make sure we have the latest version of configuration
        htm.it.app.config.loadConfig()

        apikey = AuthenticatedBaseHandler.extractAuthHeader()
        authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

        if authResult is False:
            AuthenticatedBaseHandler.raiseAuthFailure()

        res = {}
        for section in self.validSections():
            res[section] = {}
            for key, value in htm.it.app.config.items(section):
                if key not in HIDDEN_SETTINGS.get(section, set()):
                    res[section][key] = value
        return res
Example #7
0
  def getSectionSettings(self, section):
    # Make sure we have the latest version of configuration
    htm.it.app.config.loadConfig()
    res = {}

    if section != "usertrack":
      # Everything but usertrack requires authentication...
      apikey = AuthenticatedBaseHandler.extractAuthHeader()
      authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

      if authResult is False:
        AuthenticatedBaseHandler.raiseAuthFailure()

    if section in self.validSections():
      for key, value in htm.it.app.config.items(section):
        if key not in HIDDEN_SETTINGS.get(section, set()):
          res[key] = value
    return res
    def getSectionSettings(self, section):
        # Make sure we have the latest version of configuration
        htm.it.app.config.loadConfig()
        res = {}

        if section != "usertrack":
            # Everything but usertrack requires authentication...
            apikey = AuthenticatedBaseHandler.extractAuthHeader()
            authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

            if authResult is False:
                AuthenticatedBaseHandler.raiseAuthFailure()

        if section in self.validSections():
            for key, value in htm.it.app.config.items(section):
                if key not in HIDDEN_SETTINGS.get(section, set()):
                    res[key] = value
        return res
Example #9
0
  def GET(self, section=None):
    """
    List All Settings

    ::

        GET /_settings

    Returns:

    ::

        {
          "section": {
              "option": "value", ...
          }, ...
        }

    OR

    List Some Settings

    ::

        GET /_settings/section

    ::

        {
          "option": "value", ...
        }
    """
    res = {}
    if section is None:
      res = self.getAllSettings()
    else:
      res = self.getSectionSettings(section)

    AuthenticatedBaseHandler.addStandardHeaders()
    return utils.jsonEncode(res)
    def GET(self, section=None):
        """
    List All Settings

    ::

        GET /_settings

    Returns:

    ::

        {
          "section": {
              "option": "value", ...
          }, ...
        }

    OR

    List Some Settings

    ::

        GET /_settings/section

    ::

        {
          "option": "value", ...
        }
    """
        res = {}
        if section is None:
            res = self.getAllSettings()
        else:
            res = self.getSectionSettings(section)

        AuthenticatedBaseHandler.addStandardHeaders()
        return utils.jsonEncode(res)