<commit_before>"""
authors: <NAME>, <NAME>
contact: <EMAIL>

Functions to interface with GBDX API.
"""

import os
import json
from boto import s3
import re
from gbdx_auth import gbdx_auth

class Interface():

  gbdx_connection = None
  def __init__(self):
    # This will throw an exception if your .ini file is not set properly
    self.gbdx_connection = gbdx_auth.get_session()

  def get_s3tmp_cred(self):
      """Request temporary credentials for the GBDX S3 Storage Service
         The access token is good for 10 hours.

         Args:
             None.

         Returns: 
             Set of credentials needed to access S3 Storage (dict).
      """
      url = 'https://geobigdata.io/s3creds/v1/prefix?duration=36000'
      r = self.gbdx_connection.get(url)
      s3tmp_cred = r.json()
      print "Obtained S3 Credentials"

      return s3tmp_cred


  def s3tmp_cred_reg(self,s3_cred):<commit_msg>allow explicit credential passing in instantiation<commit_after>"""
authors: <NAME>, <NAME>
contact: <EMAIL>

Functions to interface with GBDX API.
"""

import os
import json
from boto import s3
import re
from gbdx_auth import gbdx_auth

class Interface():

  gbdx_connection = None
  def __init__(self, **kwargs):
    if kwargs.get('username') and kwargs.get('password') and kwargs.get('client_id') and kwargs.get('client_secret'):
        self.gbdx_connection = gbdx_auth.session_from_kwargs(**kwargs)
    else:
      # This will throw an exception if your .ini file is not set properly
      self.gbdx_connection = gbdx_auth.get_session()

  def get_s3tmp_cred(self):
      """Request temporary credentials for the GBDX S3 Storage Service
         The access token is good for 10 hours.

         Args:
             None.

         Returns: 
             Set of credentials needed to access S3 Storage (dict).
      """
      url = 'https://geobigdata.io/s3creds/v1/prefix?duration=36000'
      r = self.gbdx_connection.get(url)
      s3tmp_cred = r.json()
      print "Obtained S3 Credentials"

      return s3tmp_cred


  def s3tmp_cred_reg(self,s3_cred):
{'fraction_non_alphanumeric': 0.08888888888888889, 'fraction_numerical': 0.017391304347826087, 'mean_word_length': 2.9903660886319847, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4588433', 'n_tokens_mistral': 686, 'n_tokens_neox': 649, 'n_words': 200}