Giter VIP home page Giter VIP logo

azure-devops-java-sdk's People

Contributors

filterer avatar gabechan avatar hkarthik7 avatar jfbaraton avatar jvnoije avatar kurtn718 avatar nbihan-mediware avatar rhadamanthys79 avatar shblue21 avatar stil4m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

azure-devops-java-sdk's Issues

Documentation of RestClient or Unit tests of RestClient needed

Issue Template

Can you add unit tests for org.azd.utils.RestClient class so that I know how it works?

If you had unit tests, hitting a site such as JsonPlaceholder, then I would know how to use the client.

Steps to reproduce

Basically I have a need to query the test/runs endpoint so I can get test result information for builds. Your API does not seem to support that endpoint, documented here: https://learn.microsoft.com/en-us/rest/api/azure/devops/test/runs/list?view=azure-devops-rest-7.0&tabs=HTTP

curl --location --request GET 'https://dev.azure.com/Company/MyTeam/_apis/test/runs?api-version=7.0&includeRunDetails=true&project=MyTeam'

If you don't have any good examples of using your rest client, or any documentation, then I will be forced to use a different 3rd party library. I wanted to keep it simple and use yours, if possible. The arguments that the send methods take are cryptic.

Expected behavior


Actual behavior


Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

Azure Server

Issue:
The library provides functionality to connect to Azure DevOps services and interact with them using a provided API. However, it seems that there is an issue when attempting to connect to Azure DevOps Server instances using the library's latest version.

Steps to Reproduce:

Create an instance of the library.
Set the base instance URL to the Azure DevOps Server instance: Instance.BASE_INSTANCE.instance = "https://devops.jtaps.us"
Initialize the API using the new method: val webApi = AzDClientApi("JTAPS", pat)
Expected Behavior:
The library should successfully connect to the Azure DevOps Server instance using the provided organization name (collection name in this context) and personal access token (PAT).

Actual Behavior:
When using the new method and providing the organization name (collection name) as 'JTAPS', the following exception is thrown: InvalidOrganizationNameException: Couldn't find the organization name 'JTAPS' in instance 'https://devops.jtaps.us/'.

Additional Information:
It appears that the library's behavior aligns with the naming paradigm used by Azure DevOps services, but it does not accommodate the naming convention used by Azure DevOps Server instances. Azure DevOps Server seems to use a different naming paradigm for organizations (collections) that does not match the organization name provided when initializing the library.

VariableGroupProviderData is missing lastRefreshedOn field

When trying to expand tasks for a release release API is throwing an exception

releaseApi.getRelease(release.getId(), SingleReleaseExpands.TASKS);

ApiResponseParsingException: Unrecognized field "lastRefreshedOn" (class org.azd.distributedtask.types.VariableGroupProviderData), not marked as ignorable (2 known properties: "vault", "serviceEndpointId"])
at [Source: (StringReader); line: 1, column: 290593] (through reference chain: org.azd.release.types.Release["variableGroups"]->java.util.ArrayList[1]->org.azd.release.types.VariableGroup["providerData"]->org.azd.distributedtask.types.VariableGroupProviderData["lastRefreshedOn"])

It's because this is missing the field described in AzureKeyVaultVariableGroupProviderData interface
https://github.com/microsoft/azure-devops-node-api/blob/9ccac86e5bb38c553c433b4e300d920e7e3e2b40/api/interfaces/ReleaseInterfaces.ts#L535

Git push does not work because JSON output does not match examples

I had some problems with git pushes create and found two problems that are close related.

  1. the JSON content is filled with 'null' values. This causes undefined errors at the rest API.
  2. the 'item' in commits => changes => item is stated as a string, and that is also the type that is used in this library. However if you look al the examples you see that the item contains a 'path' parameter, with corresponds with a 'GitItem' type.

Steps to reproduce

GitRefUpdate gitRefUpdate = new GitRefUpdate();
gitRefUpdate.setName("refs/heads/test_branch");

