Search in sources :

Example 21 with Policy

use of com.google.api.services.healthcare.v1.model.Policy in project workbench by all-of-us.

the class IamServiceImpl method grantServiceAccountUserRole.

private void grantServiceAccountUserRole(String googleProject, String petServiceAccount) {
    Policy policy = cloudIamClient.getServiceAccountIamPolicy(googleProject, petServiceAccount);
    List<Binding> bindingList = Optional.ofNullable(policy.getBindings()).orElse(new ArrayList<>());
    bindingList.add(new Binding().setRole(SERVICE_ACCOUNT_USER_ROLE).setMembers(Collections.singletonList("serviceAccount:" + petServiceAccount)));
    cloudIamClient.setServiceAccountIamPolicy(googleProject, petServiceAccount, policy.setBindings(bindingList));
}
Also used : Policy(com.google.api.services.iam.v1.model.Policy) Binding(com.google.api.services.iam.v1.model.Binding)

Example 22 with Policy

use of com.google.api.services.healthcare.v1.model.Policy in project java-docs-samples by GoogleCloudPlatform.

the class Hl7v2StoreGetIamPolicy method hl7v2StoreGetIamPolicy.

public static void hl7v2StoreGetIamPolicy(String hl7v2StoreName) throws IOException {
    // String hl7v2StoreName =
    // String.format(
    // HL7v2_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-hl7v2-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Create request and configure any parameters.
    Hl7V2Stores.GetIamPolicy request = client.projects().locations().datasets().hl7V2Stores().getIamPolicy(hl7v2StoreName);
    // Execute the request and process the results.
    Policy policy = request.execute();
    System.out.println("HL7v2 store IAMPolicy retrieved: \n" + policy.toPrettyString());
}
Also used : Policy(com.google.api.services.healthcare.v1.model.Policy) Hl7V2Stores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 23 with Policy

use of com.google.api.services.healthcare.v1.model.Policy in project java-docs-samples by GoogleCloudPlatform.

the class DatasetGetIamPolicy method datasetGetIamPolicy.

public static void datasetGetIamPolicy(String datasetName) throws IOException {
    // String datasetName =
    // String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Create request and configure any parameters.
    Datasets.GetIamPolicy request = client.projects().locations().datasets().getIamPolicy(datasetName);
    // Execute the request and process the results.
    Policy policy = request.execute();
    System.out.println("Dataset IAMPolicy retrieved: \n" + policy.toPrettyString());
}
Also used : Datasets(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets) Policy(com.google.api.services.healthcare.v1.model.Policy) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 24 with Policy

use of com.google.api.services.healthcare.v1.model.Policy in project java-docs-samples by GoogleCloudPlatform.

the class DatasetSetIamPolicy method datasetSetIamPolicy.

public static void datasetSetIamPolicy(String datasetName) throws IOException {
    // String datasetName =
    // String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Configure the IAMPolicy to apply to the dataset.
    // For more information on understanding IAM roles, see the following:
    // https://cloud.google.com/iam/docs/understanding-roles
    Binding binding = new Binding().setRole("roles/healthcare.datasetViewer").setMembers(Arrays.asList("domain:google.com"));
    Policy policy = new Policy().setBindings(Arrays.asList(binding));
    SetIamPolicyRequest policyRequest = new SetIamPolicyRequest().setPolicy(policy);
    // Create request and configure any parameters.
    Datasets.SetIamPolicy request = client.projects().locations().datasets().setIamPolicy(datasetName, policyRequest);
    // Execute the request and process the results.
    Policy updatedPolicy = request.execute();
    System.out.println("Dataset policy has been updated: " + updatedPolicy.toPrettyString());
}
Also used : Binding(com.google.api.services.healthcare.v1.model.Binding) Policy(com.google.api.services.healthcare.v1.model.Policy) Datasets(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets) SetIamPolicyRequest(com.google.api.services.healthcare.v1.model.SetIamPolicyRequest) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Example 25 with Policy

use of com.google.api.services.healthcare.v1.model.Policy in project java-docs-samples by GoogleCloudPlatform.

the class FhirStoreGetIamPolicy method fhirStoreGetIamPolicy.

public static void fhirStoreGetIamPolicy(String fhirStoreName) throws IOException {
    // String fhirStoreName =
    // String.format(
    // FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Create request and configure any parameters.
    FhirStores.GetIamPolicy request = client.projects().locations().datasets().fhirStores().getIamPolicy(fhirStoreName);
    // Execute the request and process the results.
    Policy policy = request.execute();
    System.out.println("FHIR store IAMPolicy retrieved: \n" + policy.toPrettyString());
}
Also used : Policy(com.google.api.services.healthcare.v1.model.Policy) FhirStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare)

Aggregations

Policy (com.google.api.services.cloudresourcemanager.v3.model.Policy)15 IOException (java.io.IOException)14 Binding (com.google.api.services.cloudresourcemanager.v3.model.Binding)11 GetIamPolicyRequest (com.google.api.services.cloudresourcemanager.v3.model.GetIamPolicyRequest)8 CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)8 Policy (com.google.api.services.healthcare.v1.model.Policy)8 Policy (com.google.api.services.iam.v1.model.Policy)7 CloudKMS (com.google.api.services.cloudkms.v1.CloudKMS)6 Policy (com.google.api.services.cloudkms.v1.model.Policy)6 Test (org.junit.jupiter.api.Test)6 FlightMap (bio.terra.stairway.FlightMap)5 SetIamPolicyRequest (com.google.api.services.cloudresourcemanager.v3.model.SetIamPolicyRequest)4 Binding (com.google.api.services.healthcare.v1.model.Binding)4 SetIamPolicyRequest (com.google.api.services.healthcare.v1.model.SetIamPolicyRequest)4 Binding (com.google.api.services.iam.v1.model.Binding)4 SetIamPolicyRequest (com.google.api.services.iam.v1.model.SetIamPolicyRequest)4 ArrayList (java.util.ArrayList)4 ServiceAccountName (bio.terra.cloudres.google.iam.ServiceAccountName)3 StepResult (bio.terra.stairway.StepResult)3 Binding (com.google.api.services.cloudkms.v1.model.Binding)3