How to add multiple reposiroties at once/ bulk import?

Hi,

I have phabricator up and running. How do I add multiple repositories/do a bulk import from bitbucket?
I can do an import by creating a repo, adding a URI and then activating/updating the repo but I have a large number of repos in bitbucket and manually adding each repo and URI is a pain. Conduit API reference mentions to use it for bulk imports but I can’t seem to figure out how to do a bulk operation. Any help?

I would write a script that gets the list of repositories from bitbucket and then adds each of them to phabricator via the conduit api.

You can creaete repositories with diffusion.repository.edit, and then you can add the bitbucket uri via a diffusion.uri.edit call, or make your script just git push the old repository to phabricator.

Hey.

I am able to fetch the list of repos from bitbucket via API. When writing the transactions for conduit, it is not able to add all the repos using diffusion.repository.edit. Could you give me an idea of how the transactions should look like in json for adding at least two repos at once?

It doesn’t look to me, as if you can edit / create more than one object at once with conduit. You will most likely have your script do multiple requests.

But because people generally don’t create a lot of repositories all the time this shouldn’t be a problem

https://secure.phabricator.com/book/phabricator/article/diffusion_api/

This URl suggests that we can use the stated diffusion methods when trying to import bulk/multiple repos. Not sure how to do it if conduit doesn’t support it.

I think the text in the docs want to say, that you can use the api by a script and have the script perform the bulk action.

And just in the case it’s actually possible to create multiple repos in one request it would most likely just be done by POSTing a list of objects that just contain a transaction object.

$ echo '[
    {
      "transactions": [
        {
          "type": "vcs",
          "value": "git"
        },
        {
          "type": "name",
          "value": "Repo1"
        }
      ]
    },
    {
      "transactions": [
        {
          "type": "vcs",
          "value": "git"
        },
        {
          "type": "name",
          "value": "Repo2"
        }
      ]
    }
]' | arc call-conduit diffusion.repository.edit

But I don’t think that will work.

There’s no way to bulk-edit or bulk-create objects from the .edit endpoints. There might be a way to do bulk updates in the future from the API, but even that would likely not support creating multiple items, or giving different values to different objects.
The only way to do this right now is by making a separate API call for each object, as @Info-Screen suggests.