gcpdiag.queries.artifact_registry
Queries related to GCP Artifact Registry
26class ArtifactRegistryIAMPolicy(iam.BaseIAMPolicy): 27 28 def _is_resource_permission(self, permission): 29 return True
Common class for IAM policies
@dataclasses.dataclass
class
ProjectSettings:
@caching.cached_api_call(in_memory=True)
def
get_registry_iam_policy( project_id: str, location: str, registry_name: str) -> ArtifactRegistryIAMPolicy:
37@caching.cached_api_call(in_memory=True) 38def get_registry_iam_policy(project_id: str, location: str, 39 registry_name: str) -> ArtifactRegistryIAMPolicy: 40 ar_api = apis.get_api('artifactregistry', 'v1', project_id) 41 registry_id = 'projects/{}/locations/{}/repositories/{}'.format( 42 project_id, location, registry_name) 43 request = ar_api.projects().locations().repositories().getIamPolicy( 44 resource=registry_id) 45 return iam.fetch_iam_policy(request, ArtifactRegistryIAMPolicy, project_id, 46 registry_id)
@caching.cached_api_call(in_memory=True)
def
get_project_settings(project_id: str) -> ProjectSettings:
49@caching.cached_api_call(in_memory=True) 50def get_project_settings(project_id: str) -> ProjectSettings: 51 ar_api = apis.get_api('artifactregistry', 'v1', project_id) 52 response = ar_api.projects().getProjectSettings( 53 name=f'projects/{project_id}/projectSettings').execute( 54 num_retries=config.API_RETRIES) 55 return ProjectSettings(legacy_redirect=response.get('legacyRedirectionState') 56 == 'REDIRECTION_FROM_GCR_IO_ENABLED')