Skip to content

Commit

Permalink
feat: add Cloud Asset List API, add access time as condition context …
Browse files Browse the repository at this point in the history
…in request and evaluation value in response for Cloud Asset AnalyzeIamPolicy API, add more info (folders, organizations, kms_key, create_time, update_time, state, parent_full_resource_name, parent_asset_type) in response for Cloud Asset SearchAllResources API

Committer: @peter-zheng-g
PiperOrigin-RevId: 375731640

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue May 25 10:06:32 2021 -0700
Source-Repo: googleapis/googleapis
Source-Sha: de04592991247b9b617d06d4ec68f7e90adf2b81
Source-Link: googleapis/googleapis@de04592
  • Loading branch information
yoshi-automation authored and jskeet committed May 26, 2021
1 parent 1ca49a3 commit 2722d51
Show file tree
Hide file tree
Showing 8 changed files with 2,627 additions and 337 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,288 @@ public async Task ExportAssetsRequestObjectAsync()
// End snippet
}

/// <summary>Snippet for ListAssets</summary>
public void ListAssetsRequestObject()
{
// Snippet: ListAssets(ListAssetsRequest, CallSettings)
// Create client
AssetServiceClient assetServiceClient = AssetServiceClient.Create();
// Initialize request argument(s)
ListAssetsRequest request = new ListAssetsRequest
{
ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
ReadTime = new Timestamp(),
AssetTypes = { "", },
ContentType = ContentType.Unspecified,
};
// Make the request
PagedEnumerable<ListAssetsResponse, Asset> response = assetServiceClient.ListAssets(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Asset item in response)
{
// Do something with each item
Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListAssetsResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Asset item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Asset> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Asset item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
// End snippet
}

/// <summary>Snippet for ListAssetsAsync</summary>
public async Task ListAssetsRequestObjectAsync()
{
// Snippet: ListAssetsAsync(ListAssetsRequest, CallSettings)
// Create client
AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
// Initialize request argument(s)
ListAssetsRequest request = new ListAssetsRequest
{
ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
ReadTime = new Timestamp(),
AssetTypes = { "", },
ContentType = ContentType.Unspecified,
};
// Make the request
PagedAsyncEnumerable<ListAssetsResponse, Asset> response = assetServiceClient.ListAssetsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Asset item) =>
{
// Do something with each item
Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListAssetsResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Asset item in page)
{
// Do something with each item
Console.WriteLine(item);
}
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Asset> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Asset item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
// End snippet
}

/// <summary>Snippet for ListAssets</summary>
public void ListAssets()
{
// Snippet: ListAssets(string, string, int?, CallSettings)
// Create client
AssetServiceClient assetServiceClient = AssetServiceClient.Create();
// Initialize request argument(s)
string parent = "a/wildcard/resource";
// Make the request
PagedEnumerable<ListAssetsResponse, Asset> response = assetServiceClient.ListAssets(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Asset item in response)
{
// Do something with each item
Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListAssetsResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Asset item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Asset> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Asset item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
// End snippet
}

/// <summary>Snippet for ListAssetsAsync</summary>
public async Task ListAssetsAsync()
{
// Snippet: ListAssetsAsync(string, string, int?, CallSettings)
// Create client
AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "a/wildcard/resource";
// Make the request
PagedAsyncEnumerable<ListAssetsResponse, Asset> response = assetServiceClient.ListAssetsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Asset item) =>
{
// Do something with each item
Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListAssetsResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Asset item in page)
{
// Do something with each item
Console.WriteLine(item);
}
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Asset> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Asset item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
// End snippet
}

/// <summary>Snippet for ListAssets</summary>
public void ListAssetsResourceNames()
{
// Snippet: ListAssets(IResourceName, string, int?, CallSettings)
// Create client
AssetServiceClient assetServiceClient = AssetServiceClient.Create();
// Initialize request argument(s)
IResourceName parent = new UnparsedResourceName("a/wildcard/resource");
// Make the request
PagedEnumerable<ListAssetsResponse, Asset> response = assetServiceClient.ListAssets(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Asset item in response)
{
// Do something with each item
Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListAssetsResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Asset item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Asset> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Asset item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
// End snippet
}

/// <summary>Snippet for ListAssetsAsync</summary>
public async Task ListAssetsResourceNamesAsync()
{
// Snippet: ListAssetsAsync(IResourceName, string, int?, CallSettings)
// Create client
AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
// Initialize request argument(s)
IResourceName parent = new UnparsedResourceName("a/wildcard/resource");
// Make the request
PagedAsyncEnumerable<ListAssetsResponse, Asset> response = assetServiceClient.ListAssetsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Asset item) =>
{
// Do something with each item
Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListAssetsResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Asset item in page)
{
// Do something with each item
Console.WriteLine(item);
}
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Asset> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Asset item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
// End snippet
}

/// <summary>Snippet for BatchGetAssetsHistory</summary>
public void BatchGetAssetsHistoryRequestObject()
{
Expand Down
Loading

0 comments on commit 2722d51

Please sign in to comment.