コード例 #1
0
ファイル: UploadAllFiles.py プロジェクト: Vernboy/MultiFile
	def init_domo_client(self, CLIENT_ID, CLIENT_SECRET, **kwargs):
		# - Create an API client on https://developer.domo.com
		# - Initialize the Domo SDK with your API client id/secret
		# - If you have multiple API clients you would like to use, simply initialize multiple Domo() instances
		# - Docs: https://developer.domo.com/docs/domo-apis/getting-started
		handler = logging.StreamHandler()
		handler.setLevel(logging.INFO)
		formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
		handler.setFormatter(formatter)
		logging.getLogger().addHandler(handler)
		return Domo(CLIENT_ID, CLIENT_SECRET, logger_name='foo', log_level=logging.INFO, api_host=API_HOST, **kwargs)
コード例 #2
0
 def connect(**kwargs):
     try:
         if ("client_id" in kwargs and "client_secret" in kwargs):
             return Domo(kwargs["client_id"], kwargs["client_secret"])
         return create_engine(kwargs["connection_string"],
                              connect_args={
                                  "encoding": "UTF-8",
                                  "nencoding": "UTF-8"
                              }).connect()
     except Exception:
         if "logger" in kwargs:
             kwargs["logger"].exception("Unable to connect to database:")
コード例 #3
0
ファイル: examples.py プロジェクト: zcameron/domo-python-sdk
 def __init__(self):
     # Docs: https://developer.domo.com/docs/domo-apis/getting-started
     # Create an API client on https://developer.domo.com
     # Initialize the Domo SDK with your API client id/secret
     # If you have multiple API clients you would like to use, simply initialize multiple Domo() instances
     client_id = 'MY_CLIENT_ID'
     client_secret = 'MY_CLIENT_SECRET'
     api_host = 'api.domo.com'
     use_https = True
     logger_name = 'foo'
     logger_level = logging.INFO
     self.domo = Domo(client_id, client_secret, api_host, use_https,
                      logger_name, logger_level)
     self.logger = self.domo.logger
コード例 #4
0
ファイル: GhZhToDomo.py プロジェクト: BruceP99166/Repos
except:
    print("GHZH_RELEASE_HISTORY_DSID not found.")
    exit(1)

# Domo configure the logger
handler = logging.StreamHandler()
handler.setLevel(logging.INFO)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logging.getLogger().addHandler(handler)

# Domo: Create an instance of the Domo SDK Client
domo = Domo(domo_client_id,
            domo_client_secret,
            logger_name='domo_dataset',
            log_level=logging.INFO,
            api_host=domo_api_host)


def create_rows_for_issues_in_repo(r, repo_name, repo_id):
    estimate_value = 0
    pipeline_name = str('')

    if not r.status_code == 200:
        raise Exception(r.status_code)

    issues_in_repo_json = r.json()
    for issue in issues_in_repo_json:
        print(repo_name + ' issue Number: ' + str(issue['number']))
コード例 #5
0
# 20 Sep 2018
# Author: Steven Murray
# roleId
# Number
# Enter a number:
# 	1 (Admin)
# 	2 (Privileged)
# 	3 (Editor)
# 	4 (Participant)
# 	5 (Social)

#import domo libraries
from pydomo import Domo

#connect to the instance
domo = Domo("{ClientID}","{ClientSecret}",api_host="api.domo.com")

#initialize counters
user_count = 0
pull_users = True
pull_pass = 0

while pull_users == True:
	#Get list of users
	user_list = domo.users.list(500,pull_pass)
	print("Pull Pass:"******":", user_list[user_count]['role'])
		user_count += 1
コード例 #6
0
#get results in a list of dataframes
query_results_desk = query_results[query_results['device'] == 'Desktop']
query_results_tab = query_results[query_results['device'] == 'Tablet']
query_results_mob = query_results[query_results['device'] == 'Mobile']

####set parameters/arguments
####change these params whenever a new test starts
cwd = os.getcwd()
output_path_filename = cwd + '/outputs/' + config[
    'output_filename']  # path and filename for the output file