ItemContent itemContent = new ItemContent();
itemContent.setContentType(ItemContentType.RAWTEXT);
itemContent.setContent("Content of the file");

GitChange gitChange = new GitChange();
gitChange.setChangeType(VersionControlChangeType.ADD);
gitChange.setItem("/test_file.txt");
gitChange.setNewContent(itemContent);

GitCommitRef gitCommitRef = new GitCommitRef();
gitCommitRef.setComment("Add new test file");
gitCommitRef.setChanges(Collections.singletonList(gitChange));

GitPush gitPush = new GitPush();
gitPush.setRefUpdates(Collections.singletonList(gitRefUpdate));
gitPush.setCommits(Collections.singletonList(gitCommitRef));

gitApi.createPush(repositoryName, gitPush);

The above example results in the following JSON:

{
  "_links": null,
  "commits": [
    {
      "_links": null,
      "author": null,
      "changeCounts": null,
      "changes": [
        {
          "changeId": null,
          "changeType": "add",
          "item": "/test_file.txt",
          "newContent": {
            "content": "Content of the file",
            "contentType": "rawText"
          },
          "newContentTemplate": null,
          "originalPath": null,
          "sourceServerItem": null,
          "url": null
        }
      ],
      "comment": "Add new test file",
      "commentTruncated": false,
      "commitId": null,
      "committer": null,
      "parents": null,
      "push": null,
      "remoteUrl": null,
      "statuses": null,
      "url": null,
      "workItems": null
    }
  ],
  "date": null,
  "pushId": null,
  "pushedBy": null,
  "refUpdates": [
    {
      "locked": false,
      "isLocked": false,
      "name": "refs/heads/test_branch",
      "newObjectId": null,
      "oldObjectId": null,
      "repositoryId": null
    }
  ],
  "repository": null,
  "url": null
}

Expected behavior

The new file is added (assuming there is not already a file with this name)

Actual behavior

Getting a non descriptive error message:
{
    "$id": "1",
    "innerException": null,
    "message": "The body of the request contains invalid Json.\r\nParameter name: contentStream",
    "typeName": "Microsoft.TeamFoundation.SourceControl.WebServer.InvalidArgumentValueException, Microsoft.TeamFoundation.SourceControl.WebServer",
    "typeKey": "InvalidArgumentValueException",
    "errorCode": 0,
    "eventId": 0
}

Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

Pipelines API not working

Steps to reproduce

    @Test
    void pipelineTest() {
    
    
        AzDClientApi client = new AzDClientApi(devOpsConfig.getOrganization(),devOpsConfig.getPat());

        PipelinesApi pipelinesApi = client.getPipelinesApi();
        
        try {
            pipelinesApi.getPipelines().getPipelines().forEach(pipeline -> {
                System.out.println(pipeline.getId());
            });

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

Result:

org.azd.exceptions.AzDException: ApiResponseParsingException: Unrecognized token 'Page': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"Page not found."; line: 1, column: 5]                                                                                                                                                           
        at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:47) 

GitApi 'getItems' does not include version in query string

When using the GIT api to get an item from a specific branch, the version is not passed into the URL.

Steps to reproduce

Given that you have a repository "testRepository" with two or more branches where the file "test.txt" has been changed on the "branch-with-changed-file" branch.

GitItems items = gitApi.getItems(
            "testRepository",
            true,
            false,
            false,
            VersionControlRecursionType.NONE,
            "test.txt",
            "branch-with-changed-file",
            GitVersionOptions.NONE,
            GitVersionType.BRANCH);

Expected behavior

It will return the file from the "branch-with-changed-file".

Actual behavior

It will return the file of the default branch, because the 'version' is not included in the request

Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

feature enhancement - project feature toggle - unpublished API

Please see the following blog post and community discussion link:

This is to programmatically enable / disable project services such as Boards, Test Plans, etc. (see screenshot)

I've confirmed the functionality currently still works.

