use of com.google.cloud.asset.v1.Asset 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.Asset 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);
}
use of com.google.cloud.asset.v1.Asset in project tapestry-5 by apache.
the class AssetObjectProvider method provide.
/**
* Provides the asset. If the expression does not identify an asset domain, with a prefix, it is assumed to be a
* path on the classpath, relative to the root of the classpath.
*
* @param objectType the type of object (which must be Object or Asset)
* @param locator not used
*/
public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) {
Path path = annotationProvider.getAnnotation(Path.class);
if (path == null)
return null;
String expanded = symbolSource.expandSymbols(path.value());
Asset asset = source.getAsset(null, expanded, null);
return typeCoercer.coerce(asset, objectType);
}
use of com.google.cloud.asset.v1.Asset in project tapestry-5 by apache.
the class AssetSourceImpl method getLocalizedAssetFromResource.
private Asset getLocalizedAssetFromResource(Resource unlocalized, Locale locale) {
final Resource localized;
if (locale == null) {
localized = unlocalized;
} else {
Reference<Asset> reference = cache.get(unlocalized);
if (reference != null) {
Asset asset = reference.get();
if (asset != null) {
// Prefer resource from cache to use its cache
unlocalized = asset.getResource();
}
}
localized = unlocalized.forLocale(locale);
}
if (localized == null || !localized.exists()) {
throw new AssetNotFoundException(String.format("Unable to locate asset '%s' (the file does not exist).", unlocalized), unlocalized);
}
return getAssetForResource(localized);
}
use of com.google.cloud.asset.v1.Asset in project tapestry-5 by apache.
the class AssetSourceImpl method createAssetFromResource.
private Asset createAssetFromResource(Resource resource) {
try {
upgradeReadLockToWriteLock();
// Check for competing thread beat us to it (not very likely!):
Asset result = TapestryInternalUtils.getAndDeref(cache, resource);
if (result != null) {
return result;
}
Class resourceClass = resource.getClass();
AssetFactory factory = registry.get(resourceClass);
return factory.createAsset(resource);
} finally {
downgradeWriteLockToReadLock();
}
}
Aggregations