# if new dataset, create one in DOMO and save the ID
if config['output_dataset_id'] == None:
    # Create an instance of the SDK Client
    domo = Domo(domo_config.domo_id,
                domo_config.domo_secret,
                api_host="api.domo.com")

    # define the dataset, name, description, schema
    dsr = DataSetRequest()
    dsr.name = config['output_filename'][:-4] + ' Cannibalization Results'
    dsr.description = ''
    # Valid column types are STRING, DECIMAL, LONG, DOUBLE, DATE, DATETIME.
    # cannibalization results schema
    dsr.schema = Schema([
        Column(ColumnType.DATETIME, 'run_at'),
        Column(ColumnType.STRING, 'device'),
        Column(ColumnType.LONG, 'cu'),
        Column(ColumnType.LONG, 'cc'),
        Column(ColumnType.LONG, 'ccs'),
        Column(ColumnType.DECIMAL, 'control_conv'),
コード例 #7
0
import pandas as pd
import numpy as np
from pydomo import Domo
from pydomo.datasets import DataSetRequest, Schema, Column, ColumnType
from io import StringIO
from os import getenv
import json

with open('conf.json') as f:
    CONF = json.loads(f.read())

domo = Domo(**CONF["creds"])

data = pd.read_csv(CONF["csv_url"])
data['date'] = pd.to_datetime(data['date'])
data['reason'] = data['reason'].replace(np.nan, '')
data['nps_reason'] = data['nps_reason'].replace(np.nan,'')

csv = StringIO()

data.to_csv(csv, index=False)

if "dsid" in CONF.keys():
    pass
else:
    dsr = DataSetRequest()
    dsr.name = 'ZenDesk Sweethawk Surveys'
    dsr.description = 'Zendesk Surveys Exported from Sweethawk'
    dsr.schema = Schema([
        Column(ColumnType.LONG,'ticket'),
        Column(ColumnType.STRING, 'brand'),
コード例 #8
0
def run_pipeline(working_dir='.', program_dir='/Users/eric/anaconda3/bin/'):

    ####################################
    #   Create Link to Domo Instance   #
    ####################################

    # read the secret, client_id, and scope
    client_secret = None
    scope = None
    client_id = None
    api_host = 'api.domo.com'

    with open("secret.txt", 'r') as secret_file:
        client_secret = secret_file.read().strip()

    with open("client.txt", 'r') as client_file:
        client_id = client_file.read().strip()

    with open("scope.txt", 'r') as scope_file:
        scope = scope_file.read().strip()

    # link to domo instance
    domo = Domo(client_id,
                client_secret,
                logger_name="Eric",
                log_level=logging.INFO,
                api_host=api_host)

    ################################################
    #   Find Our Dataset Without Knowing It's ID   #
    ################################################

    # get the input and output datasets
    to_find = [
        'BASE|ERIC|Billboard Top 10', 'BASE|ERIC|Billboard Top 10 OUTPUT'
    ]

    def find_datasets_by_name(dataset_names, domo):
        datasets = list(domo.datasets.list())
        results = dict()
        for dataset in datasets:
            if dataset['name'] in dataset_names:
                results[dataset['name']] = dataset
        return results

    # datasets = find_datasets_by_name(to_find, domo)

    ####################################
    #         Read in all data         #
    ####################################

    include_csv_header = True
    csv_file_path = './input.csv'
    csv_download = domo.datasets.data_export_to_file(
        #     datasets['BASE|ERIC|Billboard Top 10 OUTPUT']['id']
        'e9d1c87f-6640-421b-9d13-4ad92f9ea525',
        csv_file_path,
        include_csv_header)

    ####################################
    #           Run R Script           #
    ####################################

    r_script_path = 'script_for_domo.R'
    # r_script_path = './script_for_domo.R'
    command = program_dir + 'Rscript'
    outfile_name = 'output.csv'
    args = [working_dir, csv_file_path,
            outfile_name]  # could place several command arguments here
    cmd = [command, r_script_path] + args

    # run the command and store result
    result = subprocess.check_output(cmd, universal_newlines=True)
    # universal newlines tells python to interpret returned output as a string
    # and handle both windows and linux newline characters

    #################################################
    #  Replace Target Dataset in DOMO with new Data #
    #################################################

    domo.datasets.data_import_from_file(
        #     datasets['BASE|ERIC|Billboard Top 10 OUTPUT']['id'],
        'e9d1c87f-6640-421b-9d13-4ad92f9ea525',
        outfile_name,
        update_method='REPLACE')

    print("Pipeline ran successfully!")
コード例 #9
0
client_id = secret.domo_id
client_secret = secret.domo_secret
api_host = 'api.domo.com'

# Configure the logger
handler = logging.StreamHandler()
handler.setLevel(logging.INFO)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logging.getLogger().addHandler(handler)

# Create an instance of the SDK Client
domo = Domo(
    client_id,
    client_secret,
    logger_name='foo',
    log_level=logging.INFO,
    api_host=api_host)

dsr = DataSetRequest()
datasets = domo.datasets

# Id of the dataset when we upload.
final_dataset_id = "d15aae88-4950-420d-8a89-8624443dc533"

# To create a dataset you need to create schema.
# NOTE: Will throw an error if you have wrong # of columns

# data_schema = Schema([
#     Column(ColumnType.STRING, "propertyid"),
#     Column(ColumnType.LONG, "Check Requested"),