make regen-apis

This commit is contained in:
OMGeeky
2024-05-16 21:23:40 +02:00
parent 52d2e89e51
commit ad85cafeef
5108 changed files with 1615625 additions and 992044 deletions

View File

@@ -4,12 +4,12 @@
[package]
name = "google-cloudprofiler2"
version = "5.0.4+20240219"
version = "5.0.5+20240331"
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
description = "A complete library to interact with Cloud Profiler (protocol v2)"
repository = "https://github.com/Byron/google-apis-rs/tree/main/gen/cloudprofiler2"
homepage = "https://cloud.google.com/profiler/"
documentation = "https://docs.rs/google-cloudprofiler2/5.0.4+20240219"
documentation = "https://docs.rs/google-cloudprofiler2/5.0.5+20240331"
license = "MIT"
keywords = ["cloudprofiler", "google", "protocol", "web", "api"]
autobins = false
@@ -18,12 +18,12 @@ edition = "2018"
[dependencies]
anyhow = "^ 1.0"
hyper-rustls = "0.24.0"
hyper-rustls = "0.25.0"
mime = "^ 0.3.0"
serde = { version = "^ 1.0", features = ["derive"] }
serde_json = "^ 1.0"
itertools = "^ 0.10"
google-apis-common = { path = "../../google-apis-common", version = "6.0" }
google-apis-common = { path = "../../google-apis-common", version = "6.0.3" }
hyper = "^ 0.14"
http = "^0.2"
tokio = "^1.0"

View File

