Package: pycyapi
PyCyAPIunofficial Python/CLI client for theCyVerseScience(a.k.a.Terrain) APIsStatusRequirementsInstallationUsageAuthenticatingCommandsVersionTokenUserListStatPullPushExistsCreateShareUnshareTagTagsStatusAPI coverage is still sparse, focusing mainly ondataandfileioendpoints. It will likely stay this way as this project exists predominantly for consumption byplantitandplantit-action.RequirementsPython 3.8+InstallationTo install with pip:pipinstallpycyapiUsageGenerally, the CLI is invoked withpycyapi <command>. All commands return JSON exceptpycyapi token ...(see below), which returns the token in plain text.AuthenticatingThepycyapiCLI must obtain an access token to authenticate with CyVerse. The token may be provided to commands via the--tokenparameter, or set as an environment variableCYVERSE_TOKEN. An access token can be obtained from the Terrain API by sending a request with basic auth headers (valid CyVerse username and password):GEThttps://de.cyverse.org/terrain/token/casAtokencommand (see below) is provided as convenient alternative to manually obtaining a token.CommandsTo show available commands help runpycyapi --help. The following commands are available:version: Show the currentpycyapiversion.token: Retrieve a CyVerse authentication token.user: Retrieve the user's profile information.list: List files in a collection.stat: Get information about a file or collection.pull: Download one or more files from a collection.push: Upload one or more files to a collection.exists: Check if a path exists in the data store.create: Create a collection in the data store.share: Share a file or collection with another user.unshare: Revoke another user's access to your file or collection.tag: Set metadata for a given file or collection.tags: Get metadata for a given file or collection.To show usage information for a specific command, runpycyapi <command> --help.VersionTo show the current version ofpycyapi, use theversioncommand:pycyapiversionTokenTo request a CyVerse CAS authentication token, use thetokencommand:pycyapitoken--username<yourCyVerseusername>--password<yourCyVersepassword>The token can be passed via--token (-t)argument to authenticate subsequent commands.UserTheusercommand can be used to retrieve public profile information for CyVerse users. For instance:pycyapiuser-t<token>wbonelliListTo list the contents of a collection in the data store, use thelistcommand. For instance:pycyapilist-t<token>/iplant/home/shared/iplantcollaborative/testing_tools/StatTo view metadata for a particular collection or object in the data store, use thestatcommand. For instance:pycyapistat-t<token>/iplant/home/shared/iplantcollaborative/testing_tools/PullTo download a single file from the data store to the current working directory, simply provide its full path:pycyapipull-t<token>/iplant/home/shared/iplantcollaborative/testing_tools/cowsay/cowsay.txtTo download all files from the/iplant/home/shared/iplantcollaborative/testing_tools/cowsay/collection to the current working directory, just provide the collection path instead:pycyapipull-t<token>/iplant/home/shared/iplantcollaborative/testing_tools/cowsay/Optional arguments are:--local_path (-p): Local path to download files to--include_pattern (-ip): File patterns to include (0+)--force (-f): Whether to overwrite already-existing filesPushTo upload all files in the current working directory to the/iplant/home/<my>/<directory/in the CyVerse Data Store, use:pycyapipush-t<token>/iplant/home/<username>/<collection>/Optional arguments include:--local_path (-p): Local path to download files to--include_pattern (-ip): File patterns to include (0+)--include_name (-in): File names to include (0+)--exclude_pattern (-ep): File patterns to exclude (0+)--exclude_name (-en): File names to exclude (0+)To upload a single file to the data store, provide the--local_path (-p)argument. For instance:pycyapipush-t<token>/iplant/home/<username>/<collection/-p/my/local/file.txtIf onlyinclude_...s are provided, only the file patterns and names specified will be included. If onlyexclude_...s section are present, all files except the patterns and names specified will be included. If you provide bothinclude_...andexclude_...sections, theinclude_...rules will first be applied to generate a subset of files, which will then be filtered by theexclude_...rules.ExistsTo determine whether a particular path exists in the data store, use theexistscommand. For instance, to check if a collection exists:pycyapiexists-t<token>/iplant/home/<username>/<collectionThe--typeoption can be provided with valuedirorfileto verify that the given path is of the specified type.CreateTo create a new collection, use thecreatecommand:pycyapicreate-t<token>/iplant/home/<username>/<newcollectionname>ShareTo share a file or collection with another user, use thesharecommand:pycyapishare-t<token>/iplant/home/<username>/<collection>--username<usertosharewith>--permission<'read'or'write'>Note that you must provide both the--usernameand--permissionflags.UnshareTo revoke another user's access to your file or collection, use theunsharecommand:pycyapiunshare-t<token>/iplant/home/<username>/<collection>--username<username>This applies to bothreadandwritepermissions for the specified user.TagTo set metadata for a given file object or collection in your data store, use thetagcommand:pycyapitag<dataobjectID>-t<token>-ak1=v1-ak2=v2This applies the two given attributes to the data object (attributes must be formattedkey=value).Warning:this command is an overwrite, not an append. We do not support appending tags as there is no Terrain endpoint to add/remove individual metadata attributes. Note also that by default, key/value pairs are passed on theavusattribute of the request body rather thanirods-avus, e.g.:POSThttps://de.cyverse.org/terrain/secured/filesystem/<ID>/metadata{"irods-avus":[],"avus":[{"attr":"some key""value":"some value","unit":""}]}To configureirods-avusattributes as well as or in place of standard attributes, use the--irods_attribute (-ia)option. Both standard and iRODS attributes can be used in the same invocation.TagsTo retrieve the metadata describing a particular file object or collection, use thetagscommand:pycyapitags<dataobjectID>-t<token>This will retrieve standard attributes by default. To retrieve iRODS attributes instead, use the--irods (-i)option.