Package: xplenty
Xplenty Python WrapperThe Xplenty PY is a python artifact that provides a simple wrapper for theXplenty REST API. To use it, create an XplentyClient object and call its methods to access the Xplenty API. This page describes the available XplentyClient methods.InstallationVia pip:pipinstallxplentyCreate an Xplenty Client ObjectPass your account ID and API key to the XplentyClient constructor.fromxplentyimportXplentyClientaccount_id="MyAccountID"api_key="V4eyfgNqYcSasXGhzNxS"client=XplentyClient(account_id,api_key)Create a ClusterThis method creates a new cluster. A cluster is a group of machines ("nodes") allocated to your account. The number of nodes in the cluster is determined by the "nodes" value that you supply to the call. While the cluster is active, only your account's users can run jobs on the cluster.
You will need to provide an active cluster when starting a new job. Save the cluster ID value returned in the response "id" field. You will use the value to refer to this cluster in subsequent API calls.cluster_type="production"nodes=2name="New Cluster #199999"description="New Cluster's Description"terminate_on_idle=Falsetime_to_idle=3600cluster=client.create_cluster(cluster_type,nodes,name,description,terminate_on_idle,time_to_idle)printcluster.idList All ClustersThis method returns the list of clusters that were created by users in your account.
You can use this information to monitor and display your clusters and their statuses.clusters=client.clustersprint"Number of clusters:",len(clusters)forclusterinclusters:printcluster.id,cluster.name,cluster.created_atGet Cluster InformationThis method returns the details of the cluster with the given ID.id=85cluster=client.get_cluster(id)printcluster.nameTerminate a ClusterThis method deactivates the given cluster, releasing its resources and terminating its runtime period. Use this method when all of the cluster's jobs are completed and it's no longer needed. The method returns the given cluster's details, including a status of "pending_terminate".id=85cluster=client.terminate_cluster(id)printcluster.statusRun a JobThis method creates a new job and triggers it to run. The job performs the series of data processing tasks that are defined in the job's package. Unless the job encounters an error or is terminated by the user, it will run until it completes its tasks on all of the input data. Save the job ID value returned in the response "id" field. You will use the value to refer to this job in subsequent API calls.cluster_id=83package_id=782variables={}variables['OUTPUTPATH']="test/job_vars.csv"variables['Date']="09-10-2012"job=client.add_job(cluster_id,package_id,variables)printjob.idList All JobsThis method returns information for all the jobs that have been created under your account.jobs=client.jobsforjobinjobs:printjob.id,job.progress,job.statusGet Job InformationThis method retrieves information for a job, according to the given job ID.job_id=235job=client.get_job(job_id)printjob.statusTerminate a JobThis method terminates an active job. Usually it's unnecessary to request to terminate a job, because normally the job will end when its tasks are completed. You may want to actively terminate a job if you need its cluster resources for a more urgent job, or if the job is taking too long to complete.job_id=235job=client.stop_job(job_id)printjob.statusList All PackagesThis method returns the list of packages that were created by users in your account.
You can use this information to display your packages and their properties.packages=client.packagesprint"Number of packages:",len(packages)forpackageinpackages:printpackage.id,package.name,package.created_atGet Package InformationThis method returns the details of the package with the given ID.id=85package=client.get_package(id)printpackage.nameContributingFork itCreate your feature branch (git checkout -b my-new-feature)Commit your changes (git commit -am 'Add some feature')Push to the branch (git push origin my-new-feature)Create new Pull RequestLicenseReleased under theMIT license.