@@ -6,7 +6,7 @@ DO NOT EDIT !
The MIT License (MIT)
=====================
Copyright © `2015-2020` `Sebastian Thiel`
Copyright 20152024 Sebastian Thiel
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@@ -5,16 +5,16 @@ DO NOT EDIT !
-->
The `google-cloudprofiler2` library allows access to all features of the *Google Cloud Profiler* service.
This documentation was generated from *Cloud Profiler* crate version *5.0.4+20240219*, where *20240219* is the exact revision of the *cloudprofiler:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v5.0.4*.
This documentation was generated from *Cloud Profiler* crate version *5.0.5+20240331*, where *20240331* is the exact revision of the *cloudprofiler:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v5.0.5*.
Everything else about the *Cloud Profiler* *v2* API can be found at the
[official documentation site](https://cloud.google.com/profiler/).
# Features
Handle the following *Resources* with ease from the central [hub](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/CloudProfiler) ...
Handle the following *Resources* with ease from the central [hub](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/CloudProfiler) ...
* projects
* [*profiles create*](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/api::ProjectProfileCreateCall), [*profiles create offline*](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/api::ProjectProfileCreateOfflineCall), [*profiles list*](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/api::ProjectProfileListCall) and [*profiles patch*](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/api::ProjectProfilePatchCall)
* [*profiles create*](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/api::ProjectProfileCreateCall), [*profiles create offline*](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/api::ProjectProfileCreateOfflineCall), [*profiles list*](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/api::ProjectProfileListCall) and [*profiles patch*](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/api::ProjectProfilePatchCall)
@@ -23,17 +23,17 @@ Handle the following *Resources* with ease from the central [hub](https://docs.r
The API is structured into the following primary items:
* **[Hub](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/CloudProfiler)**
* **[Hub](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/CloudProfiler)**
* a central object to maintain state and allow accessing all *Activities*
* creates [*Method Builders*](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::MethodsBuilder) which in turn
allow access to individual [*Call Builders*](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::CallBuilder)
* **[Resources](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::Resource)**
* creates [*Method Builders*](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::MethodsBuilder) which in turn
allow access to individual [*Call Builders*](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::CallBuilder)
* **[Resources](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::Resource)**
* primary types that you can apply *Activities* to
* a collection of properties and *Parts*
* **[Parts](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::Part)**
* **[Parts](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::Part)**
* a collection of properties
* never directly used in *Activities*
* **[Activities](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::CallBuilder)**
* **[Activities](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::CallBuilder)**
* operations to apply to *Resources*
All *structures* are marked with applicable traits to further categorize them and ease browsing.
@@ -52,8 +52,8 @@ let r = hub.projects().profiles_create_offline(...).doit().await
let r = hub.projects().profiles_patch(...).doit().await
```
The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
The `doit()` method performs the actual communication with the server and returns the respective result.
@@ -78,22 +78,23 @@ extern crate hyper_rustls;
extern crate google_cloudprofiler2 as cloudprofiler2;
use cloudprofiler2::api::Profile;
use cloudprofiler2::{Result, Error};
use cloudprofiler2::api::enums::*;
use std::default::Default;
use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
// Get an ApplicationSecret instance by some means. It contains the `client_id` and
// Get an ApplicationSecret instance by some means. It contains the `client_id` and
// `client_secret`, among other things.
let secret: oauth2::ApplicationSecret = Default::default();
// Instantiate the authenticator. It will choose a suitable authentication flow for you,
// Instantiate the authenticator. It will choose a suitable authentication flow for you,
// unless you replace `None` with the desired Flow.
// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
// retrieve them from storage.
let auth = oauth2::InstalledFlowAuthenticator::builder(
secret,
oauth2::InstalledFlowReturnMethod::HTTPRedirect,
).build().await.unwrap();
let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
// As the method needs a request, you would usually fill it with the desired information
// into the respective structure. Some of the parts shown here might not be applicable !
// Values shown here are possibly random and not representative !
@@ -103,7 +104,7 @@ let mut req = Profile::default();
// execute the final call using `doit()`.
// Values shown here are possibly random and not representative !
let result = hub.projects().profiles_patch(req, "name")
.update_mask(&Default::default())
.update_mask(FieldMask::new::<&str>(&[]))
.doit().await;
match result {
@@ -127,49 +128,49 @@ match result {
```
## Handling Errors
All errors produced by the system are provided either as [Result](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::Result) enumeration as return value of
the doit() methods, or handed as possibly intermediate results to either the
[Hub Delegate](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::Delegate), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
All errors produced by the system are provided either as [Result](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::Result) enumeration as return value of
the doit() methods, or handed as possibly intermediate results to either the
[Hub Delegate](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::Delegate), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
makes the system potentially resilient to all kinds of errors.
## Uploads and Downloads
If a method supports downloads, the response body, which is part of the [Result](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::Result), should be
If a method supports downloads, the response body, which is part of the [Result](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::Result), should be
read by you to obtain the media.
If such a method also supports a [Response Result](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::ResponseResult), it will return that by default.
If such a method also supports a [Response Result](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::ResponseResult), it will return that by default.
You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
this call: `.param("alt", "media")`.
Methods supporting uploads can do so using up to 2 different protocols:
*simple* and *resumable*. The distinctiveness of each is represented by customized
Methods supporting uploads can do so using up to 2 different protocols:
*simple* and *resumable*. The distinctiveness of each is represented by customized
`doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
## Customization and Callbacks
You may alter the way an `doit()` method is called by providing a [delegate](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::Delegate) to the
[Method Builder](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::CallBuilder) before making the final `doit()` call.
Respective methods will be called to provide progress information, as well as determine whether the system should
You may alter the way an `doit()` method is called by providing a [delegate](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::Delegate) to the
[Method Builder](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::CallBuilder) before making the final `doit()` call.
Respective methods will be called to provide progress information, as well as determine whether the system should
retry on failure.
The [delegate trait](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::Delegate) is default-implemented, allowing you to customize it with minimal effort.
The [delegate trait](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::Delegate) is default-implemented, allowing you to customize it with minimal effort.
## Optional Parts in Server-Requests
All structures provided by this library are made to be [encodable](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::RequestValue) and
[decodable](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::ResponseResult) via *json*. Optionals are used to indicate that partial requests are responses
All structures provided by this library are made to be [encodable](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::RequestValue) and
[decodable](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::ResponseResult) via *json*. Optionals are used to indicate that partial requests are responses
are valid.
Most optionals are are considered [Parts](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::Part) which are identifiable by name, which will be sent to
Most optionals are are considered [Parts](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::Part) which are identifiable by name, which will be sent to
the server to indicate either the set parts of the request or the desired parts in the response.
## Builder Arguments
Using [method builders](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::CallBuilder), you are able to prepare an action call by repeatedly calling it's methods.
Using [method builders](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::CallBuilder), you are able to prepare an action call by repeatedly calling it's methods.
These will always take a single argument, for which the following statements are true.
* [PODs][wiki-pod] are handed by copy
* strings are passed as `&str`
* [request values](https://docs.rs/google-cloudprofiler2/5.0.4+20240219/google_cloudprofiler2/client::RequestValue) are moved
* [request values](https://docs.rs/google-cloudprofiler2/5.0.5+20240331/google_cloudprofiler2/client::RequestValue) are moved
Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
@@ -178,7 +179,7 @@ Arguments will always be copied or cloned into the builder, to make them indepen
[google-go-api]: https://github.com/google/google-api-go-client
# License
The **cloudprofiler2** library was generated by Sebastian Thiel, and is placed
The **cloudprofiler2** library was generated by Sebastian Thiel, and is placed
under the *MIT* license.
You can read the full text at the repository's [license file][repo-license].

View File

@@ -1,424 +1,4 @@
use std::collections::HashMap;
use std::cell::RefCell;
use std::default::Default;
use std::collections::BTreeSet;
use std::error::Error as StdError;
use serde_json as json;
use std::io;
use std::fs;
use std::mem;
use hyper::client::connect;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::time::sleep;
use tower_service;
use serde::{Serialize, Deserialize};
use crate::{client, client::GetToken, client::serde_with};
// ##############
// UTILITIES ###
// ############
/// Identifies the an OAuth2 authorization scope.
/// A scope is needed when requesting an
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
pub enum Scope {
/// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
CloudPlatform,
/// View and write monitoring data for all of your Google and third-party Cloud and API projects
Monitoring,
/// Publish metric data to your Google Cloud projects
MonitoringWrite,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
Scope::Monitoring => "https://www.googleapis.com/auth/monitoring",
Scope::MonitoringWrite => "https://www.googleapis.com/auth/monitoring.write",
}
}
}
impl Default for Scope {
fn default() -> Scope {
Scope::Monitoring
}
}
// ########
// HUB ###
// ######
/// Central instance to access all CloudProfiler related resource activities
///
/// # Examples
///
/// Instantiate a new hub
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_cloudprofiler2 as cloudprofiler2;
/// use cloudprofiler2::api::Profile;
/// use cloudprofiler2::{Result, Error};
/// # async fn dox() {
/// use std::default::Default;
/// use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
/// // `client_secret`, among other things.
/// let secret: oauth2::ApplicationSecret = Default::default();
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
/// // unless you replace `None` with the desired Flow.
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
/// // retrieve them from storage.
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Profile::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.projects().profiles_patch(req, "name")
/// .update_mask(&Default::default())
/// .doit().await;
///
/// match result {
/// Err(e) => match e {
/// // The Error enum provides details about what exactly happened.
/// // You can also just use its `Debug`, `Display` or `Error` traits
/// Error::HttpError(_)
/// |Error::Io(_)
/// |Error::MissingAPIKey
/// |Error::MissingToken(_)
/// |Error::Cancelled
/// |Error::UploadSizeLimitExceeded(_, _)
/// |Error::Failure(_)
/// |Error::BadRequest(_)
/// |Error::FieldClash(_)
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
/// },
/// Ok(res) => println!("Success: {:?}", res),
/// }
/// # }
/// ```
#[derive(Clone)]
pub struct CloudProfiler<S> {
pub client: hyper::Client<S, hyper::body::Body>,
pub auth: Box<dyn client::GetToken>,
_user_agent: String,
_base_url: String,
_root_url: String,
}
impl<'a, S> client::Hub for CloudProfiler<S> {}
impl<'a, S> CloudProfiler<S> {
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> CloudProfiler<S> {
CloudProfiler {
client,
auth: Box::new(auth),
_user_agent: "google-api-rust-client/5.0.4".to_string(),
_base_url: "https://cloudprofiler.googleapis.com/".to_string(),
_root_url: "https://cloudprofiler.googleapis.com/".to_string(),
}
}
pub fn projects(&'a self) -> ProjectMethods<'a, S> {
ProjectMethods { hub: &self }
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/5.0.4`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
mem::replace(&mut self._user_agent, agent_name)
}
/// Set the base url to use in all requests to the server.
/// It defaults to `https://cloudprofiler.googleapis.com/`.
///
/// Returns the previously set base url.
pub fn base_url(&mut self, new_base_url: String) -> String {
mem::replace(&mut self._base_url, new_base_url)
}
/// Set the root url to use in all requests to the server.
/// It defaults to `https://cloudprofiler.googleapis.com/`.
///
/// Returns the previously set root url.
pub fn root_url(&mut self, new_root_url: String) -> String {
mem::replace(&mut self._root_url, new_root_url)
}
}
// ############
// SCHEMAS ###
// ##########
/// CreateProfileRequest describes a profile resource online creation request. The deployment field must be populated. The profile_type specifies the list of profile types supported by the agent. The creation call will hang until a profile of one of these types needs to be collected.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [profiles create projects](ProjectProfileCreateCall) (request)
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreateProfileRequest {
/// Deployment details.
pub deployment: Option<Deployment>,
/// One or more profile types that the agent is capable of providing.
#[serde(rename="profileType")]
pub profile_type: Option<Vec<String>>,
}
impl client::RequestValue for CreateProfileRequest {}
/// Deployment contains the deployment identification information.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Deployment {
/// Labels identify the deployment within the user universe and same target. Validation regex for label names: `^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`. Value for an individual label must be \<= 512 bytes, the total size of all label names and values must be \<= 1024 bytes. Label named “language” can be used to record the programming language of the profiled deployment. The standard choices for the value include “java”, “go”, “python”, “ruby”, “nodejs”, “php”, “dotnet”. For deployments running on Google Cloud Platform, “zone” or “region” label should be present describing the deployment location. An example of a zone is “us-central1-a”, an example of a region is “us-central1” or “us-central”.
pub labels: Option<HashMap<String, String>>,
/// Project ID is the ID of a cloud project. Validation regex: `^a-z{4,61}[a-z0-9]$`.
#[serde(rename="projectId")]
pub project_id: Option<String>,
/// Target is the service name used to group related deployments: * Service name for App Engine Flex / Standard. * Cluster and container name for GKE. * User-specified string for direct Compute Engine profiling (e.g. Java). * Job name for Dataflow. Validation regex: `^[a-z0-9]([-a-z0-9_.]{0,253}[a-z0-9])?$`.
pub target: Option<String>,
}
impl client::Part for Deployment {}
/// ListProfileResponse contains the list of collected profiles for deployments in projects which the user has permissions to view.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [profiles list projects](ProjectProfileListCall) (response)
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ListProfilesResponse {
/// Token to receive the next page of results. This field maybe empty if there are no more profiles to fetch.
#[serde(rename="nextPageToken")]
pub next_page_token: Option<String>,
/// List of profiles fetched.
pub profiles: Option<Vec<Profile>>,
/// Number of profiles that were skipped in the current page since they were not able to be fetched successfully. This should typically be zero. A non-zero value may indicate a transient failure, in which case if the number is too high for your use case, the call may be retried.
#[serde(rename="skippedProfiles")]
pub skipped_profiles: Option<i32>,
}
impl client::ResponseResult for ListProfilesResponse {}
/// Profile resource.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [profiles create projects](ProjectProfileCreateCall) (response)
/// * [profiles create offline projects](ProjectProfileCreateOfflineCall) (request|response)
/// * [profiles patch projects](ProjectProfilePatchCall) (request|response)
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Profile {
/// Deployment this profile corresponds to.
pub deployment: Option<Deployment>,
/// Duration of the profiling session. Input (for the offline mode) or output (for the online mode). The field represents requested profiling duration. It may slightly differ from the effective profiling duration, which is recorded in the profile data, in case the profiling can't be stopped immediately (e.g. in case stopping the profiling is handled asynchronously).
#[serde_as(as = "Option<::client::serde::duration::Wrapper>")]
pub duration: Option<client::chrono::Duration>,
/// Input only. Labels associated to this specific profile. These labels will get merged with the deployment labels for the final data set. See documentation on deployment labels for validation rules and limits.
pub labels: Option<HashMap<String, String>>,
/// Output only. Opaque, server-assigned, unique ID for this profile.
pub name: Option<String>,
/// Input only. Profile bytes, as a gzip compressed serialized proto, the format is https://github.com/google/pprof/blob/master/proto/profile.proto.
#[serde(rename="profileBytes")]
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub profile_bytes: Option<Vec<u8>>,
/// Type of profile. For offline mode, this must be specified when creating the profile. For online mode it is assigned and returned by the server.
#[serde(rename="profileType")]
pub profile_type: Option<String>,
/// Output only. Start time for the profile. This output is only present in response from the ListProfiles method.
#[serde(rename="startTime")]
pub start_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
}
impl client::RequestValue for Profile {}
impl client::ResponseResult for Profile {}
// ###################
// MethodBuilders ###
// #################
/// A builder providing access to all methods supported on *project* resources.
/// It is not used directly, but through the [`CloudProfiler`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_cloudprofiler2 as cloudprofiler2;
///
/// # async fn dox() {
/// use std::default::Default;
/// use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `profiles_create(...)`, `profiles_create_offline(...)`, `profiles_list(...)` and `profiles_patch(...)`
/// // to build up your call.
/// let rb = hub.projects();
/// # }
/// ```
pub struct ProjectMethods<'a, S>
where S: 'a {
hub: &'a CloudProfiler<S>,
}
impl<'a, S> client::MethodsBuilder for ProjectMethods<'a, S> {}
impl<'a, S> ProjectMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// CreateProfile creates a new profile resource in the online mode. _Direct use of this API is discouraged, please use a [supported profiler agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection._ The server ensures that the new profiles are created at a constant rate per deployment, so the creation request may hang for some time until the next profile session is available. The request may fail with ABORTED error if the creation is not available within ~1m, the response will indicate the duration of the backoff the client should take before attempting creating a profile again. The backoff duration is returned in google.rpc.RetryInfo extension on the response status. To a gRPC client, the extension will be return as a binary-serialized proto in the trailing metadata item named "google.rpc.retryinfo-bin".
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `parent` - Parent project to create the profile in.
pub fn profiles_create(&self, request: CreateProfileRequest, parent: &str) -> ProjectProfileCreateCall<'a, S> {
ProjectProfileCreateCall {
hub: self.hub,
_request: request,
_parent: parent.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// CreateOfflineProfile creates a new profile resource in the offline mode. The client provides the profile to create along with the profile bytes, the server records it. _Direct use of this API is discouraged, please use a [supported profiler agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection._
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `parent` - Parent project to create the profile in.
pub fn profiles_create_offline(&self, request: Profile, parent: &str) -> ProjectProfileCreateOfflineCall<'a, S> {
ProjectProfileCreateOfflineCall {
hub: self.hub,
_request: request,
_parent: parent.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists profiles which have been collected so far and for which the caller has permission to view.
///
/// # Arguments
///
/// * `parent` - Required. The parent, which owns this collection of profiles. Format: projects/{user_project_id}
pub fn profiles_list(&self, parent: &str) -> ProjectProfileListCall<'a, S> {
ProjectProfileListCall {
hub: self.hub,
_parent: parent.to_string(),
_page_token: Default::default(),
_page_size: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// UpdateProfile updates the profile bytes and labels on the profile resource created in the online mode. Updating the bytes for profiles created in the offline mode is currently not supported: the profile content must be provided at the time of the profile creation. _Direct use of this API is discouraged, please use a [supported profiler agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection._
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `name` - Output only. Opaque, server-assigned, unique ID for this profile.
pub fn profiles_patch(&self, request: Profile, name: &str) -> ProjectProfilePatchCall<'a, S> {
ProjectProfilePatchCall {
hub: self.hub,
_request: request,
_name: name.to_string(),
_update_mask: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
// ###################
// CallBuilders ###
// #################
use super::*;
/// CreateProfile creates a new profile resource in the online mode. _Direct use of this API is discouraged, please use a [supported profiler agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection._ The server ensures that the new profiles are created at a constant rate per deployment, so the creation request may hang for some time until the next profile session is available. The request may fail with ABORTED error if the creation is not available within ~1m, the response will indicate the duration of the backoff the client should take before attempting creating a profile again. The backoff duration is returned in google.rpc.RetryInfo extension on the response status. To a gRPC client, the extension will be return as a binary-serialized proto in the trailing metadata item named "google.rpc.retryinfo-bin".
///
/// A builder for the *profiles.create* method supported by a *project* resource.
@@ -433,6 +13,7 @@ impl<'a, S> ProjectMethods<'a, S> {
/// # extern crate hyper_rustls;
/// # extern crate google_cloudprofiler2 as cloudprofiler2;
/// use cloudprofiler2::api::CreateProfileRequest;
/// use cloudprofiler2::api::enums::*;
/// # async fn dox() {
/// # use std::default::Default;
/// # use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
@@ -442,7 +23,7 @@ impl<'a, S> ProjectMethods<'a, S> {
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
/// # let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
@@ -458,12 +39,12 @@ impl<'a, S> ProjectMethods<'a, S> {
pub struct ProjectProfileCreateCall<'a, S>
where S: 'a {
hub: &'a CloudProfiler<S>,
_request: CreateProfileRequest,
_parent: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
pub(super) hub: &'a CloudProfiler<S>,
pub(super) _request: CreateProfileRequest,
pub(super) _parent: String,
pub(super) _delegate: Option<&'a mut dyn client::Delegate>,
pub(super) _additional_params: HashMap<String, String>,
pub(super) _scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProjectProfileCreateCall<'a, S> {}
@@ -497,7 +78,7 @@ where
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("parent", self._parent);
params.push("parent", &self._parent);
params.extend(self._additional_params.iter());
@@ -725,6 +306,7 @@ where
/// # extern crate hyper_rustls;
/// # extern crate google_cloudprofiler2 as cloudprofiler2;
/// use cloudprofiler2::api::Profile;
/// use cloudprofiler2::api::enums::*;
/// # async fn dox() {
/// # use std::default::Default;
/// # use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
@@ -734,7 +316,7 @@ where
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
/// # let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
@@ -750,12 +332,12 @@ where
pub struct ProjectProfileCreateOfflineCall<'a, S>
where S: 'a {
hub: &'a CloudProfiler<S>,
_request: Profile,
_parent: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
pub(super) hub: &'a CloudProfiler<S>,
pub(super) _request: Profile,
pub(super) _parent: String,
pub(super) _delegate: Option<&'a mut dyn client::Delegate>,
pub(super) _additional_params: HashMap<String, String>,
pub(super) _scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProjectProfileCreateOfflineCall<'a, S> {}
@@ -789,7 +371,7 @@ where
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("parent", self._parent);
params.push("parent", &self._parent);
params.extend(self._additional_params.iter());
@@ -1016,6 +598,7 @@ where
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_cloudprofiler2 as cloudprofiler2;
/// use cloudprofiler2::api::enums::*;
/// # async fn dox() {
/// # use std::default::Default;
/// # use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
@@ -1025,7 +608,7 @@ where
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
/// # let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
@@ -1038,13 +621,13 @@ where
pub struct ProjectProfileListCall<'a, S>
where S: 'a {
hub: &'a CloudProfiler<S>,
_parent: String,
_page_token: Option<String>,
_page_size: Option<i32>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
pub(super) hub: &'a CloudProfiler<S>,
pub(super) _parent: String,
pub(super) _page_token: Option<String>,
pub(super) _page_size: Option<i32>,
pub(super) _delegate: Option<&'a mut dyn client::Delegate>,
pub(super) _additional_params: HashMap<String, String>,
pub(super) _scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProjectProfileListCall<'a, S> {}
@@ -1078,7 +661,7 @@ where
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("parent", self._parent);
params.push("parent", &self._parent);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
@@ -1133,6 +716,7 @@ where
let request = req_builder
.header(CONTENT_LENGTH, 0_u64)
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
@@ -1199,14 +783,14 @@ where
self._parent = new_value.to_string();
self
}
/// The token to continue pagination and get profiles from a particular page. When paginating, all other parameters provided to `ListProfiles` must match the call that provided the page token.
/// Optional. The token to continue pagination and get profiles from a particular page. When paginating, all other parameters provided to `ListProfiles` must match the call that provided the page token.
///
/// Sets the *page token* query property to the given value.
pub fn page_token(mut self, new_value: &str) -> ProjectProfileListCall<'a, S> {
self._page_token = Some(new_value.to_string());
self
}
/// The maximum number of items to return. Default page_size is 1000. Max limit is 1000.
/// Optional. The maximum number of items to return. Default page_size is 1000. Max limit is 1000.
///
/// Sets the *page size* query property to the given value.
pub fn page_size(mut self, new_value: i32) -> ProjectProfileListCall<'a, S> {
@@ -1303,6 +887,7 @@ where
/// # extern crate hyper_rustls;
/// # extern crate google_cloudprofiler2 as cloudprofiler2;
/// use cloudprofiler2::api::Profile;
/// use cloudprofiler2::api::enums::*;
/// # async fn dox() {
/// # use std::default::Default;
/// # use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
@@ -1312,7 +897,7 @@ where
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
/// # let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
@@ -1322,20 +907,20 @@ where
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.projects().profiles_patch(req, "name")
/// .update_mask(&Default::default())
/// .update_mask(FieldMask::new::<&str>(&[]))
/// .doit().await;
/// # }
/// ```
pub struct ProjectProfilePatchCall<'a, S>
where S: 'a {
hub: &'a CloudProfiler<S>,
_request: Profile,
_name: String,
_update_mask: Option<client::FieldMask>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
pub(super) hub: &'a CloudProfiler<S>,
pub(super) _request: Profile,
pub(super) _name: String,
pub(super) _update_mask: Option<client::FieldMask>,
pub(super) _delegate: Option<&'a mut dyn client::Delegate>,
pub(super) _additional_params: HashMap<String, String>,
pub(super) _scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProjectProfilePatchCall<'a, S> {}
@@ -1369,7 +954,7 @@ where
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("name", self._name);
params.push("name", &self._name);
if let Some(value) = self._update_mask.as_ref() {
params.push("updateMask", value.to_string());
}

View File

@@ -0,0 +1,212 @@
use super::*;
// region CreateProfileRequestProfileTypeEnum
#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)]
/// One or more profile types that the agent is capable of providing.
pub enum CreateProfileRequestProfileTypeEnum {
/// Unspecified profile type.
///
/// "PROFILE_TYPE_UNSPECIFIED"
#[serde(rename="PROFILE_TYPE_UNSPECIFIED")]
PROFILETYPEUNSPECIFIED,
/// Thread CPU time sampling.
///
/// "CPU"
#[serde(rename="CPU")]
CPU,
/// Wallclock time sampling. More expensive as stops all threads.
///
/// "WALL"
#[serde(rename="WALL")]
WALL,
/// In-use heap profile. Represents a snapshot of the allocations that are live at the time of the profiling.
///
/// "HEAP"
#[serde(rename="HEAP")]
HEAP,
/// Single-shot collection of all thread stacks.
///
/// "THREADS"
#[serde(rename="THREADS")]
THREADS,
/// Synchronization contention profile.
///
/// "CONTENTION"
#[serde(rename="CONTENTION")]
CONTENTION,
/// Peak heap profile.
///
/// "PEAK_HEAP"
#[serde(rename="PEAK_HEAP")]
PEAKHEAP,
/// Heap allocation profile. It represents the aggregation of all allocations made over the duration of the profile. All allocations are included, including those that might have been freed by the end of the profiling interval. The profile is in particular useful for garbage collecting languages to understand which parts of the code create most of the garbage collection pressure to see if those can be optimized.
///
/// "HEAP_ALLOC"
#[serde(rename="HEAP_ALLOC")]
HEAPALLOC,
}
impl AsRef<str> for CreateProfileRequestProfileTypeEnum {
fn as_ref(&self) -> &str {
match *self {
CreateProfileRequestProfileTypeEnum::PROFILETYPEUNSPECIFIED => "PROFILE_TYPE_UNSPECIFIED",
CreateProfileRequestProfileTypeEnum::CPU => "CPU",
CreateProfileRequestProfileTypeEnum::WALL => "WALL",
CreateProfileRequestProfileTypeEnum::HEAP => "HEAP",
CreateProfileRequestProfileTypeEnum::THREADS => "THREADS",
CreateProfileRequestProfileTypeEnum::CONTENTION => "CONTENTION",
CreateProfileRequestProfileTypeEnum::PEAKHEAP => "PEAK_HEAP",
CreateProfileRequestProfileTypeEnum::HEAPALLOC => "HEAP_ALLOC",
}
}
}
impl std::convert::TryFrom< &str> for CreateProfileRequestProfileTypeEnum {
type Error = ();
fn try_from(value: &str) -> Result<Self, Self::Error> {
match value {
"PROFILE_TYPE_UNSPECIFIED" => Ok(CreateProfileRequestProfileTypeEnum::PROFILETYPEUNSPECIFIED),
"CPU" => Ok(CreateProfileRequestProfileTypeEnum::CPU),
"WALL" => Ok(CreateProfileRequestProfileTypeEnum::WALL),
"HEAP" => Ok(CreateProfileRequestProfileTypeEnum::HEAP),
"THREADS" => Ok(CreateProfileRequestProfileTypeEnum::THREADS),
"CONTENTION" => Ok(CreateProfileRequestProfileTypeEnum::CONTENTION),
"PEAK_HEAP" => Ok(CreateProfileRequestProfileTypeEnum::PEAKHEAP),
"HEAP_ALLOC" => Ok(CreateProfileRequestProfileTypeEnum::HEAPALLOC),
_=> Err(()),
}
}
}
impl<'a> Into<std::borrow::Cow<'a, str>> for &'a CreateProfileRequestProfileTypeEnum {
fn into(self) -> std::borrow::Cow<'a, str> {
self.as_ref().into()
}
}
// endregion
// region ProfileProfileTypeEnum
#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)]
/// Type of profile. For offline mode, this must be specified when creating the profile. For online mode it is assigned and returned by the server.
pub enum ProfileProfileTypeEnum {
/// Unspecified profile type.
///
/// "PROFILE_TYPE_UNSPECIFIED"
#[serde(rename="PROFILE_TYPE_UNSPECIFIED")]
PROFILETYPEUNSPECIFIED,
/// Thread CPU time sampling.
///
/// "CPU"
#[serde(rename="CPU")]
CPU,
/// Wallclock time sampling. More expensive as stops all threads.
///
/// "WALL"
#[serde(rename="WALL")]
WALL,
/// In-use heap profile. Represents a snapshot of the allocations that are live at the time of the profiling.
///
/// "HEAP"
#[serde(rename="HEAP")]
HEAP,
/// Single-shot collection of all thread stacks.
///
/// "THREADS"
#[serde(rename="THREADS")]
THREADS,
/// Synchronization contention profile.
///
/// "CONTENTION"
#[serde(rename="CONTENTION")]
CONTENTION,
/// Peak heap profile.
///
/// "PEAK_HEAP"
#[serde(rename="PEAK_HEAP")]
PEAKHEAP,
/// Heap allocation profile. It represents the aggregation of all allocations made over the duration of the profile. All allocations are included, including those that might have been freed by the end of the profiling interval. The profile is in particular useful for garbage collecting languages to understand which parts of the code create most of the garbage collection pressure to see if those can be optimized.
///
/// "HEAP_ALLOC"
#[serde(rename="HEAP_ALLOC")]
HEAPALLOC,
}
impl AsRef<str> for ProfileProfileTypeEnum {
fn as_ref(&self) -> &str {
match *self {
ProfileProfileTypeEnum::PROFILETYPEUNSPECIFIED => "PROFILE_TYPE_UNSPECIFIED",
ProfileProfileTypeEnum::CPU => "CPU",
ProfileProfileTypeEnum::WALL => "WALL",
ProfileProfileTypeEnum::HEAP => "HEAP",
ProfileProfileTypeEnum::THREADS => "THREADS",
ProfileProfileTypeEnum::CONTENTION => "CONTENTION",
ProfileProfileTypeEnum::PEAKHEAP => "PEAK_HEAP",
ProfileProfileTypeEnum::HEAPALLOC => "HEAP_ALLOC",
}
}
}
impl std::convert::TryFrom< &str> for ProfileProfileTypeEnum {
type Error = ();
fn try_from(value: &str) -> Result<Self, Self::Error> {
match value {
"PROFILE_TYPE_UNSPECIFIED" => Ok(ProfileProfileTypeEnum::PROFILETYPEUNSPECIFIED),
"CPU" => Ok(ProfileProfileTypeEnum::CPU),
"WALL" => Ok(ProfileProfileTypeEnum::WALL),
"HEAP" => Ok(ProfileProfileTypeEnum::HEAP),
"THREADS" => Ok(ProfileProfileTypeEnum::THREADS),
"CONTENTION" => Ok(ProfileProfileTypeEnum::CONTENTION),
"PEAK_HEAP" => Ok(ProfileProfileTypeEnum::PEAKHEAP),
"HEAP_ALLOC" => Ok(ProfileProfileTypeEnum::HEAPALLOC),
_=> Err(()),
}
}
}
impl<'a> Into<std::borrow::Cow<'a, str>> for &'a ProfileProfileTypeEnum {
fn into(self) -> std::borrow::Cow<'a, str> {
self.as_ref().into()
}
}
// endregion

View File

@@ -0,0 +1,114 @@
use super::*;
/// Central instance to access all CloudProfiler related resource activities
///
/// # Examples
///
/// Instantiate a new hub
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_cloudprofiler2 as cloudprofiler2;
/// use cloudprofiler2::api::Profile;
/// use cloudprofiler2::{Result, Error};
/// use cloudprofiler2::api::enums::*;
/// # async fn dox() {
/// use std::default::Default;
/// use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
/// // `client_secret`, among other things.
/// let secret: oauth2::ApplicationSecret = Default::default();
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
/// // unless you replace `None` with the desired Flow.
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
/// // retrieve them from storage.
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req = Profile::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.projects().profiles_patch(req, "name")
/// .update_mask(FieldMask::new::<&str>(&[]))
/// .doit().await;
///
/// match result {
/// Err(e) => match e {
/// // The Error enum provides details about what exactly happened.
/// // You can also just use its `Debug`, `Display` or `Error` traits
/// Error::HttpError(_)
/// |Error::Io(_)
/// |Error::MissingAPIKey
/// |Error::MissingToken(_)
/// |Error::Cancelled
/// |Error::UploadSizeLimitExceeded(_, _)
/// |Error::Failure(_)
/// |Error::BadRequest(_)
/// |Error::FieldClash(_)
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
/// },
/// Ok(res) => println!("Success: {:?}", res),
/// }
/// # }
/// ```
#[derive(Clone)]
pub struct CloudProfiler<S> {
pub client: hyper::Client<S, hyper::body::Body>,
pub auth: Box<dyn client::GetToken>,
pub(super) _user_agent: String,
pub(super) _base_url: String,
pub(super) _root_url: String,
}
impl<'a, S> client::Hub for CloudProfiler<S> {}
impl<'a, S> CloudProfiler<S> {
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> CloudProfiler<S> {
CloudProfiler {
client,
auth: Box::new(auth),
_user_agent: "google-api-rust-client/5.0.5".to_string(),
_base_url: "https://cloudprofiler.googleapis.com/".to_string(),
_root_url: "https://cloudprofiler.googleapis.com/".to_string(),
}
}
pub fn projects(&'a self) -> ProjectMethods<'a, S> {
ProjectMethods { hub: &self }
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/5.0.5`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
mem::replace(&mut self._user_agent, agent_name)
}
/// Set the base url to use in all requests to the server.
/// It defaults to `https://cloudprofiler.googleapis.com/`.
///
/// Returns the previously set base url.
pub fn base_url(&mut self, new_base_url: String) -> String {
mem::replace(&mut self._base_url, new_base_url)
}
/// Set the root url to use in all requests to the server.
/// It defaults to `https://cloudprofiler.googleapis.com/`.
///
/// Returns the previously set root url.
pub fn root_url(&mut self, new_root_url: String) -> String {
mem::replace(&mut self._root_url, new_root_url)
}
}

View File

@@ -0,0 +1,119 @@
use super::*;
/// A builder providing access to all methods supported on *project* resources.
/// It is not used directly, but through the [`CloudProfiler`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_cloudprofiler2 as cloudprofiler2;
///
/// # async fn dox() {
/// use std::default::Default;
/// use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `profiles_create(...)`, `profiles_create_offline(...)`, `profiles_list(...)` and `profiles_patch(...)`
/// // to build up your call.
/// let rb = hub.projects();
/// # }
/// ```
pub struct ProjectMethods<'a, S>
where S: 'a {
pub(super) hub: &'a CloudProfiler<S>,
}
impl<'a, S> client::MethodsBuilder for ProjectMethods<'a, S> {}
impl<'a, S> ProjectMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// CreateProfile creates a new profile resource in the online mode. _Direct use of this API is discouraged, please use a [supported profiler agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection._ The server ensures that the new profiles are created at a constant rate per deployment, so the creation request may hang for some time until the next profile session is available. The request may fail with ABORTED error if the creation is not available within ~1m, the response will indicate the duration of the backoff the client should take before attempting creating a profile again. The backoff duration is returned in google.rpc.RetryInfo extension on the response status. To a gRPC client, the extension will be return as a binary-serialized proto in the trailing metadata item named "google.rpc.retryinfo-bin".
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `parent` - Parent project to create the profile in.
pub fn profiles_create(&self, request: CreateProfileRequest, parent: &str) -> ProjectProfileCreateCall<'a, S> {
ProjectProfileCreateCall {
hub: self.hub,
_request: request,
_parent: parent.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// CreateOfflineProfile creates a new profile resource in the offline mode. The client provides the profile to create along with the profile bytes, the server records it. _Direct use of this API is discouraged, please use a [supported profiler agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection._
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `parent` - Parent project to create the profile in.
pub fn profiles_create_offline(&self, request: Profile, parent: &str) -> ProjectProfileCreateOfflineCall<'a, S> {
ProjectProfileCreateOfflineCall {
hub: self.hub,
_request: request,
_parent: parent.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists profiles which have been collected so far and for which the caller has permission to view.
///
/// # Arguments
///
/// * `parent` - Required. The parent, which owns this collection of profiles. Format: projects/{user_project_id}
pub fn profiles_list(&self, parent: &str) -> ProjectProfileListCall<'a, S> {
ProjectProfileListCall {
hub: self.hub,
_parent: parent.to_string(),
_page_token: Default::default(),
_page_size: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// UpdateProfile updates the profile bytes and labels on the profile resource created in the online mode. Updating the bytes for profiles created in the offline mode is currently not supported: the profile content must be provided at the time of the profile creation. _Direct use of this API is discouraged, please use a [supported profiler agent](https://cloud.google.com/profiler/docs/about-profiler#profiling_agent) instead for profile collection._
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `name` - Output only. Opaque, server-assigned, unique ID for this profile.
pub fn profiles_patch(&self, request: Profile, name: &str) -> ProjectProfilePatchCall<'a, S> {
ProjectProfilePatchCall {
hub: self.hub,
_request: request,
_name: name.to_string(),
_update_mask: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}

View File

@@ -0,0 +1,35 @@
use std::collections::HashMap;
use std::cell::RefCell;
use std::default::Default;
use std::collections::BTreeSet;
use std::error::Error as StdError;
use serde_json as json;
use std::io;
use std::fs;
use std::mem;
use hyper::client::connect;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::time::sleep;
use tower_service;
use serde::{Serialize, Deserialize};
use crate::{client, client::GetToken, client::serde_with};
mod utilities;
pub use utilities::*;
mod hub;
pub use hub::*;
mod schemas;
pub use schemas::*;
mod method_builders;
pub use method_builders::*;
mod call_builders;
pub use call_builders::*;
pub mod enums;
pub(crate) use enums::*;

View File

@@ -0,0 +1,118 @@
use super::*;
/// CreateProfileRequest describes a profile resource online creation request. The deployment field must be populated. The profile_type specifies the list of profile types supported by the agent. The creation call will hang until a profile of one of these types needs to be collected.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [profiles create projects](ProjectProfileCreateCall) (request)
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreateProfileRequest {
/// Deployment details.
pub deployment: Option<Deployment>,
/// One or more profile types that the agent is capable of providing.
#[serde(rename="profileType")]
pub profile_type: Option<Vec<CreateProfileRequestProfileTypeEnum>>,
}
impl client::RequestValue for CreateProfileRequest {}
/// Deployment contains the deployment identification information.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Deployment {
/// Labels identify the deployment within the user universe and same target. Validation regex for label names: `^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`. Value for an individual label must be \<= 512 bytes, the total size of all label names and values must be \<= 1024 bytes. Label named “language” can be used to record the programming language of the profiled deployment. The standard choices for the value include “java”, “go”, “python”, “ruby”, “nodejs”, “php”, “dotnet”. For deployments running on Google Cloud Platform, “zone” or “region” label should be present describing the deployment location. An example of a zone is “us-central1-a”, an example of a region is “us-central1” or “us-central”.
pub labels: Option<HashMap<String, String>>,
/// Project ID is the ID of a cloud project. Validation regex: `^a-z{4,61}[a-z0-9]$`.
#[serde(rename="projectId")]
pub project_id: Option<String>,
/// Target is the service name used to group related deployments: * Service name for App Engine Flex / Standard. * Cluster and container name for GKE. * User-specified string for direct Compute Engine profiling (e.g. Java). * Job name for Dataflow. Validation regex: `^[a-z0-9]([-a-z0-9_.]{0,253}[a-z0-9])?$`.
pub target: Option<String>,
}
impl client::Part for Deployment {}
/// ListProfileResponse contains the list of collected profiles for deployments in projects which the user has permissions to view.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [profiles list projects](ProjectProfileListCall) (response)
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ListProfilesResponse {
/// Token to receive the next page of results. This field maybe empty if there are no more profiles to fetch.
#[serde(rename="nextPageToken")]
pub next_page_token: Option<String>,
/// List of profiles fetched.
pub profiles: Option<Vec<Profile>>,
/// Number of profiles that were skipped in the current page since they were not able to be fetched successfully. This should typically be zero. A non-zero value may indicate a transient failure, in which case if the number is too high for your use case, the call may be retried.
#[serde(rename="skippedProfiles")]
pub skipped_profiles: Option<i32>,
}
impl client::ResponseResult for ListProfilesResponse {}
/// Profile resource.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [profiles create projects](ProjectProfileCreateCall) (response)
/// * [profiles create offline projects](ProjectProfileCreateOfflineCall) (request|response)
/// * [profiles patch projects](ProjectProfilePatchCall) (request|response)
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Profile {
/// Deployment this profile corresponds to.
pub deployment: Option<Deployment>,
/// Duration of the profiling session. Input (for the offline mode) or output (for the online mode). The field represents requested profiling duration. It may slightly differ from the effective profiling duration, which is recorded in the profile data, in case the profiling can't be stopped immediately (e.g. in case stopping the profiling is handled asynchronously).
#[serde_as(as = "Option<::client::serde::duration::Wrapper>")]
pub duration: Option<client::chrono::Duration>,
/// Input only. Labels associated to this specific profile. These labels will get merged with the deployment labels for the final data set. See documentation on deployment labels for validation rules and limits.
pub labels: Option<HashMap<String, String>>,
/// Output only. Opaque, server-assigned, unique ID for this profile.
pub name: Option<String>,
/// Input only. Profile bytes, as a gzip compressed serialized proto, the format is https://github.com/google/pprof/blob/master/proto/profile.proto.
#[serde(rename="profileBytes")]
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub profile_bytes: Option<Vec<u8>>,
/// Type of profile. For offline mode, this must be specified when creating the profile. For online mode it is assigned and returned by the server.
#[serde(rename="profileType")]
pub profile_type: Option<ProfileProfileTypeEnum>,
/// Output only. Start time for the profile. This output is only present in response from the ListProfiles method.
#[serde(rename="startTime")]
pub start_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
}
impl client::RequestValue for Profile {}
impl client::ResponseResult for Profile {}

View File

@@ -0,0 +1,32 @@
use super::*;
/// Identifies the an OAuth2 authorization scope.
/// A scope is needed when requesting an
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
pub enum Scope {
/// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
CloudPlatform,
/// View and write monitoring data for all of your Google and third-party Cloud and API projects
Monitoring,
/// Publish metric data to your Google Cloud projects
MonitoringWrite,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
Scope::Monitoring => "https://www.googleapis.com/auth/monitoring",
Scope::MonitoringWrite => "https://www.googleapis.com/auth/monitoring.write",
}
}
}
impl Default for Scope {
fn default() -> Scope {
Scope::Monitoring
}
}

View File

@@ -2,14 +2,14 @@
// This file was generated automatically from 'src/generator/templates/api/lib.rs.mako'
// DO NOT EDIT !
//! This documentation was generated from *Cloud Profiler* crate version *5.0.4+20240219*, where *20240219* is the exact revision of the *cloudprofiler:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v5.0.4*.
//! This documentation was generated from *Cloud Profiler* crate version *5.0.5+20240331*, where *20240331* is the exact revision of the *cloudprofiler:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v5.0.5*.
//!
//! Everything else about the *Cloud Profiler* *v2* API can be found at the
//! [official documentation site](https://cloud.google.com/profiler/).
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/main/gen/cloudprofiler2).
//! # Features
//!
//! Handle the following *Resources* with ease from the central [hub](CloudProfiler) ...
//! Handle the following *Resources* with ease from the central [hub](CloudProfiler) ...
//!
//! * projects
//! * [*profiles create*](api::ProjectProfileCreateCall), [*profiles create offline*](api::ProjectProfileCreateOfflineCall), [*profiles list*](api::ProjectProfileListCall) and [*profiles patch*](api::ProjectProfilePatchCall)
@@ -52,8 +52,8 @@
//! let r = hub.projects().profiles_patch(...).doit().await
//! ```
//!
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
//! The `doit()` method performs the actual communication with the server and returns the respective result.
//!
@@ -78,23 +78,24 @@
//! extern crate google_cloudprofiler2 as cloudprofiler2;
//! use cloudprofiler2::api::Profile;
//! use cloudprofiler2::{Result, Error};
//! use cloudprofiler2::api::enums::*;
//! # async fn dox() {
//! use std::default::Default;
//! use cloudprofiler2::{CloudProfiler, oauth2, hyper, hyper_rustls, chrono, FieldMask};
//!
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
//! // `client_secret`, among other things.
//! let secret: oauth2::ApplicationSecret = Default::default();
//! // Instantiate the authenticator. It will choose a suitable authentication flow for you,
//! // Instantiate the authenticator. It will choose a suitable authentication flow for you,
//! // unless you replace `None` with the desired Flow.
//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
//! // retrieve them from storage.
//! let auth = oauth2::InstalledFlowAuthenticator::builder(
//! secret,
//! oauth2::InstalledFlowReturnMethod::HTTPRedirect,
//! ).build().await.unwrap();
//! let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
//! let mut hub = CloudProfiler::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
//! // As the method needs a request, you would usually fill it with the desired information
//! // into the respective structure. Some of the parts shown here might not be applicable !
//! // Values shown here are possibly random and not representative !
@@ -104,7 +105,7 @@
//! // execute the final call using `doit()`.
//! // Values shown here are possibly random and not representative !
//! let result = hub.projects().profiles_patch(req, "name")
//! .update_mask(&Default::default())
//! .update_mask(FieldMask::new::<&str>(&[]))
//! .doit().await;
//!
//! match result {
@@ -129,10 +130,10 @@
//! ## Handling Errors
//!
//! All errors produced by the system are provided either as [Result](client::Result) enumeration as return value of
//! the doit() methods, or handed as possibly intermediate results to either the
//! the doit() methods, or handed as possibly intermediate results to either the
//! [Hub Delegate](client::Delegate), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
//!
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
//! makes the system potentially resilient to all kinds of errors.
//!
//! ## Uploads and Downloads
@@ -142,25 +143,25 @@
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
//! this call: `.param("alt", "media")`.
//!
//! Methods supporting uploads can do so using up to 2 different protocols:
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
//! Methods supporting uploads can do so using up to 2 different protocols:
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
//!
//! ## Customization and Callbacks
//!
//! You may alter the way an `doit()` method is called by providing a [delegate](client::Delegate) to the
//! [Method Builder](client::CallBuilder) before making the final `doit()` call.
//! Respective methods will be called to provide progress information, as well as determine whether the system should
//! You may alter the way an `doit()` method is called by providing a [delegate](client::Delegate) to the
//! [Method Builder](client::CallBuilder) before making the final `doit()` call.
//! Respective methods will be called to provide progress information, as well as determine whether the system should
//! retry on failure.
//!
//! The [delegate trait](client::Delegate) is default-implemented, allowing you to customize it with minimal effort.
//!
//! ## Optional Parts in Server-Requests
//!
//! All structures provided by this library are made to be [encodable](client::RequestValue) and
//! [decodable](client::ResponseResult) via *json*. Optionals are used to indicate that partial requests are responses
//! All structures provided by this library are made to be [encodable](client::RequestValue) and
//! [decodable](client::ResponseResult) via *json*. Optionals are used to indicate that partial requests are responses
//! are valid.
//! Most optionals are are considered [Parts](client::Part) which are identifiable by name, which will be sent to
//! Most optionals are are considered [Parts](client::Part) which are identifiable by name, which will be sent to
//! the server to indicate either the set parts of the request or the desired parts in the response.
//!
//! ## Builder Arguments