I'm planning to add this functionality to my app. Since this is not an official published API feature, I'm just confirming if you want me to add this to this library.
If not, I will implement outside, either in my calling app or in my fork only.

Screen Shot 2022-06-27 at 3 07 50 PM.

Support Attachments for Work Items

Currently SDK doesn't support adding attachments to work items. Please add support for attachments.

Steps to reproduce

Expected behavior


Actual behavior


Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields
otherwise the issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

[CORE API] getTeams() Fails with ApiResponseParsingException: No content to map due to end-of-input at [Source: (String)""; line: 1, column: 0]

I seem to have an issue with coreapi.getTeams() service call that works from the raw Azure DevOps API service calls, but seems to be empty on the AzD service.

org.azd.exceptions.AzDException: ApiResponseParsingException: No content to map due to end-of-input
at [Source: (String)""; line: 1, column: 0]
at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:59) ~[azd-5.0.10.jar:na]
at org.azd.core.CoreApi.getTeams(CoreApi.java:357) ~[azd-5.0.10.jar:na]
at io.noda.adaptor.azuredevops.domain.AzureAdaptor.getTeams(AzureAdaptor.java:91) ~[classes/:na]

When a raw service call is done at browser:
https://dev.azure.com/rabbitearsvideoproduction/_apis/teams?api-version=7.1-preview.3
{
"value": [
{
"id": "553f1e11-ec5c-4ed3-81cb-71de6365e900",
"name": "The-Mongooses",
"url": "https://dev.azure.com/rabbitearsvideoproduction/_apis/projects/3a335c3a-bad0-4850-b46d-7942d45c239e/teams/553f1e11-ec5c-4ed3-81cb-71de6365e900",
"description": "",
"identityUrl": "https://spsprodcus5.vssps.visualstudio.com/Aff21754c-65bc-40f1-ae29-af385431d22a/_apis/Identities/553f1e11-ec5c-4ed3-81cb-71de6365e900",
"projectName": "Noda-Integration-AzureDevOps-adaptor",
"projectId": "3a335c3a-bad0-4850-b46d-7942d45c239e"
},
{
"id": "91ddb058-fbfb-4a14-b61c-09f8e4d6f1b3",
"name": "Noda-Integration-AzureDevOps Team",
"url": "https://dev.azure.com/rabbitearsvideoproduction/_apis/projects/4fcfd2af-a1da-44ee-bd48-ef80f837ae7d/teams/91ddb058-fbfb-4a14-b61c-09f8e4d6f1b3",
"description": "The default project team.",
"identityUrl": "https://spsprodcus5.vssps.visualstudio.com/Aff21754c-65bc-40f1-ae29-af385431d22a/_apis/Identities/91ddb058-fbfb-4a14-b61c-09f8e4d6f1b3",
"projectName": "Noda-Integration-AzureDevOps",
"projectId": "4fcfd2af-a1da-44ee-bd48-ef80f837ae7d"
},
{
"id": "dad01d92-2ae8-4824-9b2b-1cf4049268ae",
"name": "Noda-Integration-AzureDevOps-adaptor-TeamA",
"url": "https://dev.azure.com/rabbitearsvideoproduction/_apis/projects/3a335c3a-bad0-4850-b46d-7942d45c239e/teams/dad01d92-2ae8-4824-9b2b-1cf4049268ae",
"description": "The default project team.",
"identityUrl": "https://spsprodcus5.vssps.visualstudio.com/Aff21754c-65bc-40f1-ae29-af385431d22a/_apis/Identities/dad01d92-2ae8-4824-9b2b-1cf4049268ae",
"projectName": "Noda-Integration-AzureDevOps-adaptor",
"projectId": "3a335c3a-bad0-4850-b46d-7942d45c239e"
}
],
"count": 3
}

All other service calls seem to be working for me, so I am not completely sure it's PaT authority, but from the code, It looks like it checks for that.

Also there seems to be a data type miss-match with the type on the 4 element Teams Get Call

