Helpers for interacting with the gen3 api
Delete a record out of indexd using basic-auth creds:
gen3 api indexd-delete $did
Helper downloads all the records from indexd to a folder
ex:$ gen3 api indexd-download-all domain.commons.io ./destFolder
Helper uploads a folder of json indexd records.
gen3 api indexd-post-folder [folder]
Post the .json files under the given folder to indexd in the current environment: $DEST_DOMAIN
Note - currently only works with new records - does not attempt to update existing records.
A new record looks like this:
{
"acl": [ "*" // public access - otherwise list of project accessors
],
//"did": "",
//"file_name": "",
"form": "object",
"hashes": {
//"md5": "c1898b7f2865ef7d7847b40e58f7c49c"
},
"metadata": {},
"size": 0,
"urls": [
//"s3://tcga-protected-dcf-databucket-gen3/testdata"
],
"urls_metadata": {
//"s3://tcga-protected-dcf-databucket-gen3/testdata": {
//"acls": "test"
//}
}
Allocate a one-hour access-token for the given user, or re-use one from cache if available.
Assumes that a fence
pod is running in the current environment.
gen3 api access-token [user-email] [expires-in (default: 3600)] [skip-cache (default: false)]
Generate a new api key for a given user or service account.
gen3 api api-key <username>
List old api keys with curl:
gen3 api curl credentials/cdis/ <username>
Delete an old api key with curl:
gen3 api curl credentials/cdis/<kid> <username> DELETE
Attempt to create a new program using a default template - suitable for dev accounts and testing.
gen3 api new-program [program-name] [user-email]
Where user-email
specifies the user to act as (via gen3 api access-token
)
ex:
gen3 api new-program jnkns [email protected]
Shortcut for g3kubectl get configmap global -o json | jq -r .data.hostname
ex:
gen3 api hostname
Shortcut for g3kubectl get configmap global -o json | jq -r .data.environment
ex:
gen3 api environment
Alias for gen3 db namespace
- echo kubectl namespace best guess
Attempt to create a new project using a default template - suitable for dev accounts and testing.
gen3 api new-project [program] [project] [user-email]
ex:
gen3 api new-project jnkns jenkins [email protected]
Where user-email
specifies the user to act as (via gen3 api access-token
)
Curl the endpoint of the given commons with the user's access token, POST jsonFile if given, DELETE if method specified
gen3 api curl path user-email jsonFile
or
gen3 api curl path path/to/apikey.json jsonFile
or
gen3 api curl path path/to/apikey.json DELETE
ex:
gen3 api curl /user/user [email protected]
Submit the given command file to sower to launch a job,
then wait for the job to finish, and fetch the job output.
Note - see sower-template
below for help generating a
sower command file.
- run on an admin vm with a user name - fetches an access-token for that user from fence
gen3 api sower-run commandFile.json user-email
- run on any machine with an api key
gen3 api sower-run commandFile.json path/to/apikey.json
Generate a name that is safe from collisions across environments and namespaces and is less than 64 characters from the given base name - envname--namespace--basename. If no base name is given, then a random base is generated.
ex:
gen3 api safe-name myName
Generate a skeleton for a sower job, so it can be used with gen3 api sower-job
or some similar tool. Currently only supports the following job types:
- pfb
$ gen3 api sower-template pfb | tee commandFile.json
{
"action": "export",
"input": {
"filter": {
"AND": []
}
}
}