Search in sources :

Example 26 with Project

use of com.google.api.services.cloudresourcemanager.v3.model.Project in project uPMT by coco35700.

the class NewProjectDialogController method createProject.

public void createProject() {
    Project p = new Project(nomProjet.getText(), this.choixSchema.getValue());
    p.getSchema().setName(nomProjet.getText());
    main.setProjectInCreation(p);
    // main.getProjects().add(p);
    // main.setCurrentProject(p);
    // p.save();
    window.close();
    launchingScreenWindow.close();
// in case the center was set to null because of automatic interview Creation
/*if (main.getRootLayout().getCenter() == null) {
			main.launchMainView();
		}*/
// main.launchMainView();
// main.refreshDataTreeView();
// main.needToSave();
}
Also used : Project(model.Project)

Example 27 with Project

use of com.google.api.services.cloudresourcemanager.v3.model.Project in project uPMT by coco35700.

the class NewProjectDialogController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    // TODO Auto-generated method stub
    choixSchema.getItems().add(main.getDefaultSchema());
    for (Project p : main.getProjects()) {
        choixSchema.getItems().add(p.getSchema());
    }
    // change the text to make it pretty
    choixSchema.setConverter(new StringConverter<Schema>() {

        @Override
        public String toString(Schema object) {
            // TODO Auto-generated method stub
            return object.getName();
        }

        @Override
        public Schema fromString(String string) {
            // TODO Auto-generated method stub
            return new Schema(string);
        }
    });
    choixSchema.setValue(main.getDefaultSchema());
}
Also used : Project(model.Project) Schema(model.Schema)

Example 28 with Project

use of com.google.api.services.cloudresourcemanager.v3.model.Project in project java-docs-samples by GoogleCloudPlatform.

the class RemoveMember method removeMember.

// Removes member from a role; removes binding if binding contains 0 members.
public static void removeMember(Policy policy) {
    // policy = service.Projects.GetIAmPolicy(new GetIamPolicyRequest(), your-project-id).Execute();
    String role = "roles/existing-role";
    String member = "user:member-to-remove@example.com";
    List<Binding> bindings = policy.getBindings();
    Binding binding = null;
    for (Binding b : bindings) {
        if (b.getRole().equals(role)) {
            binding = b;
        }
    }
    if (binding.getMembers().contains(member)) {
        binding.getMembers().remove(member);
        System.out.println("Member " + member + " removed from " + role);
        if (binding.getMembers().isEmpty()) {
            policy.getBindings().remove(binding);
        }
        return;
    }
    System.out.println("Role not found in policy; member not removed");
    return;
}
Also used : Binding(com.google.api.services.cloudresourcemanager.v3.model.Binding)

Example 29 with Project

use of com.google.api.services.cloudresourcemanager.v3.model.Project in project java-docs-samples by GoogleCloudPlatform.

the class SetPolicy method setPolicy.

// Sets a project's policy.
public static void setPolicy(Policy policy, String projectId) {
    // policy = service.Projects.GetIAmPolicy(new GetIamPolicyRequest(), your-project-id).Execute();
    // projectId = "my-project-id"
    CloudResourceManager service = null;
    try {
        service = createCloudResourceManagerService();
    } catch (IOException | GeneralSecurityException e) {
        System.out.println("Unable to initialize service: \n" + e.toString());
        return;
    }
    try {
        SetIamPolicyRequest request = new SetIamPolicyRequest();
        request.setPolicy(policy);
        Policy response = service.projects().setIamPolicy(projectId, request).execute();
        System.out.println("Policy set: " + response.toString());
    } catch (IOException e) {
        System.out.println("Unable to set policy: \n" + e.toString());
    }
}
Also used : Policy(com.google.api.services.cloudresourcemanager.v3.model.Policy) CloudResourceManager(com.google.api.services.cloudresourcemanager.v3.CloudResourceManager) SetIamPolicyRequest(com.google.api.services.cloudresourcemanager.v3.model.SetIamPolicyRequest) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException)

Example 30 with Project

use of com.google.api.services.cloudresourcemanager.v3.model.Project in project java-docs-samples by GoogleCloudPlatform.

the class GetPolicy method getPolicy.

// Gets a project's policy.
public static Policy getPolicy(String projectId) {
    // projectId = "my-project-id"
    Policy policy = null;
    CloudResourceManager service = null;
    try {
        service = createCloudResourceManagerService();
    } catch (IOException | GeneralSecurityException e) {
        System.out.println("Unable to initialize service: \n" + e.toString());
        return policy;
    }
    try {
        GetIamPolicyRequest request = new GetIamPolicyRequest();
        policy = service.projects().getIamPolicy(projectId, request).execute();
        System.out.println("Policy retrieved: " + policy.toString());
        return policy;
    } catch (IOException e) {
        System.out.println("Unable to get policy: \n" + e.toString());
        return policy;
    }
}
Also used : Policy(com.google.api.services.cloudresourcemanager.v3.model.Policy) CloudResourceManager(com.google.api.services.cloudresourcemanager.v3.CloudResourceManager) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) GetIamPolicyRequest(com.google.api.services.cloudresourcemanager.v3.model.GetIamPolicyRequest)

Aggregations

Project (com.google.api.services.cloudresourcemanager.v3.model.Project)37 Test (org.junit.jupiter.api.Test)29 BaseIntegrationTest (bio.terra.buffer.common.BaseIntegrationTest)15 Pool (bio.terra.buffer.common.Pool)15 ResourceId (bio.terra.buffer.common.ResourceId)15 IntegrationUtils.preparePool (bio.terra.buffer.integration.IntegrationUtils.preparePool)15 FlightManager (bio.terra.buffer.service.resource.FlightManager)15 IOException (java.io.IOException)14 Binding (com.google.api.services.cloudresourcemanager.v3.model.Binding)10 StepStatus (bio.terra.stairway.StepStatus)9 ArrayList (java.util.ArrayList)9 BaseConnectedTest (bio.terra.workspace.common.BaseConnectedTest)8 List (java.util.List)8 DisabledIfEnvironmentVariable (org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)8 FlightDebugInfo (bio.terra.stairway.FlightDebugInfo)7 FlightState (bio.terra.stairway.FlightState)7 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)7 Project (com.blackducksoftware.bdio2.model.Project)7 GetIamPolicyRequest (com.google.api.services.cloudresourcemanager.v3.model.GetIamPolicyRequest)7 FlightMap (bio.terra.stairway.FlightMap)6