Search in sources :

Example 41 with AssetServiceClient

use of com.google.cloud.asset.v1.AssetServiceClient in project gapic-generator-java by googleapis.

the class AsyncSearchAllIamPoliciesPaged method asyncSearchAllIamPoliciesPaged.

public static void asyncSearchAllIamPoliciesPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        SearchAllIamPoliciesRequest request = SearchAllIamPoliciesRequest.newBuilder().setScope("scope109264468").setQuery("query107944136").setPageSize(883849137).setPageToken("pageToken873572522").addAllAssetTypes(new ArrayList<String>()).setOrderBy("orderBy-1207110587").build();
        while (true) {
            SearchAllIamPoliciesResponse response = assetServiceClient.searchAllIamPoliciesCallable().call(request);
            for (IamPolicySearchResult element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : SearchAllIamPoliciesResponse(com.google.cloud.asset.v1.SearchAllIamPoliciesResponse) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) SearchAllIamPoliciesRequest(com.google.cloud.asset.v1.SearchAllIamPoliciesRequest) IamPolicySearchResult(com.google.cloud.asset.v1.IamPolicySearchResult)

Example 42 with AssetServiceClient

use of com.google.cloud.asset.v1.AssetServiceClient in project gapic-generator-java by googleapis.

the class AsyncExportAssetsLRO method asyncExportAssetsLRO.

public static void asyncExportAssetsLRO() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        ExportAssetsRequest request = ExportAssetsRequest.newBuilder().setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()).setReadTime(Timestamp.newBuilder().build()).addAllAssetTypes(new ArrayList<String>()).setContentType(ContentType.forNumber(0)).setOutputConfig(OutputConfig.newBuilder().build()).addAllRelationshipTypes(new ArrayList<String>()).build();
        OperationFuture<ExportAssetsResponse, ExportAssetsRequest> future = assetServiceClient.exportAssetsOperationCallable().futureCall(request);
        // Do something.
        ExportAssetsResponse response = future.get();
    }
}
Also used : ExportAssetsRequest(com.google.cloud.asset.v1.ExportAssetsRequest) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) ArrayList(java.util.ArrayList) ExportAssetsResponse(com.google.cloud.asset.v1.ExportAssetsResponse)

Example 43 with AssetServiceClient

use of com.google.cloud.asset.v1.AssetServiceClient in project gapic-generator-java by googleapis.

the class SyncExportAssets method syncExportAssets.

public static void syncExportAssets() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        ExportAssetsRequest request = ExportAssetsRequest.newBuilder().setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()).setReadTime(Timestamp.newBuilder().build()).addAllAssetTypes(new ArrayList<String>()).setContentType(ContentType.forNumber(0)).setOutputConfig(OutputConfig.newBuilder().build()).addAllRelationshipTypes(new ArrayList<String>()).build();
        ExportAssetsResponse response = assetServiceClient.exportAssetsAsync(request).get();
    }
}
Also used : ExportAssetsRequest(com.google.cloud.asset.v1.ExportAssetsRequest) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) ArrayList(java.util.ArrayList) ExportAssetsResponse(com.google.cloud.asset.v1.ExportAssetsResponse)

Example 44 with AssetServiceClient

use of com.google.cloud.asset.v1.AssetServiceClient in project gapic-generator-java by googleapis.

the class SyncGetFeed method syncGetFeed.

public static void syncGetFeed() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        GetFeedRequest request = GetFeedRequest.newBuilder().setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()).build();
        Feed response = assetServiceClient.getFeed(request);
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) GetFeedRequest(com.google.cloud.asset.v1.GetFeedRequest) Feed(com.google.cloud.asset.v1.Feed)

Example 45 with AssetServiceClient

use of com.google.cloud.asset.v1.AssetServiceClient in project gapic-generator-java by googleapis.

the class AsyncListAssets method asyncListAssets.

public static void asyncListAssets() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        ListAssetsRequest request = ListAssetsRequest.newBuilder().setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()).setReadTime(Timestamp.newBuilder().build()).addAllAssetTypes(new ArrayList<String>()).setContentType(ContentType.forNumber(0)).setPageSize(883849137).setPageToken("pageToken873572522").addAllRelationshipTypes(new ArrayList<String>()).build();
        ApiFuture<Asset> future = assetServiceClient.listAssetsPagedCallable().futureCall(request);
        // Do something.
        for (Asset element : future.get().iterateAll()) {
        // doThingsWith(element);
        }
    }
}
Also used : ListAssetsRequest(com.google.cloud.asset.v1.ListAssetsRequest) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) ArrayList(java.util.ArrayList) Asset(com.google.cloud.asset.v1.Asset)

Aggregations

AssetServiceClient (com.google.cloud.asset.v1.AssetServiceClient)52 Feed (com.google.cloud.asset.v1.Feed)13 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)6 ApiException (com.google.api.gax.rpc.ApiException)5 AnalyzeIamPolicyLongrunningRequest (com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest)5 ExportAssetsRequest (com.google.cloud.asset.v1.ExportAssetsRequest)5 ExportAssetsResponse (com.google.cloud.asset.v1.ExportAssetsResponse)4 ListFeedsResponse (com.google.cloud.asset.v1.ListFeedsResponse)4 ProjectName (com.google.cloud.asset.v1.ProjectName)4 AnalyzeIamPolicyRequest (com.google.cloud.asset.v1.AnalyzeIamPolicyRequest)3 AnalyzeIamPolicyResponse (com.google.cloud.asset.v1.AnalyzeIamPolicyResponse)3 CreateFeedRequest (com.google.cloud.asset.v1.CreateFeedRequest)3 IamPolicyAnalysisQuery (com.google.cloud.asset.v1.IamPolicyAnalysisQuery)3 Options (com.google.cloud.asset.v1.IamPolicyAnalysisQuery.Options)3 ResourceSelector (com.google.cloud.asset.v1.IamPolicyAnalysisQuery.ResourceSelector)3 IamPolicySearchResult (com.google.cloud.asset.v1.IamPolicySearchResult)3 ListAssetsRequest (com.google.cloud.asset.v1.ListAssetsRequest)3 ResourceSearchResult (com.google.cloud.asset.v1.ResourceSearchResult)3 SearchAllIamPoliciesRequest (com.google.cloud.asset.v1.SearchAllIamPoliciesRequest)3