v2 deploy keys API inconsistencies

Issue #17907 resolved
John Stockbauer created an issue

We've run into a few issues with these new v2 routes where the documentation doesn't match the functionality and are hoping to have these addressed in some way.

  • GET /2.0/repositories/{username}/{repo_slug}/deploy-keys returns the array of keys, but none of them contain the "pk" field as documented. The pk can be obtained by parsing the "links.self.href" but that is not ideal.
  • POST /2.0/repositories/{username}/{repo_slug}/deploy-keys returns an object that does not contain the "pk" field. It does contain an "id" field, which is not documented, but this field is not the same as "pk". You can't use it for a GET or a DELETE. I'm not sure what it's the ID of. Ideally POST would return the pk.
  • GET /2.0/repositories/{username}/{repo_slug}/deploy-keys/{pk} does correctly return the "pk" field (though it's not particularly useful in this case since you must've already known it)
  • DELETE seems to behave as expected once you have the correct pk.

Comments (4)

  1. Ben Chavet

    POST /2.0/repositories/{username}/{repo_slug}/deploy-keys returns an object that does not contain the "pk" field. It does contain an "id" field, which is not documented, but this field is not the same as "pk". You can't use it for a GET or a DELETE. I'm not sure what it's the ID of. Ideally POST would return the pk.

    This is a major blocker for us. We cannot finish our 2.0 API migration until this is fixed.

  2. Sean Conaty staff

    Thanks for reporting this issue. A fix is on its way, including some potentially breaking changes. I'll update when they are live.

    Changes include

    • fixing the key IDs so they work--the id property should match what's in links.self.href for all methods
    • updating the documentation--pk is not a property. It should be id
    • paginating the list. GET /deploy-keys returns a paginated_deploy_keys object with a values property.
    • repository property will be an object, not a string.

    Example: $ curl -H "Authorization <auth header>" https://api.bitbucket.org/2.0/repositories/mleu/test/deploy-keys

    Output:

    {
        "pagelen": 10,
        "values": [
            {
                "id": 123,
                "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAK/b1cHHDr/TEV1JGQl+WjCwStKG6Bhrv0rFpEsYlyTBm1fzN0VOJJYn4ZOPCPJwqse6fGbXntEs+BbXiptR+++HycVgl65TMR0b5ul5AgwrVdZdT7qjCOCgaSV74/9xlHDK8oqgGnfA7ZoBBU+qpVyaloSjBdJfLtPY/xqj4yHnXKYzrtn/uFc4Kp9Tb7PUg9Io3qohSTGJGVHnsVblq/rToJG7L5xIo0OxK0SJSQ5vuId93ZuFZrCNMXj8JDHZeSEtjJzpRCBEXHxpOPhAcbm4MzULgkFHhAVgp4JbkrT99/wpvZ7r9AdkTg7HGqL3rlaDrEcWfL7Lu6TnhBdq5",
                "label": "mykey",
                "type": "deploy_key",
                "created_on": "2018-08-15T23:50:59.993890+00:00",
                "repository": {
                    "full_name": "mleu/test",
                    "name": "test",
                    "type": "repository",
                    "uuid": "{85d08b4e-571d-44e9-a507-fa476535aa98}"
                },
                "links":{
                    "self":{
                        "href": "https://api.bitbucket.org/2.0/repositories/mleu/test/deploy-keys/123"
                    }
                }
                "last_used": null,
                "comment": "mleu@C02W454JHTD8"
            }
        ],
        "page": 1,
        "size": 1
    }
    
  3. Log in to comment