https://learn.microsoft.com/en-us/rest/api/azure/devops/core/teams/get-all-teams?view=azure-devops-rest-7.1&tabs=HTTP
$mine is boolean on MS Azure DevOps API and is string in the AzD library

How to authenticate with REST API via OAuth

Most of the examples have the code authenticating with Azure via a PAT (Personal Access Token) but the application I'm writing runs as a background agent and syncs Azure with another system. I saw in the Connection class there is a way to pass the AuthorizedToken object to get an OAuth connection but I wasn't 100% sure if I had the steps correct (starting with OAuthApi.getAuthorizationEndpoint?).

Do you have a Java sample of how to connect via OAuth you could post? I currently have the tenant Id, client id and client secret of the application as defined in Azure. Do I need other pieces of information?

Add ability to get Retry-After value in response header

Add ability to get Retry-After value in response header.

When making a large number of API calls in a short period of time (such as creating new Releases) that cause one to exceed Azure limits on CPU usage via API usage, and before the request(s) get delayed / denied the server will return a Retry-After value in the response header.

I will open a pull request that can achieve this using minimal code changes, but am open to a better way of doing this too :-)

MIssing visibility enum value

Issue Template

Looks like "organization" is a valid ProjectVisibility?

org.azd.exceptions.AzDException: ApiResponseParsingException: Cannot deserialize value of type org.azd.enums.ProjectVisibility from String "organization": not one of the values accepted for Enum class: [public, private, unchanged]

Steps to reproduce

// get the list of projects
            core.getProjects();

Expected behavior


Actual behavior


Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.

  • [x ] Bug Description Added
  • [ x] Reproduce Steps Added
  • [x ] Expected Behaviour Added
  • [ x] Actual Behaviour Added

Json mapping issue when trying to read builds that couldn't run

Issue Template

Hi,

We get this error:
org.azd.exceptions.AzDException: ApiResponseParsingException: Cannot construct instance of org.azd.build.types.ValidationResult (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('error')
at [Source: (StringReader); line: 1, column: 5734] (through reference chain: org.azd.build.types.Builds["value"]->java.util.ArrayList[1]->org.azd.build.types.Build["validationResults"]->java.util.ArrayList[0]->org.azd.build.types.BuildRequestValidationResult["result"])
at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:49) ~[azd-5.0.4.jar:?]

When trying to get builds. This occurs when we have a pipeline run that failed to start (by errors in yaml syntax or, in this case service account suspended).

image

image

Response from azure devops:

      "validationResults": [
        {
          "result": "error",
          "message": "The pipeline is not valid. Could not get the latest source version for repository XXXX hosted on https://github.com/ using ref refs/tags/v3. GitHub reported the error, \"Sorry. Your account was suspended.\""
        }
      ],
  • You should provide a description for the bug
  • Add exception message and stacktrace if available
  • Please attach screen captures if available
  • Additionally, you can specify your OS version, IDE you are using and the SDK version

Steps to reproduce

Run a pipeline with invalid yaml or service account disabled.

Expected behavior


Actual behavior


Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

[Feature] Missing Pull Request Statuses object

Hi, first of all, thank you for your work, it's amazing!

Using this library, I have found that it's missing the Pull Request Statuses object (i.e. GitPullRequestStatus[es]), to get the status of a pull request's checks.

I refer to this:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-request-statuses?view=azure-devops-rest-7.0

having this, would be possible to list the pull request statuses:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-request-statuses/list?view=azure-devops-rest-7.0&tabs=HTTP
or get a specific pull request status:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-request-statuses/get?view=azure-devops-rest-7.0&tabs=HTTP

And it would help to verify a pull request check.

One more time: thank you for your work!

Do you support pagination with the continuationToken

Hi

First thanks for this project very helpful and very clean code!!!!

I saw in the code that there are some calls that do support the continuation token as a param but I was wondering if you return the next continuation token in the response as well so it can be used in the next call?

Thanks again

Get stages from pipeline run?

Hi,

