Skip to content

Commit

Permalink
COMPUTE-413: dx toolkit support for dx-jobutil-get-identity-token (#1328
Browse files Browse the repository at this point in the history
)

* feat: add job_get_identity_token api method + bash script

---------

Co-authored-by: Kurt Jensen <[email protected]>
  • Loading branch information
bayou-brogrammer and kpjensen authored Mar 4, 2024
1 parent adea766 commit 98c16ea
Show file tree
Hide file tree
Showing 15 changed files with 929 additions and 202 deletions.
9 changes: 8 additions & 1 deletion contrib/perl/lib/DNAnexus/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,13 @@ sub jobUpdate($;$%) {
}


sub jobGetIdentityToken($;$%) {
my ($object_id, $input_params, %kwargs) = @_;
%kwargs = () unless %kwargs;
return DXHTTPRequest('/'.$object_id.'/getIdentityToken', $input_params, %kwargs);
}


sub jobNew(;$%) {
my ($input_params, %kwargs) = @_;
%kwargs = () unless %kwargs;
Expand Down Expand Up @@ -1580,5 +1587,5 @@ sub workflowNew(;$%) {


our @ISA = "Exporter";
our @EXPORT_OK = qw(analysisAddTags analysisDescribe analysisRemoveTags analysisSetProperties analysisTerminate appAddAuthorizedUsers appAddCategories appAddDevelopers appAddTags appDelete appDescribe appGet appInstall appListAuthorizedUsers appListCategories appListDevelopers appPublish appRemoveAuthorizedUsers appRemoveCategories appRemoveDevelopers appRemoveTags appRun appValidateBatch appUninstall appUpdate appNew appletAddTags appletDescribe appletGet appletGetDetails appletListProjects appletRemoveTags appletRename appletValidateBatch appletRun appletSetProperties appletNew containerClone containerDescribe containerDestroy containerListFolder containerMove containerNewFolder containerRemoveFolder containerRemoveObjects containerRenameFolder databaseAddTags databaseAddTypes databaseClose databaseDescribe databaseGetDetails databaseListProjects databaseRelocate databaseRemoveTags databaseRemoveTypes databaseRename databaseSetDetails databaseSetProperties databaseSetVisibility databaseDownloadFile databaseListFolder dbclusterAddTags dbclusterAddTypes dbclusterDescribe dbclusterGetDetails dbclusterNew dbclusterRemoveTags dbclusterRemoveTypes dbclusterRename dbclusterSetDetails dbclusterSetProperties dbclusterSetVisibility dbclusterStart dbclusterStop dbclusterTerminate fileAddTags fileAddTypes fileClose fileDescribe fileDownload fileGetDetails fileListProjects fileRemoveTags fileRemoveTypes fileRename fileSetDetails fileSetProperties fileSetVisibility fileUpload fileNew globalWorkflowAddAuthorizedUsers globalWorkflowAddCategories globalWorkflowAddDevelopers globalWorkflowAddTags globalWorkflowDelete globalWorkflowDescribe globalWorkflowListAuthorizedUsers globalWorkflowListCategories globalWorkflowListDevelopers globalWorkflowPublish globalWorkflowRemoveAuthorizedUsers globalWorkflowRemoveCategories globalWorkflowRemoveDevelopers globalWorkflowRemoveTags globalWorkflowRun globalWorkflowUpdate globalWorkflowNew jobAddTags jobDescribe jobGetLog jobRemoveTags jobSetProperties jobTerminate jobUpdate jobNew notificationsGet notificationsMarkRead orgDescribe orgFindMembers orgFindProjects orgFindApps orgInvite orgRemoveMember orgSetMemberAccess orgUpdate orgNew projectAddTags projectArchive projectUnarchive projectClone projectDecreasePermissions projectDescribe projectDestroy projectInvite projectLeave projectListFolder projectMove projectNewFolder projectRemoveFolder projectRemoveObjects projectRemoveTags projectRenameFolder projectSetProperties projectTransfer projectUpdate projectUpdateSponsorship projectNew recordAddTags recordAddTypes recordClose recordDescribe recordGetDetails recordListProjects recordRemoveTags recordRemoveTypes recordRename recordSetDetails recordSetProperties recordSetVisibility recordNew systemDescribeDataObjects systemDescribeExecutions systemDescribeProjects systemFindAffiliates systemFindApps systemFindDataObjects systemFindGlobalWorkflows systemResolveDataObjects systemFindExecutions systemFindAnalyses systemFindDatabases systemFindJobs systemFindProjects systemFindUsers systemFindProjectMembers systemFindOrgs systemGenerateBatchInputs systemGlobalSearch systemGreet systemHeaders systemShortenURL systemWhoami userDescribe userUpdate workflowAddStage workflowAddTags workflowAddTypes workflowClose workflowDescribe workflowDryRun workflowGetDetails workflowIsStageCompatible workflowListProjects workflowMoveStage workflowOverwrite workflowRemoveStage workflowRemoveTags workflowRemoveTypes workflowRename workflowRun workflowValidateBatch workflowSetDetails workflowSetProperties workflowSetVisibility workflowUpdate workflowUpdateStageExecutable workflowNew);
our @EXPORT_OK = qw(analysisAddTags analysisDescribe analysisRemoveTags analysisSetProperties analysisTerminate appAddAuthorizedUsers appAddCategories appAddDevelopers appAddTags appDelete appDescribe appGet appInstall appListAuthorizedUsers appListCategories appListDevelopers appPublish appRemoveAuthorizedUsers appRemoveCategories appRemoveDevelopers appRemoveTags appRun appValidateBatch appUninstall appUpdate appNew appletAddTags appletDescribe appletGet appletGetDetails appletListProjects appletRemoveTags appletRename appletValidateBatch appletRun appletSetProperties appletNew containerClone containerDescribe containerDestroy containerListFolder containerMove containerNewFolder containerRemoveFolder containerRemoveObjects containerRenameFolder databaseAddTags databaseAddTypes databaseClose databaseDescribe databaseGetDetails databaseListProjects databaseRelocate databaseRemoveTags databaseRemoveTypes databaseRename databaseSetDetails databaseSetProperties databaseSetVisibility databaseDownloadFile databaseListFolder dbclusterAddTags dbclusterAddTypes dbclusterDescribe dbclusterGetDetails dbclusterNew dbclusterRemoveTags dbclusterRemoveTypes dbclusterRename dbclusterSetDetails dbclusterSetProperties dbclusterSetVisibility dbclusterStart dbclusterStop dbclusterTerminate fileAddTags fileAddTypes fileClose fileDescribe fileDownload fileGetDetails fileListProjects fileRemoveTags fileRemoveTypes fileRename fileSetDetails fileSetProperties fileSetVisibility fileUpload fileNew globalWorkflowAddAuthorizedUsers globalWorkflowAddCategories globalWorkflowAddDevelopers globalWorkflowAddTags globalWorkflowDelete globalWorkflowDescribe globalWorkflowListAuthorizedUsers globalWorkflowListCategories globalWorkflowListDevelopers globalWorkflowPublish globalWorkflowRemoveAuthorizedUsers globalWorkflowRemoveCategories globalWorkflowRemoveDevelopers globalWorkflowRemoveTags globalWorkflowRun globalWorkflowUpdate globalWorkflowNew jobAddTags jobDescribe jobGetLog jobRemoveTags jobSetProperties jobTerminate jobUpdate jobGetIdentityToken jobNew notificationsGet notificationsMarkRead orgDescribe orgFindMembers orgFindProjects orgFindApps orgInvite orgRemoveMember orgSetMemberAccess orgUpdate orgNew projectAddTags projectArchive projectUnarchive projectClone projectDecreasePermissions projectDescribe projectDestroy projectInvite projectLeave projectListFolder projectMove projectNewFolder projectRemoveFolder projectRemoveObjects projectRemoveTags projectRenameFolder projectSetProperties projectTransfer projectUpdate projectUpdateSponsorship projectNew recordAddTags recordAddTypes recordClose recordDescribe recordGetDetails recordListProjects recordRemoveTags recordRemoveTypes recordRename recordSetDetails recordSetProperties recordSetVisibility recordNew systemDescribeDataObjects systemDescribeExecutions systemDescribeProjects systemFindAffiliates systemFindApps systemFindDataObjects systemFindGlobalWorkflows systemResolveDataObjects systemFindExecutions systemFindAnalyses systemFindDatabases systemFindJobs systemFindProjects systemFindUsers systemFindProjectMembers systemFindOrgs systemGenerateBatchInputs systemGlobalSearch systemGreet systemHeaders systemShortenURL systemWhoami userDescribe userUpdate workflowAddStage workflowAddTags workflowAddTypes workflowClose workflowDescribe workflowDryRun workflowGetDetails workflowIsStageCompatible workflowListProjects workflowMoveStage workflowOverwrite workflowRemoveStage workflowRemoveTags workflowRemoveTypes workflowRename workflowRun workflowValidateBatch workflowSetDetails workflowSetProperties workflowSetVisibility workflowUpdate workflowUpdateStageExecutable workflowNew);

8 changes: 8 additions & 0 deletions contrib/ruby/lib/dxruby/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,14 @@ def self.job_update(object_id, input_params={}, opts={})
return DX::http_request("/#{object_id}/update", input_params, opts)
end

# Invokes the /job-xxxx/getIdentityToken API method.
#
# For more info, see: https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-getIdentityToken
def self.job_get_identity_token(object_id, input_params={}, opts={})
opts = { "always_retry" => true }.merge(opts)
return DX::http_request("/#{object_id}/getIdentityToken", input_params, opts)
end

# Invokes the /job/new API method.
#
# For more info, see: https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-new
Expand Down
33 changes: 33 additions & 0 deletions src/R/dxR/R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -3894,6 +3894,39 @@ jobUpdate <- function(objectID,
alwaysRetry=alwaysRetry)
}

##' jobGetIdentityToken API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/getIdentityToken} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-getIdentityToken}
jobGetIdentityToken <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getIdentityToken', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}

##' jobNew API wrapper
##'
##' This function makes an API call to the \code{/job/new} API
Expand Down
9 changes: 9 additions & 0 deletions src/api_wrappers/wrapper_table.json
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,15 @@
"wikiLink": "https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-update"
}
],
[
"/job-xxxx/getIdentityToken",
"jobGetIdentityToken(req, objectId)",
{
"retryable": true,
"objectMethod": true,
"wikiLink": "https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-getIdentityToken"
}
],
[
"/job/new",
"jobNew(req)",
Expand Down
8 changes: 8 additions & 0 deletions src/cpp/dxcpp/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,14 @@ namespace dx {
return jobUpdate(object_id, input_params.toString(), safe_to_retry);
}

JSON jobGetIdentityToken(const std::string &object_id, const std::string &input_params, const bool safe_to_retry) {
return DXHTTPRequest(std::string("/") + object_id + std::string("/getIdentityToken"), input_params, safe_to_retry);
}

JSON jobGetIdentityToken(const std::string &object_id, const JSON &input_params, const bool safe_to_retry) {
return jobGetIdentityToken(object_id, input_params.toString(), safe_to_retry);
}

JSON jobNew(const std::string &input_params, const bool safe_to_retry) {
return DXHTTPRequest("/job/new", input_params, safe_to_retry);
}
Expand Down
3 changes: 3 additions & 0 deletions src/cpp/dxcpp/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ namespace dx {
JSON jobUpdate(const std::string &object_id, const std::string &input_params="{}", const bool safe_to_retry=true);
JSON jobUpdate(const std::string &object_id, const dx::JSON &input_params, const bool safe_to_retry=true);

JSON jobGetIdentityToken(const std::string &object_id, const std::string &input_params="{}", const bool safe_to_retry=true);
JSON jobGetIdentityToken(const std::string &object_id, const dx::JSON &input_params, const bool safe_to_retry=true);

JSON jobNew(const std::string &input_params="{}", const bool safe_to_retry=false);
JSON jobNew(const dx::JSON &input_params, const bool safe_to_retry=false);

Expand Down
Loading

0 comments on commit 98c16ea

Please sign in to comment.