Search code examples
google-artifact-registry

Using Google.Cloud.ArtifactRegistry.V1Beta2 with parent - Permission problem


I wonder if anyone has used Google.Cloud.ArtifactRegistry.V1Beta2?

I am trying to create a console application with the api to list all Repositories in a project.

        ListRepositoriesRequest request = new ListRepositoriesRequest
        {
            Parent = "",
            PageSize = 1
        
        };
        var response = client.ListRepositories( request );

I have no indication what parent should be. The help just says "The name of the parent resource whose repositories will be listed". I have tried project name, project id but nothing works. I get the error "Permission denied" and I have full access as I am the owner of the project. Being lost what could be wrong, I suspect it could be the parent or does anyone has any idea where to look?


Solution

  • Sometimes the docs are not very clear but this one is very clear. If you look closer to the section HTTP request you will find

    GET https://artifactregistry.googleapis.com/v1beta2/{parent=projects/*/locations/*}/repositories
    

    So the parent is:

    {parent=projects/*/locations/*} -> projects/*/locations/*
    

    So, if you want to list repositories in us-central1 for example, your parent will be:

    ListRepositoriesRequest request = new ListRepositoriesRequest
            {
                Parent = "projects/YOUR_PROJECT_ID/locations/us-central1",
                PageSize = 1
            
            };
            var response = client.ListRepositories( request );
    

    So my advice is to inspect very well the docs.