I need to fetch which stages there are for a pipeline run and their statuses.
For example I want to get if the Test and Prod stages was succeeded or not for an runId.

I tried to search the source but as far as I could see this is not supported?
I can help implementing this but could appreciate some hints in where it should be implemented and naming conventions etc.

Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields
otherwise the issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

Parsing exception for ReleaseDefinition that has an an Environment that has Conditions.

Issue Template

A parsing exception occurs when getting a ReleaseDefinition that has an an Environment that has Conditions. Exception below:

org.azd.exceptions.AzDException: ApiResponseParsingException: Cannot construct instance of org.azd.release.types.ConditionType (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('event')
at [Source: (StringReader); line: 1, column: 11013] (through reference chain: org.azd.release.types.ReleaseDefinition["environments"]->java.util.ArrayList[0]->org.azd.release.types.ReleaseDefinitionEnvironment["conditions"]->java.util.ArrayList[0]->org.azd.release.types.Condition["conditionType"])
at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:49)
at org.azd.release.ReleaseApi.getReleaseDefinition(ReleaseApi.java:430)

Will submit a PR for this as the fix is simple. We should be using the corresponding enum instead of a class.

Steps to reproduce

Create a Release Definition that has an Environment that has one ore more conditions.

Expected behavior

No exception should occur (and the Release Definition should be successfully fetched/parsed from server

Actual behavior

Exception occurs

Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

Release Condition conditionType is an object but should be an enum

With version 5.0.2 the API parsing fails for an expanded release with tasks. This is due to Jackson failing to deserialize the ConditionType in the release condition.
This is call

Release expandedRelease = azDClientApi.getReleaseApi().getRelease(release.getId(), SingleReleaseExpands.TASKS);

is throwing

ApiResponseParsingException: Cannot construct instance of `org.azd.release.types.ConditionType` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('event')
 at [Source: (StringReader); line: 1, column: 3340] (through reference chain: org.azd.release.types.Release["environments"]->java.util.ArrayList[0]->org.azd.release.types.ReleaseEnvironment["conditions"]->java.util.ArrayList[0]->org.azd.release.types.ReleaseCondition["conditionType"])

The error comes down to the class org.azd.release.types.Condition referencing org.azd.release.types.ConditionType but the expected result for API version 7.1 is an enum
ConditionType enum

See conditionType here in json response

            "conditions": [
                {
                    "result": false,
                    "name": "ReleaseStarted",
                    "conditionType": "event",
                    "value": ""
                },

Announcement!!!

📢 Announcement!!! ❗❗

Version 6.0 introduces some breaking changes to the library. This is a complete re-write to make azd more robust, easy to extend and use. Currently azd uses single Client Api class per Azure DevOps Api (such as BuildApi, CoreApi, GitApi etc..), this is splitted into request builders to provide a declarative syntax and fluent Api style coding experience with single client instance to construct and execute the request.

v6.0 introduces additional configurations such as,

  • Organization url is not hard coded, so the request can be constructed for Azure DevOps Services as well TFS server.
  • Default retry mechanism.
  • Pagination.
  • Proxy configuration.

What is changing?

Api Link Details
Connection Connection Deprecated
AzDAsyncApi AzDAsyncApi Deprecated
BaseRestClient BaseRestClient Deprecated
RestClient RestClient Deprecated
RestClientProvider RestClientProvider Deprecated
JsonMapper JsonMapper Deprecated
AzDService AzDService New
OAuthAccessTokenBuilder OAuthAccessTokenBuilder New
AccessTokenCredential AccessTokenCredential New
ClientRequest ClientRequest New

Features

v6.0 brings new features and functionalities.

  • Authentication: AccessTokenCredential interface provides the functionality of choosing the authentication provider. Currently azd supports Personal access token and OAuth on-behalf of authentication.
  • Json -> POJO and viceversa: SerializerContext interface provides the serialization and deserialization functionalities.
  • Paged response/continuation token: All the collects that derives from SerializableCollectionEntity exposes getNextPageLink() method which returns next page based link if continuation token is found in the header.

Note that, some Apis return link:rel=next; in the header and it is not managed by getNextPageLink() method. Instead use getResponse().getResponseHeaders() which returns the HttpResponseHeader object to retrieve the URL.

  • ClientRequest: ClientRequest is responsible for sending and executing the request and deserializing the response.
  • Client object: AzDServiceClient helps to create the client object and demands authentication provider.
  • Declarative syntax: Unlike the Legacy Apis such as BuildApi, GitApi or CoreApi, the client object created using AzDServiceClient can be used to construct the requests and get the response back. See below for example.
  • TFS or Azure DevOps server support: Support for TFS and Azure DevOps services.

Why changing now?

With the help of community contributors the functionalities of azd has grown huge, to make the code base maintaintable, easy to use, and align the usage more close to Azure DevOps Api. Also, v6.0 introduces declarative syntax to query the Api.

A glimpse of the usage:

// 1. Choose the authentication provider;
// AccessTokenCredential interface has few implementations.
// --> PersonalAccessTokenCredential - Use with your personal access token.
// --> OAuthAccessTokenCredential - Use for on-behalf of user and generate access token aka jwt.
// --> OAuthAccessTokenCredential provides automatic token refresh functionality.

// For Azure DevOps Services or TFS server the authentication provider object can be created as below
// https://dev.azure.com/{organization}
// https://server:port/tfs/{collection}
var oauthTokenCredential = new OAuthAccessTokenCredential(organizationUrl, projectName, appSecret, authCode, callbackUrl);
var personalAccessTokenCredential = new PersonalAccessTokenCredential(organizationUrl, project, personalAccessToken);


// 2. Create the client object with choosen authentication provider.
AzDServiceClient client = AzDService.builder()
    .authentication(personalAccessTokenCredential)
    .buildClient();
//or
AzDServiceClient client = AzDService.builder()
    .authentication(oauthTokenCredential)
    .buildClient();

// Single client instance and declarative syntax.
client.core().projects().list(); 

// Usage with query parameters.
client.core().projects().list(config -> {
    config.queryParameters.top = 100;
    config.queryParameters.stateFilter = ProjectState.ALL;
    config.queryParameters.getDefaultTeamImageUrl = true;
    config.queryParameters.skip = 10;
});

// All the Apis have overloaded methods that returns a CompletableFuture<> object.
client.core().projects().listAsync();

What happens to legacy Apis?

Legacy Apis are not going to change and will remain as is, indeed the internal implementations are going to change. The Legacy Apis will implement the new functionalities internally thus providing same output as before. Due to the deprecation of Apis that are used by Legacy Apis a minimal code change is required if you're using any of the Deprecated Apis. It is highly recommended that you move to new implementation.

PS: Latest code can be found here.

Repository size field does not support long values.

If retrieving repositories with where the size of the repository is rather large, then the JSON object mapping fails with the following exception:

Exception in thread "main" org.azd.exceptions.AzDException: ApiResponseParsingException: Numeric value (39027429139) out of range of int (-2147483648 - 2147483647)
 at [Source: (StringReader); line: 1, column: 261214] (through reference chain: org.azd.git.types.Repositories["value"]->java.util.ArrayList[270]->org.azd.git.types.Repository["size"])

Steps to reproduce

Run the following Java code:

public class Example {

    public static void main(String[] args) throws AzDException {
        var organisation = "<my org>";
        var personalAccessToken = "<access code>";
        var webApi = new AzDClientApi(organisation, personalAccessToken);
        var core = webApi.getCoreApi();
        System.out.println(webApi.getGitApi().getRepositories());
    }
}

Have a large Git repository. For example the following JSON response on the repositories API:

{
  "value": [
    ...
    {
      "id": "<private>",
      "name": "<private>",
      "url": "<private>",
      "project": {
        ...
      },
      "size": 39027429139,
      ...
    }
    ...
  ]
}

Expected behavior

Status code 0

Actual behavior

Exception was raised by `JsonMapper`

Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields
otherwise the issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

[Improvement] Add ability for GitApi.getRepositories() to include hidden repositories

This is a wonderful library and I'm using it weekly to extract a bunch of interesting insights for my organization - thank you!

One thing I noticed about GitApi's getRepositories() method is that it doesn't allow one to set the includeHidden switch, which I believe is necessary to include Wiki repos in search results without calling getRepository(repoName) explicitly. This means I have to perform a few more steps to search for Wikis, then iterate through each one to get the remote URLs for further cloning and analysis. Someone else may also like to specify includeAllUrls and includeLinks as well, so I'm wondering if you could leave the existing getRepositories() method alone and add a convenience method that accepts those three switches?

Thank you in advance - this is a genuinely useful library! - Scott

GitPullRequest getCommits() is always null

Issue Template

When calling the git API, the getCommits() always returns null:

        AzDClientApi webApi = new AzDClientApi(Constants.ORGANIZATION_NAME, Constants.PROJECT_NAME, Constants.PERSONAL_ACCESS_TOKEN);
        GitApi git = webApi.getGitApi();
        PullRequests pullRequests = git.getPullRequests(Constants.REPO_NAME);
        List<GitPullRequest> gitPullRequests = pullRequests.getPullRequests();
        if (gitPullRequests == null) {
            return;
        }
        for (GitPullRequest gitPullRequest : gitPullRequests) {
            List<GitCommitRef> commits = gitPullRequest.getCommits();
// commits is always null

i tried with 5.0.10 and i also tried with 6.0.0-SNAPSHOT.

what am i doing wrong?

my goal is, to get all changed files from a pull request, to analyze the path of the files and add labels.

adding labels works fine:
git.createPullRequestLabel(Constants.REPO_NAME, gitPullRequest.getPullRequestId(), "azd-tooling-test-feature-xyz");

[Improvement] Add more examples to GitApi.md

Hi, first of all: thank you for your work! :)

Your library was helpful, same way as your examples.

When I started to use your library, it was helpful this example document:
https://github.com/hkarthik7/azure-devops-java-sdk/blob/main/examples/GitApi.md

I detected some lack of examples. For example, some examples to do a simple case, as:

  1. create new branch
  2. get existing file, update its content and commit changes
  3. create pull request from new branch to main branch

or
4. delete branch from point 2

it would be nice to have this kind of examples in the file.

as example:

// create branch
var git = webApi.getGitApi();
String newBranch = "branch_name";
String mainBranchId = git.getBranch(repositoryName, branchName).getObjectId();
String oldBranchId = "0000000000000000000000000000000000000000"; // Azure rules ¯_(ツ)_/¯
GitRefUpdateResult gitRefUpdateResult = git.updateRef(repositoryName, "refs/heads/" + newBranchName, oldBranchId, mainBranchId);

// commit
GitPush gitPush = new GitPush();
gitPush.setCommits(gitCommitRefList);
gitPush.setRefUpdates(gitRefUpdateList);
git.createPush(repoId, gitPush);

// create pull request
GitPullRequest gitPullRequest = new GitPullRequest();
gitPullRequest.setDescription("PR test description");
gitPullRequest.setIsDraft(false);
gitPullRequest.setLabels(new ArrayList<>());
gitPullRequest.setReviewers(new ArrayList<>());
gitPullRequest.setSourceRefName("refs/heads/" + newBranch);
gitPullRequest.setTargetRefName("refs/heads/main");
gitPullRequest.setTitle("PR title");
gitPullRequest.setRepository(repository);
GitPullRequest gitPullRequestOutput = git.createPullRequest(gitPullRequest);

// delete branch
String deleteBranchId = "0000000000000000000000000000000000000000"; // Azure rules ¯_(ツ)_/¯
String oldObjectId = git.getBranch(sepositoryName, branchToDeleteName).getObjectId();
gitRefUpdateResult = git.updateRef(repositoryName, "refs/heads/" + branchToDeleteName, oldObjectId, deleteBranchId);

Can I implement deleteTag or deleteBranch method?

Hello.

Azure Devops Rest API does not provide Create/Delete Tag(not annotate) or Create/Delete Branch.
However, it can be implemented through updateRefs, Is it ok if I implement the method?

https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/update-refs?view=azure-devops-rest-7.1

Below is the expected implementation.
image

Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields
otherwise the issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

Support for Android

Hi Karthik,
Thanks for the hard work!
I think this is a great azure devops java library
I was wondering if there'll be support for Android?

Have a nice day!

Enhance the API to connect to on premise Azure DevOps server

The current SDK can only connect to Azure DevOps in the cloud - looking at the code this looks like it is due to the Instance.BASE_INSTANCE value hard-coded to 'BASE_INSTANCE("https://dev.azure.com/")'

This value in-turn is used by RestClientProvider getLocationUrl(String resourceID, String organizationName) method that is used to connect to the ADO endpoints

As the various connection APIs mainly pass the organizationName and projectName parameters and changing the signature will be cumbersome and invasive a hack could be just changing the getLocationUrl method - if the organizationName is a full url (starting with https://....) you could keep the value unchanged otherwise prepend with the BASE_INSTANCE

queueBuild with parameters issue

Not able to trigger buildDefinition with buildParameters

Steps to reproduce

my definitionId is 162

queue build like in the example
build.queueBuild(162);
works

but with parameters not.

java sample code

var parameters = new HashMap<String, Object>();
BuildDefinition def = new BuildDefinition();
def.setId(162);
parameters.put("definition", def);
parameters.put("key1", "value1");
build.queueBuild(parameters);

Expected behavior

build triggered with parameter

Actual behavior

Message

DefinitionNotFoundException: Build pipeline 162 was not found.

Possible to compile with Java 8

When building azd from the command line using Maven it requires that Java 11 or higher is used to build the jar.

The problem I'm having is I would like to use the jar as part of a script library in HCL Domino however unfortunately the latest release (Domino 12.0.2) only supports up to Java 8 so when the jar is loaded it errors out.

Is there any way the azd jar could be built with Java 8 (even if I had to lose some functionality)? I only need the WorkItem/WorkItemTracking functionality to sync issues from a Notes-based database to Azure DevOps.

GitRepository does not support repositories with size greater than 2147483647 bytes

Issue Template

I'm tring to clone a very large repository ( ~30Gb ) but I got the following error :

org.azd.exceptions.AzDException: ApiResponseParsingException: Numeric value (30134050676) out of range of int (-2147483648 - 2147483647)
at [Source: (String)"{"id":"7dc78671-3aca-4f78-adb7-06d5c183a1cb","name":"XXXX","url":"XXXX","project":{"id":"XXXXX","name":"XXXXX","description":"XXXXX","url":"XXXXX","state":"wellFormed","revision":2665,"visibility":"priva"[truncated 1531 chars]; line: 1, column: 604] (through reference chain: org.azd.git.types.GitRepository["size"])
at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:49) ~[azd-5.0.6.jar:na]
at org.azd.git.GitApi.getRepository(GitApi.java:135) ~[azd-5.0.6.jar:na]

Library version : 5.0.6

This issue is the same reported here : #13
Possible solution : change the type of the size field from Integer to Long in class GitRepository ( package org.azd.git.types )

Steps to reproduce

AzDClientApi azDClientApi = new AzDClientApi("xxxx", "xxxxx", "xxxxx");
GitRepository gitRepository = azDClientApi.getGitApi().getRepository(""); // repository size must be > 2Gb

Expected behavior

No Exception raised and the JSON provided by Azure DevOps is correctly mapped in the GitRepository class

Actual behavior

Exception org.azd.exceptions.AzDException: ApiResponseParsingException raised

Information Checklist

Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.

  • Bug Description Added
  • Reproduce Steps Added
  • Expected Behaviour Added
  • Actual Behaviour Added

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.