Title: | Access to 'Azure DevOps' API via R |
---|---|
Description: | Implementation of 'Azure DevOps' <https://azure.microsoft.com/> API calls. It enables the extraction of information about repositories, build and release definitions and individual releases. It also helps create repositories and work items within a project without logging into 'Azure DevOps'. There is the ability to use any API service with a shell for any non-predefined call. |
Authors: | Ashley Baldry [aut, cre] |
Maintainer: | Ashley Baldry <[email protected]> |
License: | GPL-2 |
Version: | 1.1.1 |
Built: | 2025-01-21 04:25:42 UTC |
Source: | https://github.com/ashbaldry/vstsr |
This package takes a look at the Azure DevOps API calls and wraps them around in easy to use R functions. This includes looking at projects, repositories, work items, and eventually sections such as builds and releases.
For more information about Azure DevOps APIs, take a look at https://docs.microsoft.com/en-us/rest/api/vsts
This looks at the projects available in a visual studio instance. This lets you change between any project that you might have access to.
This looks primarily at the Git repositories available, and whether you want to create a new repository or delete an existing one.
This will track any existing work item for a project, and also the ability to create a new work item for a project. Useful if working within a development team and automate inclusion of creating bugs upon creating any certain R error.
This will look at the releases available for a project, both the definitions and the actual releases. There is the ability to deploy the created releases to a new environment.
For any non-predefined API service available in the package, it is always possible to run the vsts_run_command
which
will use any enabled Azure DevOps API call.
Maintainer: Ashley Baldry [email protected]
Useful links:
Report bugs at https://github.com/ashbaldry/vstsr/issues
Azure DevOps Account
user |
username for the Azure DevOps account |
pass |
password for the Azure DevOps account |
domain |
domain name for the Azure DevOps account |
project |
(optional) project name within the domain of the Azure DevOps account |
repo |
(optional) repository name with the project of the Azure DevOps domain |
An R6Class
generator object
For the majority of functions that are within this vsts_account
object, you can get help about the
query or body parameter with ?vsts_<function name>
.
## Not run: proj <- vsts_account$new( "<username>", "<password>", "<domain>", "<project>", "<repo>" ) str(proj) ## End(Not run)
## Not run: proj <- vsts_account$new( "<username>", "<password>", "<domain>", "<project>", "<repo>" ) str(proj) ## End(Not run)
Creation of a Azure DevOps authentication key that will be used when running any of the API calls.
vsts_auth_key(user, pass)
vsts_auth_key(user, pass)
user |
username to access Azure DevOps project |
pass |
password to access Azure DevOps project |
For more information about authentication check https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-6.1#create-the-request
An authentication key string in the form of 'Basic <Base 64 of user
:pass
>'
# Using credentials auth_key <- vsts_auth_key("<username>", "<password>") # Using PAT token auth_key <- vsts_auth_key(NULL, "<token>")
# Using credentials auth_key <- vsts_auth_key("<username>", "<password>") # Using PAT token auth_key <- vsts_auth_key(NULL, "<token>")
These functions will allow you to create releases from Azure DevOps.
vsts_create_release(domain, project, auth_key, body)
vsts_create_release(domain, project, auth_key, body)
domain |
The name of the Azure DevOps organization. |
project |
the name of the project in |
auth_key |
authentication key generated by using |
body |
a list of extra parameters that can need to be sent to the API call (* mandatory):
|
The artifacts
object within the body contains two items:
alias[character] Sets alias of artifact.
instanceReference[list] Sets instance reference of artifact. e.g. for build artifact it is build number.
For more information about release API calls check https://docs.microsoft.com/en-us/rest/api/vsts/release/releases.
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") art_list <- list( list(alias = "Art1", instanceReference = list(id = 1)), list(alias = "Art2", instanceReference = list(id = 2)) ) body <- list( definitionId = 1, description = "R API Release", artifacts = I(art_list) ) vsts_create_release("domain", "project", auth_key, body) ## End(Not run)
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") art_list <- list( list(alias = "Art1", instanceReference = list(id = 1)), list(alias = "Art2", instanceReference = list(id = 2)) ) body <- list( definitionId = 1, description = "R API Release", artifacts = I(art_list) ) vsts_create_release("domain", "project", auth_key, body) ## End(Not run)
These functions will allow you to scrape work item information from a particular Azure DevOps project.
vsts_create_workitem(domain, project, item_type, auth_key, ...)
vsts_create_workitem(domain, project, item_type, auth_key, ...)
domain |
The name of the Azure DevOps organization. |
project |
the name of the project in |
item_type |
the type of work item to be created |
auth_key |
authentication key generated by using |
... |
arguments passed to |
For more information about work item API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work-items.
These functions will allow you to run release environment tasks from Azure DevOps.
vsts_deploy_release(domain, project, release, env, auth_key)
vsts_deploy_release(domain, project, release, env, auth_key)
domain |
The name of the Azure DevOps organization. |
project |
the name of the project in |
release |
the release ID of the release |
env |
the release environment ID to release on |
auth_key |
authentication key generated by using |
For more information about release environment API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases/update-release-environment.
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_deploy_release("domain", "project", auth_key, 1, 1) ## End(Not run)
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_deploy_release("domain", "project", auth_key, 1, 1) ## End(Not run)
These functions will allow you to scrape build definition information from Azure DevOps.
vsts_get_build_defs(domain, project, auth_key, query = NULL)
vsts_get_build_defs(domain, project, auth_key, query = NULL)
domain |
The name of the Azure DevOps organization. |
project |
the name of the project in |
auth_key |
authentication key generated by using |
query |
a list of extra parameters that can be sent to the API call. Check details for access to list of options. |
For more information about the build definition API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/build/definitions/list.
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_get_build_defs("domain", "project", auth_key) ## End(Not run)
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_get_build_defs("domain", "project", auth_key) ## End(Not run)
These functions will allow you to scrape git repository information from Azure DevOps.
vsts_get_commits(domain, project, repo, auth_key, query = NULL)
vsts_get_commits(domain, project, repo, auth_key, query = NULL)
domain |
The name of the Azure DevOps organization. |
project |
the name of the project in |
repo |
the name of the repository in |
auth_key |
authentication key generated by using |
query |
a list of extra parameters that can be sent to the API call:
|
For more information about git repository API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/git/commits/get-commits.
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_get_commits("domain", "project", "repo", auth_key) ## End(Not run)
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_get_commits("domain", "project", "repo", auth_key) ## End(Not run)
These functions will allow you to scrape project information from Azure DevOps.
vsts_get_projects(domain, auth_key, quiet = FALSE)
vsts_get_projects(domain, auth_key, quiet = FALSE)
domain |
The name of the Azure DevOps organization. |
auth_key |
Authentication key generated by using |
quiet |
logical whether want general running information from printing. Any issue with the API call will
still show up if set to |
For more information about project API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/core/Projects.
These functions will allow you to scrape release definition information from Azure DevOps.
vsts_get_release_defs(domain, project, auth_key, quiet = FALSE)
vsts_get_release_defs(domain, project, auth_key, quiet = FALSE)
domain |
The name of the Azure DevOps organization. |
project |
the name of the project in |
auth_key |
authentication key generated by using |
quiet |
logical whether want general running information from printing. Any
issue with the API call will still show up if set to |
For more information about release definition API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/release/releases.
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_get_release_defs("domain", "project", auth_key) ## End(Not run)
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_get_release_defs("domain", "project", auth_key) ## End(Not run)
These functions will allow you to scrape releases from Azure DevOps.
vsts_get_releases(domain, project, auth_key, query = NULL) vsts_get_release(domain, project, release, auth_key)
vsts_get_releases(domain, project, auth_key, query = NULL) vsts_get_release(domain, project, release, auth_key)
domain |
The name of the Azure DevOps organization. |
project |
the name of the project in |
auth_key |
authentication key generated by using |
query |
a list of extra parameters that can be sent to the API call |
release |
Release Definition ID |
For more information about release API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/release/Releases.
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_get_releases("domain", "project", auth_key) ## End(Not run)
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") vsts_get_releases("domain", "project", auth_key) ## End(Not run)
These functions will allow you to scrape project information from Azure DevOps.
vsts_get_repos(domain, project, auth_key, quiet = FALSE) vsts_create_repo(domain, project, repo, auth_key, quiet = FALSE) vsts_delete_repo(domain, project, repo, auth_key, quiet = FALSE)
vsts_get_repos(domain, project, auth_key, quiet = FALSE) vsts_create_repo(domain, project, repo, auth_key, quiet = FALSE) vsts_delete_repo(domain, project, repo, auth_key, quiet = FALSE)
domain |
The name of the Azure DevOps organization |
project |
Project ID or project name |
auth_key |
authentication key generated by using |
quiet |
logical whether want general running information from printing. Any issue with the API call will
still show up if set to |
repo |
the name of the repository in |
For more information about repository API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/git.
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") # Get repo list vsts_get_repos("domain", "project", auth_key) # Create new repo vsts_create_repo("domain", "project", "repo", auth_key) # Delete existing repo vsts_delete_repo("domain", "project", "repo", auth_key) ## End(Not run)
## Not run: # Add in own details to get a non-NULL output auth_key <- vsts_auth_key("<username>", "<password>") # Get repo list vsts_get_repos("domain", "project", auth_key) # Create new repo vsts_create_repo("domain", "project", "repo", auth_key) # Delete existing repo vsts_delete_repo("domain", "project", "repo", auth_key) ## End(Not run)
This contains all the fields required of any work item in a visual studio project and helps add/rename the fields of the selected work item.
vsts_get_workitem_fields( System.Title, System.Description, System.TeamProject, System.AreaPath, System.IterationPath, Microsoft.VSTS.Common.Priority, ... )
vsts_get_workitem_fields( System.Title, System.Description, System.TeamProject, System.AreaPath, System.IterationPath, Microsoft.VSTS.Common.Priority, ... )
System.Title |
[character] title of the Azure DevOps work item |
System.Description |
[character] description of the Azure DevOps work item |
System.TeamProject |
[character] name of the Azure DevOps project |
System.AreaPath |
[character] path of the Azure DevOps work item |
System.IterationPath |
[character] name of the Azure DevOps iteration path |
Microsoft.VSTS.Common.Priority |
[integer] priority of the work item - 1 to 4 |
... |
other fields that might have been missed out originally |
For more information about work item fields API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/Fields.
These functions will allow you to scrape work item information from a particular Azure DevOps project.
vsts_get_workitems(domain, project, auth_key, id, query = list()) vsts_get_workitem(domain, project, auth_key, id)
vsts_get_workitems(domain, project, auth_key, id, query = list()) vsts_get_workitem(domain, project, auth_key, id)
domain |
The name of the Azure DevOps organization. |
project |
Project ID or project name |
auth_key |
authentication key generated by using |
id |
ID of the work item to retrieve |
query |
a list of extra parameters that can be sent to the API call:
|
For more information about work item API calls check https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work-items.
For any requirement not currently in place in the vstsr
package, then this function will allow you
to use the relevant API call without any extra requirements.
For the most part it is just a shell of VERB
but will have the auth_key
set up already.
vsts_run_command(url, verb, auth_key, body = NULL, query = NULL)
vsts_run_command(url, verb, auth_key, body = NULL, query = NULL)
url |
the URI of the API call to run |
verb |
name of the verb to use |
auth_key |
authentication key generated by using |
body |
check |
query |
a list of extra parameters that can be sent to the API call. If not required then leave as |
## Not run: auth_key <- vsts_auth_key("<username>", "<password>") # Get commits of a repository URL <- file.path( "https://dev.azure.com", domain, project, "_apis/git/repositories", repository_id, "commits?api-version=5.0" ) vsts_run_command(URL, "GET", auth_key) ## End(Not run)
## Not run: auth_key <- vsts_auth_key("<username>", "<password>") # Get commits of a repository URL <- file.path( "https://dev.azure.com", domain, project, "_apis/git/repositories", repository_id, "commits?api-version=5.0" ) vsts_run_command(URL, "GET", auth_key) ## End(Not run)