use of org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.Project in project camel by apache.
the class ProjectProducer method doUpdate.
private void doUpdate(Exchange exchange) {
final Message msg = exchange.getIn();
final Project in = messageToProject(msg);
final Project out = osV3Client.identity().projects().update(in);
msg.setBody(out);
}
use of org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.Project in project camel by apache.
the class ProjectProducer method messageToProject.
private Project messageToProject(Message message) {
Project project = message.getBody(Project.class);
if (project == null) {
Map headers = message.getHeaders();
ProjectBuilder builder = Builders.project();
ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
if (headers.containsKey(KeystoneConstants.DOMAIN_ID)) {
builder.domainId(message.getHeader(KeystoneConstants.DOMAIN_ID, String.class));
}
if (headers.containsKey(KeystoneConstants.DESCRIPTION)) {
builder.description(message.getHeader(KeystoneConstants.DESCRIPTION, String.class));
}
if (headers.containsKey(KeystoneConstants.PARENT_ID)) {
builder.parentId(message.getHeader(KeystoneConstants.PARENT_ID, String.class));
}
project = builder.build();
}
return project;
}
use of org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.Project in project camel by apache.
the class ProjectProducer method doGet.
private void doGet(Exchange exchange) {
final Message msg = exchange.getIn();
final String id = msg.getHeader(OpenstackConstants.ID, String.class);
ObjectHelper.notEmpty(id, "Project ID");
final Project result = osV3Client.identity().projects().get(id);
msg.setBody(result);
}
use of org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.Project in project camel by apache.
the class ProjectProducerTest method setUp.
@Before
public void setUp() {
producer = new ProjectProducer(endpoint, client);
when(projectService.create(any(Project.class))).thenReturn(testOSproject);
when(projectService.get(anyString())).thenReturn(testOSproject);
List<Project> getAllList = new ArrayList<>();
getAllList.add(testOSproject);
getAllList.add(testOSproject);
doReturn(getAllList).when(projectService).list();
dummyProject = createProject();
when(testOSproject.getName()).thenReturn(dummyProject.getName());
when(testOSproject.getDescription()).thenReturn(dummyProject.getDescription());
}
use of org.eclipse.persistence.testing.models.jpa.composite.advanced.member_3.Project in project java-docs-samples by GoogleCloudPlatform.
the class SetUsageExportBucket method getUsageExportBucket.
// [END compute_usage_report_set]
// [START compute_usage_report_get]
// Retrieve Compute Engine usage export bucket for the Cloud project.
// Replaces the empty value returned by the API with the default value used
// to generate report file names.
public static UsageExportLocation getUsageExportBucket(String project) throws IOException {
try (ProjectsClient projectsClient = ProjectsClient.create()) {
// Get the usage export location for the project from the server.
Project projectResponse = projectsClient.get(project);
// used to generate report file names.
if (projectResponse.hasUsageExportLocation()) {
UsageExportLocation usageExportLocation = projectResponse.getUsageExportLocation();
// Verify that the server explicitly sent the optional field.
if (usageExportLocation.hasReportNamePrefix()) {
String reportNamePrefix = usageExportLocation.getReportNamePrefix();
if (reportNamePrefix.length() == 0) {
// Although the server explicitly sent the empty string value,
// the next usage report generated with these settings still has the default
// prefix value "usage_gce".
// (see, https://cloud.google.com/compute/docs/reference/rest/v1/projects/get)
reportNamePrefix = "usage_gce";
System.out.println("Report name prefix not set, replacing with default value of `usage_gce`.");
}
}
return usageExportLocation;
} else {
// The usage reports are disabled.
return null;
}
}
}
Aggregations