use of com.google.cloud.asset.v1.ContentType in project geotoolkit by Geomatys.
the class OwcXmlIO method toEntry.
private static void toEntry(String parentPath, final MapItem item, List entries) {
final EntryType entry = ATOM_FACTORY.createEntryType();
entries.add(ATOM_FACTORY.createFeedTypeEntry(entry));
// store other informations
final String name = ((parentPath != null) ? parentPath : "") + item.getIdentifier();
final CharSequence title = item.getTitle();
final CharSequence abstrat = item.getAbstract();
if (name != null) {
final IdType atom = new IdType();
atom.setValue(name);
entry.getAuthorOrCategoryOrContent().add(ATOM_FACTORY.createEntryTypeId(atom));
}
if (title != null) {
final TextType atom = new TextType();
atom.setType(TextTypeType.TEXT);
atom.getContent().add(title.toString());
entry.getAuthorOrCategoryOrContent().add(ATOM_FACTORY.createEntryTypeTitle(atom));
}
if (abstrat != null) {
final TextType atom = new TextType();
atom.setType(TextTypeType.TEXT);
atom.getContent().add(abstrat.toString());
entry.getAuthorOrCategoryOrContent().add(ATOM_FACTORY.createEntryTypeSummary(atom));
}
if (item instanceof MapLayer) {
final MapLayer layer = (MapLayer) item;
entry.getAuthorOrCategoryOrContent().add(GEOTK_FACTORY.createVisible(layer.isVisible()));
entry.getAuthorOrCategoryOrContent().add(GEOTK_FACTORY.createOpacity(layer.getOpacity()));
OfferingType offering = null;
for (OwcExtension ext : getExtensions()) {
if (ext.canHandle(layer)) {
offering = ext.createOffering(layer);
entry.getAuthorOrCategoryOrContent().add(OWC_FACTORY.createOffering(offering));
break;
}
}
// store styles
if (offering != null) {
if (layer.getStyle() != null) {
final StyleSetType styleBase = toStyleSet(layer.getStyle(), true);
offering.getOperationOrContentOrStyleSet().add(OWC_FACTORY.createOfferingTypeStyleSet(styleBase));
}
}
} else if (item instanceof MapLayers) {
final MapLayers mc = (MapLayers) item;
final ContentType content = OWC_FACTORY.createContentType();
content.setType(mc.getIdentifier());
// encode children
for (MapItem child : mc.getComponents()) {
toEntry(name + "/", child, entries);
}
entry.getAuthorOrCategoryOrContent().add(OWC_FACTORY.createOfferingTypeContent(content));
}
}
use of com.google.cloud.asset.v1.ContentType in project geotoolkit by Geomatys.
the class OwcXmlIO method toStyleSet.
private static StyleSetType toStyleSet(Style style, boolean def) {
final StyleSetType styleSet = OWC_FACTORY.createStyleSetType();
styleSet.setDefault(def);
final ContentType content = OWC_FACTORY.createContentType();
final StyleXmlIO io = new StyleXmlIO();
final UserStyle jaxbStyle = io.getTransformerXMLv110().visit(style, null);
content.getContent().add(jaxbStyle);
styleSet.getNameOrTitleOrAbstract().add(OWC_FACTORY.createStyleSetTypeContent(content));
return styleSet;
}
use of com.google.cloud.asset.v1.ContentType in project java-asset by googleapis.
the class ExportAssetsBigqueryExample method exportBigQuery.
// Export assets to BigQuery for a project.
public static void exportBigQuery(String bigqueryDataset, String bigqueryTable, ContentType contentType, boolean isPerType) throws IOException, IllegalArgumentException, InterruptedException, ExecutionException {
try (AssetServiceClient client = AssetServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
OutputConfig outputConfig;
// Outputs to per-type BigQuery table.
if (isPerType) {
outputConfig = OutputConfig.newBuilder().setBigqueryDestination(BigQueryDestination.newBuilder().setDataset(bigqueryDataset).setTable(bigqueryTable).setForce(true).setSeparateTablesPerAssetType(true).setPartitionSpec(PartitionSpec.newBuilder().setPartitionKey(PartitionSpec.PartitionKey.READ_TIME).build()).build()).build();
} else {
outputConfig = OutputConfig.newBuilder().setBigqueryDestination(BigQueryDestination.newBuilder().setDataset(bigqueryDataset).setTable(bigqueryTable).setForce(true).build()).build();
}
ExportAssetsRequest request = ExportAssetsRequest.newBuilder().setParent(parent.toString()).setContentType(contentType).setOutputConfig(outputConfig).build();
ExportAssetsResponse response = client.exportAssetsAsync(request).get();
System.out.println(response);
}
}
use of com.google.cloud.asset.v1.ContentType in project java-asset by googleapis.
the class BatchGetAssetsHistoryExample method main.
// Export assets for a project.
// @param args path where the results will be exported to.
public static void main(String... args) throws Exception {
// Asset names, e.g.: "//storage.googleapis.com/[BUCKET_NAME]"
String[] assetNames = args[0].split(",");
try (AssetServiceClient client = AssetServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
TimeWindow readTimeWindow = TimeWindow.newBuilder().build();
BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder().setParent(parent.toString()).addAllAssetNames(Arrays.asList(assetNames)).setContentType(contentType).setReadTimeWindow(readTimeWindow).build();
BatchGetAssetsHistoryResponse response = client.batchGetAssetsHistory(request);
System.out.println(response);
}
}
use of com.google.cloud.asset.v1.ContentType in project java-asset by googleapis.
the class ListAssetsExample method listAssets.
public static void listAssets() throws IOException, IllegalArgumentException {
// The project id of the asset parent to list.
String projectId = "YOUR_PROJECT_ID";
// The asset types to list. E.g.,
// ["storage.googleapis.com/Bucket", "bigquery.googleapis.com/Table"].
// See full list of supported asset types at
// https://cloud.google.com/asset-inventory/docs/supported-asset-types.
String[] assetTypes = { "YOUR_ASSET_TYPES_TO_LIST" };
// The asset content type to list. E.g., ContentType.CONTENT_TYPE_UNSPECIFIED.
// See full list of content types at
// https://cloud.google.com/asset-inventory/docs/reference/rpc/google.cloud.asset.v1#contenttype
ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
listAssets(projectId, assetTypes, contentType);
}
Aggregations