On April 1, 2021, we are moving all of our QuotaGuard Support Documentation to 


https://quotaguard.github.io/qg-docs/


 Please Update Your Support Bookmarks


 Documentation for this article will be maintained at 


https://quotaguard.github.io/qg-docs/quickstart-ruby 


Please click on the above link to ensure you are reading 

the most recent and updated documentation.


Our documentation assumes that your QuotaGuard Static credentials are available in the form of a connection string in the QUOTAGUARDSTATIC_URL environment variable. 


On CloudFoundry based platforms like IBM Bluemix, Pivotal and RedHat Openshift, this is not the case. so you need slightly different code to access your QuotaGuard Static credentials by extracting them from the VCAP_SERVICES environment variable.

 

The VCAP_SERVICES entry looks like the following: 

{"quotaguard":[{"name":"QuotaGuardInstance","label":"quotaguard","tags":[],"plan":"starter","credentials":{"QUOTAGUARD_URL":QUOTAGUARD_URL}}]}

 

Extract the variable using the snippets below and then continue with our standard documented solutions.


In Java 

String vcapServices = System.getenv("VCAP_SERVICES");
JsonRootNode root = new JdomParser().parse(vcapServices);
JsonNode mysqlNode = root.getNode("quotaguard");
JsonNode credentials = mysqlNode.getNode(0).getNode("credentials");
String quotaguardURL = credentials.getStringValue("QUOTAGUARD_URL");

 

In Ruby 

credentials = proxyURL = ''
if !ENV['VCAP_SERVICES'].blank?
  JSON.parse(ENV['VCAP_SERVICES']).each do |k,v|
    if !k.scan("quotaguard").blank?
      credentials = v.first.select {|k1,v1| k1 == "credentials"}["credentials"]
      proxyURL = credentials["QUOTAGUARD_URL"]
    end
  end
end


In Python 

quotaguard_service = json.loads(os.environ['VCAP_SERVICES'])['quotaguard'][0]
credentials = quotaguard_service['credentials']
quotaguard_url = credentials['QUOTAGUARD_URL']

 

In Node.js/Javascript 

var vcap_services = JSON.parse(process.env.VCAP_SERVICES)
var quotaguardUrl = vcap_services['quotaguard'][0].credentials.QUOTAGUARD_URL

 

In PHP 

 $vcap = json_decode(getenv("VCAP_SERVICES"),true);
 $quotaguard_env = $vcap["quotaguard"][0]["credentials"]["QUOTAGUARD_URL"];

 


If you have questions, or if this solution doesn’t work or fit your use case, please reach out to us at Support so we can help figure it out with you.


Working with sensitive data, like HIPAA, Financial, or Personally Identifiable Information (PII)? 

    Then you will want to check out our QuotaGuard Shield solution, it's the same as QuotaGuard Static, but with stronger end to end security for your requests. We can also help migrate current Static customers to Shield for free, just reach out to us at Support to request assistance.