google_cloud_storage/http/objects/list.rs
1use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
2
3use crate::http::object_access_controls::Projection;
4use crate::http::objects::Object;
5use crate::http::Escape;
6
7/// Request message for GetNotification.
8#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
9#[serde(rename_all = "camelCase")]
10pub struct ListObjectsRequest {
11 /// Name of the bucket in which to look for objects.
12 #[serde(skip_serializing)]
13 pub bucket: String,
14 /// Returns results in a directory-like mode, with / being a common value for the delimiter.
15 /// items[] contains object metadata for objects whose names do not contain
16 /// delimiter, or whose names only have instances of delimiter in their prefix.
17 /// prefixes[] contains truncated object names for objects whose names contain
18 /// delimiter after any prefix. Object names are truncated beyond the first applicable
19 /// instance of the delimiter. If multiple objects have the same truncated name, duplicates are omitted.
20 pub delimiter: Option<String>,
21 /// Filter results to objects whose names are lexicographically before endOffset.
22 /// If startOffset is also set, the objects listed have names between startOffset
23 /// (inclusive) and endOffset (exclusive).
24 pub end_offset: Option<String>,
25 /// If true, objects that end in exactly one instance of delimiter have their metadata
26 /// included in items[] in addition to the relevant part of the object name appearing in prefixes[].
27 pub include_trailing_delimiter: Option<bool>,
28 /// Maximum combined number of entries in items[] and prefixes[] to return in a
29 /// single page of responses. The service may return fewer results than maxResults
30 /// so the presence of nextPageToken should always be checked.
31 /// The recommended upper value for maxResults is 1000 objects in a single response.
32 pub max_results: Option<i32>,
33 /// A previously-returned page token representing part of the larger set of results to view.
34 /// The pageToken is an encoded field that marks the name and generation of
35 /// the last object in the returned list. In a subsequent request using the pageToken,
36 /// items that come after the pageToken are shown (up to maxResults).
37 /// If you start a listing and then create an object in the bucket before using a pageToken
38 /// to continue listing, you do not see the new object in subsequent listing results
39 /// if it is in part of the object namespace already listed.
40 pub page_token: Option<String>,
41 /// Filter results to include only objects whose names begin with this prefix.
42 pub prefix: Option<String>,
43 /// Set of properties to return. Defaults to noAcl.
44 /// Acceptable values are:
45 /// full: Include all properties.
46 /// noAcl: Omit the owner, acl property.
47 pub projection: Option<Projection>,
48 /// Filter results to objects whose names are lexicographically equal to or after startOffset.
49 /// If endOffset is also set, the objects listed have names between startOffset
50 /// (inclusive) and endOffset (exclusive).
51 pub start_offset: Option<String>,
52 /// If true, lists all versions of an object as distinct results in order of
53 /// increasing generation number. The default value for versions is false.
54 /// For more information, see Object Versioning.
55 pub versions: Option<bool>,
56 /// Filter results to objects and prefixes that match this glob pattern.
57 /// For more information, see [List objects and prefixes using glob](<https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-objects-and-prefixes-using-glob>)
58 pub match_glob: Option<String>,
59}
60
61/// The result of a call to Objects.ListObjects
62#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug)]
63#[serde(rename_all = "camelCase")]
64pub struct ListObjectsResponse {
65 /// The list of prefixes of objects matching-but-not-listed up to and including
66 /// the requested delimiter.
67 pub prefixes: Option<Vec<String>>,
68 /// The list of items.
69 pub items: Option<Vec<Object>>,
70 /// The continuation token, used to page through large result sets. Provide
71 /// this value in a subsequent request to return the next page of results.
72 pub next_page_token: Option<String>,
73}
74
75pub(crate) fn build(base_url: &str, client: &Client, req: &ListObjectsRequest) -> RequestBuilder {
76 let url = format!("{}/b/{}/o", base_url, req.bucket.escape());
77 client.get(url).query(&req)
78}