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();
}
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());
}
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;
}
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());
}
}
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;
}
}
Aggregations