From ada46072120b6e4c3b210158354cc1de922d2669 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Sat, 24 Feb 2024 04:04:26 +0000 Subject: [PATCH 1/2] feat: add `start_time` to Profile proto docs: update documentation to add guidance around use of ProfilerService API methods PiperOrigin-RevId: 609836544 Source-Link: https://github.com/googleapis/googleapis/commit/c5b43c89282bb8c39cbfbc0dc226386292633fa4 Source-Link: https://github.com/googleapis/googleapis-gen/commit/aefdaf1520429808b5d954ae24f2922e251c2a89 Copy-Tag: eyJwIjoiUHJvZmlsZXIvLk93bEJvdC55YW1sIiwiaCI6ImFlZmRhZjE1MjA0Mjk4MDhiNWQ5NTRhZTI0ZjI5MjJlMjUxYzJhODkifQ== --- .../Devtools/Cloudprofiler/V2/Profiler.php | Bin 0 -> 4189 bytes .../V2/CreateOfflineProfileRequest.php | 127 +++++ .../Profiler/V2/CreateProfileRequest.php | 148 ++++++ .../Google/Cloud/Profiler/V2/Deployment.php | 199 ++++++++ .../Cloud/Profiler/V2/ListProfilesRequest.php | 171 +++++++ .../Profiler/V2/ListProfilesResponse.php | 152 ++++++ .../src/Google/Cloud/Profiler/V2/Profile.php | 345 +++++++++++++ .../Google/Cloud/Profiler/V2/ProfileType.php | 104 ++++ .../Profiler/V2/UpdateProfileRequest.php | 151 ++++++ .../V2/ExportServiceClient/list_profiles.php | 78 +++ .../create_offline_profile.php | 64 +++ .../ProfilerServiceClient/create_profile.php | 75 +++ .../ProfilerServiceClient/update_profile.php | 65 +++ .../v2/src/V2/Client/ExportServiceClient.php | 239 +++++++++ .../src/V2/Client/ProfilerServiceClient.php | 348 +++++++++++++ .../v2/src/V2/ExportServiceClient.php | 34 ++ .../src/V2/Gapic/ExportServiceGapicClient.php | 333 ++++++++++++ .../V2/Gapic/ProfilerServiceGapicClient.php | 473 ++++++++++++++++++ .../v2/src/V2/ProfilerServiceClient.php | 34 ++ .../Profiler/v2/src/V2/gapic_metadata.json | 47 ++ .../export_service_client_config.json | 39 ++ .../export_service_descriptor_config.php | 31 ++ .../export_service_rest_client_config.php | 20 + .../profiler_service_client_config.json | 69 +++ .../profiler_service_descriptor_config.php | 49 ++ .../profiler_service_rest_client_config.php | 46 ++ .../V2/Client/ExportServiceClientTest.php | 176 +++++++ .../V2/Client/ProfilerServiceClientTest.php | 264 ++++++++++ .../tests/Unit/V2/ExportServiceClientTest.php | 132 +++++ .../Unit/V2/ProfilerServiceClientTest.php | 229 +++++++++ 30 files changed, 4242 insertions(+) create mode 100644 owl-bot-staging/Profiler/v2/proto/src/GPBMetadata/Google/Devtools/Cloudprofiler/V2/Profiler.php create mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateOfflineProfileRequest.php create mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateProfileRequest.php create mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Deployment.php create mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesRequest.php create mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesResponse.php create mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Profile.php create mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ProfileType.php create mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/UpdateProfileRequest.php create mode 100644 owl-bot-staging/Profiler/v2/samples/V2/ExportServiceClient/list_profiles.php create mode 100644 owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_offline_profile.php create mode 100644 owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_profile.php create mode 100644 owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/update_profile.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/Client/ExportServiceClient.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/Client/ProfilerServiceClient.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/ExportServiceClient.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/Gapic/ExportServiceGapicClient.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/Gapic/ProfilerServiceGapicClient.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/ProfilerServiceClient.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/gapic_metadata.json create mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/export_service_client_config.json create mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/export_service_descriptor_config.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/export_service_rest_client_config.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_client_config.json create mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_descriptor_config.php create mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_rest_client_config.php create mode 100644 owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ExportServiceClientTest.php create mode 100644 owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ProfilerServiceClientTest.php create mode 100644 owl-bot-staging/Profiler/v2/tests/Unit/V2/ExportServiceClientTest.php create mode 100644 owl-bot-staging/Profiler/v2/tests/Unit/V2/ProfilerServiceClientTest.php diff --git a/owl-bot-staging/Profiler/v2/proto/src/GPBMetadata/Google/Devtools/Cloudprofiler/V2/Profiler.php b/owl-bot-staging/Profiler/v2/proto/src/GPBMetadata/Google/Devtools/Cloudprofiler/V2/Profiler.php new file mode 100644 index 0000000000000000000000000000000000000000..2ccee3ee6a7c23632bd0a812ccfc4687680aa274 GIT binary patch literal 4189 zcmdT{&2!sC6i0SGnst-9TW0FI9S|m+x@jVVGcZLVfMPpoAdNkVTL#868d+W^BC;f; zb<)tufsf(9l>-M3oMDC;{)gUrESz$o2Tnb3;K+gDt+Z0)q``J>F?y|=&jdtbY6 zzw2x}=v8rrSj5#RX^G8!k!};wacyerwkbBd?KW{m-R?MsNnA-3%T;l`S{Ezj)%q)- z>e*daC$hL@+gm0nw8$>CZPP30rrm9UnKn}^>=p~*TJmipWN97ZIhszymDLbaAg zwZ@8Xrcvf*8l||I#{J>~Lb|DWo>=3i(L*G{pVMuchAw(kqwq6rc&cF;)X+@hGw^Cr zY-^@RK>4I>yKCvxuq}}(R4tw4Z;F9UCOhqbH=rK^gJY=;q%>A7N?c1b0jj6FhC^+) z2BNaOMQB7P`;x!Ok7eeJwwMnv%JK=2iz0QqB!0Rmx`cLJYr)6O3>-wO#&c*>9HXIF zmd#kOEl-w@d^$35nqtW`h((9fSvH8-S|Z!pu3@{wscsOSIs=1@xG#4hS;4`<4~$fO zz;`uo=M1`a12UFs9q0MFeyYs9WAMaKTCFG#mZ1ppQRG-0Z=mn4pu&(vgL#!nVU$lfTg70pR;#@kjf? z0Ue>ia=#1c#ga>)2SKP<&)6WJc7bjD9vX8r7yQVKh(dm1>9xO=IdseS zJ4D&hENu&VQ-BgY_ax|71u*mp(U}F*B93YAcbF9ctfY#wT=;Y*rE;W$OXxfRXQ))V z?~qJFOy;MGbNy{_U+SQg`(8j-0}re1wrN4b=1OqLbG!y6*GiWD7i!S z1IF%m@kZaGByJ)(%=bS7$Rwwv6IL)fhD?H?@gYX6rd}2}uxgQ0D zVugkg;?kYm)(nsG5O`sSDn%VC zDBSs{N@D0HbrDTC(8N>^?km2dqnMGwK2dvzSQ(b66S=RUOnWhS4h(vN7tlFij*;pC zZ!DRHsME{nf<+!sHFlgIbeutHZ^v*P(o!Sq49MurR{~0LB3O6B*HEUmQC(hLtElyl zY8Ca~`evOI1d|&2^ z`M{T;E+jThVj($dM>7YJ7ulbM$I7+;>Tpk#Z-i}19ZxP4_V)I8z@kfs)}`CQ+h@)( zHQKh_&TK#Njtwsl+cm7MAw;D;*Px{MR{~8|9yqp3!}R|}K1}K_d zwV)H_UO!a$jm?ij4)-mI{~PH`zX>n}?M~lfU78Gg6Z}%UCVaf&r&g%QZmC=Lv8OVm z610$>6m*&k$Nv8*ky-Iy%2J6vki%<%E8Qgoogle.devtools.cloudprofiler.v2.CreateOfflineProfileRequest + */ +class CreateOfflineProfileRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Parent project to create the profile in. + * + * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Contents of the profile to create. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 2; + */ + protected $profile = null; + + /** + * @param string $parent Parent project to create the profile in. + * @param \Google\Cloud\Profiler\V2\Profile $profile Contents of the profile to create. + * + * @return \Google\Cloud\Profiler\V2\CreateOfflineProfileRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\Profiler\V2\Profile $profile): self + { + return (new self()) + ->setParent($parent) + ->setProfile($profile); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Parent project to create the profile in. + * @type \Google\Cloud\Profiler\V2\Profile $profile + * Contents of the profile to create. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); + parent::__construct($data); + } + + /** + * Parent project to create the profile in. + * + * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Parent project to create the profile in. + * + * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Contents of the profile to create. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 2; + * @return \Google\Cloud\Profiler\V2\Profile|null + */ + public function getProfile() + { + return $this->profile; + } + + public function hasProfile() + { + return isset($this->profile); + } + + public function clearProfile() + { + unset($this->profile); + } + + /** + * Contents of the profile to create. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 2; + * @param \Google\Cloud\Profiler\V2\Profile $var + * @return $this + */ + public function setProfile($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Profiler\V2\Profile::class); + $this->profile = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateProfileRequest.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateProfileRequest.php new file mode 100644 index 000000000000..ef1a7c790639 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateProfileRequest.php @@ -0,0 +1,148 @@ +google.devtools.cloudprofiler.v2.CreateProfileRequest + */ +class CreateProfileRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Parent project to create the profile in. + * + * Generated from protobuf field string parent = 4 [(.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Deployment details. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 1; + */ + protected $deployment = null; + /** + * One or more profile types that the agent is capable of providing. + * + * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; + */ + private $profile_type; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Parent project to create the profile in. + * @type \Google\Cloud\Profiler\V2\Deployment $deployment + * Deployment details. + * @type array|\Google\Protobuf\Internal\RepeatedField $profile_type + * One or more profile types that the agent is capable of providing. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); + parent::__construct($data); + } + + /** + * Parent project to create the profile in. + * + * Generated from protobuf field string parent = 4 [(.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Parent project to create the profile in. + * + * Generated from protobuf field string parent = 4 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Deployment details. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 1; + * @return \Google\Cloud\Profiler\V2\Deployment|null + */ + public function getDeployment() + { + return $this->deployment; + } + + public function hasDeployment() + { + return isset($this->deployment); + } + + public function clearDeployment() + { + unset($this->deployment); + } + + /** + * Deployment details. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 1; + * @param \Google\Cloud\Profiler\V2\Deployment $var + * @return $this + */ + public function setDeployment($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Profiler\V2\Deployment::class); + $this->deployment = $var; + + return $this; + } + + /** + * One or more profile types that the agent is capable of providing. + * + * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getProfileType() + { + return $this->profile_type; + } + + /** + * One or more profile types that the agent is capable of providing. + * + * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setProfileType($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Profiler\V2\ProfileType::class); + $this->profile_type = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Deployment.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Deployment.php new file mode 100644 index 000000000000..4ee6e5aaebc1 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Deployment.php @@ -0,0 +1,199 @@ +google.devtools.cloudprofiler.v2.Deployment + */ +class Deployment extends \Google\Protobuf\Internal\Message +{ + /** + * Project ID is the ID of a cloud project. + * Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`. + * + * Generated from protobuf field string project_id = 1; + */ + protected $project_id = ''; + /** + * 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])?$`. + * + * Generated from protobuf field string target = 2; + */ + protected $target = ''; + /** + * 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". + * + * Generated from protobuf field map labels = 3; + */ + private $labels; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $project_id + * Project ID is the ID of a cloud project. + * Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`. + * @type string $target + * 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])?$`. + * @type array|\Google\Protobuf\Internal\MapField $labels + * 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". + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); + parent::__construct($data); + } + + /** + * Project ID is the ID of a cloud project. + * Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`. + * + * Generated from protobuf field string project_id = 1; + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * Project ID is the ID of a cloud project. + * Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`. + * + * Generated from protobuf field string project_id = 1; + * @param string $var + * @return $this + */ + public function setProjectId($var) + { + GPBUtil::checkString($var, True); + $this->project_id = $var; + + return $this; + } + + /** + * 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])?$`. + * + * Generated from protobuf field string target = 2; + * @return string + */ + public function getTarget() + { + return $this->target; + } + + /** + * 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])?$`. + * + * Generated from protobuf field string target = 2; + * @param string $var + * @return $this + */ + public function setTarget($var) + { + GPBUtil::checkString($var, True); + $this->target = $var; + + return $this; + } + + /** + * 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". + * + * Generated from protobuf field map labels = 3; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * 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". + * + * Generated from protobuf field map labels = 3; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->labels = $arr; + + return $this; + } + +} + diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesRequest.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesRequest.php new file mode 100644 index 000000000000..ff53a3c48f13 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesRequest.php @@ -0,0 +1,171 @@ +google.devtools.cloudprofiler.v2.ListProfilesRequest + */ +class ListProfilesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent, which owns this collection of profiles. + * Format: projects/{user_project_id} + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * The maximum number of items to return. + * Default page_size is 1000. + * Max limit is 1000. + * + * Generated from protobuf field int32 page_size = 2; + */ + protected $page_size = 0; + /** + * 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. + * + * Generated from protobuf field string page_token = 3; + */ + protected $page_token = ''; + + /** + * @param string $parent Required. The parent, which owns this collection of profiles. + * Format: projects/{user_project_id} + * Please see {@see ExportServiceClient::projectName()} for help formatting this field. + * + * @return \Google\Cloud\Profiler\V2\ListProfilesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent, which owns this collection of profiles. + * Format: projects/{user_project_id} + * @type int $page_size + * The maximum number of items to return. + * Default page_size is 1000. + * Max limit is 1000. + * @type string $page_token + * 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. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent, which owns this collection of profiles. + * Format: projects/{user_project_id} + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The parent, which owns this collection of profiles. + * Format: projects/{user_project_id} + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * The maximum number of items to return. + * Default page_size is 1000. + * Max limit is 1000. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * The maximum number of items to return. + * Default page_size is 1000. + * Max limit is 1000. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * 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. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesResponse.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesResponse.php new file mode 100644 index 000000000000..a52a9ccd27a9 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesResponse.php @@ -0,0 +1,152 @@ +google.devtools.cloudprofiler.v2.ListProfilesResponse + */ +class ListProfilesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * List of profiles fetched. + * + * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + private $profiles; + /** + * Token to receive the next page of results. + * This field maybe empty if there are no more profiles to fetch. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + /** + * 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. + * + * Generated from protobuf field int32 skipped_profiles = 3; + */ + protected $skipped_profiles = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Profiler\V2\Profile>|\Google\Protobuf\Internal\RepeatedField $profiles + * List of profiles fetched. + * @type string $next_page_token + * Token to receive the next page of results. + * This field maybe empty if there are no more profiles to fetch. + * @type int $skipped_profiles + * 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. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); + parent::__construct($data); + } + + /** + * List of profiles fetched. + * + * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getProfiles() + { + return $this->profiles; + } + + /** + * List of profiles fetched. + * + * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + * @param array<\Google\Cloud\Profiler\V2\Profile>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setProfiles($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Profiler\V2\Profile::class); + $this->profiles = $arr; + + return $this; + } + + /** + * Token to receive the next page of results. + * This field maybe empty if there are no more profiles to fetch. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * Token to receive the next page of results. + * This field maybe empty if there are no more profiles to fetch. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field int32 skipped_profiles = 3; + * @return int + */ + public function getSkippedProfiles() + { + return $this->skipped_profiles; + } + + /** + * 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. + * + * Generated from protobuf field int32 skipped_profiles = 3; + * @param int $var + * @return $this + */ + public function setSkippedProfiles($var) + { + GPBUtil::checkInt32($var); + $this->skipped_profiles = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Profile.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Profile.php new file mode 100644 index 000000000000..90f9a635a620 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Profile.php @@ -0,0 +1,345 @@ +google.devtools.cloudprofiler.v2.Profile + */ +class Profile extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Opaque, server-assigned, unique ID for this profile. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $name = ''; + /** + * 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. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; + */ + protected $profile_type = 0; + /** + * Deployment this profile corresponds to. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 3; + */ + protected $deployment = null; + /** + * 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). + * + * Generated from protobuf field .google.protobuf.Duration duration = 4; + */ + protected $duration = null; + /** + * Input only. Profile bytes, as a gzip compressed serialized proto, the + * format is https://github.com/google/pprof/blob/master/proto/profile.proto. + * + * Generated from protobuf field bytes profile_bytes = 5 [(.google.api.field_behavior) = INPUT_ONLY]; + */ + protected $profile_bytes = ''; + /** + * 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. + * + * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = INPUT_ONLY]; + */ + private $labels; + /** + * Output only. Start time for the profile. + * This output is only present in response from the ListProfiles method. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $start_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Output only. Opaque, server-assigned, unique ID for this profile. + * @type int $profile_type + * 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. + * @type \Google\Cloud\Profiler\V2\Deployment $deployment + * Deployment this profile corresponds to. + * @type \Google\Protobuf\Duration $duration + * 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). + * @type string $profile_bytes + * Input only. Profile bytes, as a gzip compressed serialized proto, the + * format is https://github.com/google/pprof/blob/master/proto/profile.proto. + * @type array|\Google\Protobuf\Internal\MapField $labels + * 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. + * @type \Google\Protobuf\Timestamp $start_time + * Output only. Start time for the profile. + * This output is only present in response from the ListProfiles method. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Opaque, server-assigned, unique ID for this profile. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. Opaque, server-assigned, unique ID for this profile. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; + * @return int + */ + public function getProfileType() + { + return $this->profile_type; + } + + /** + * 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. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; + * @param int $var + * @return $this + */ + public function setProfileType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Profiler\V2\ProfileType::class); + $this->profile_type = $var; + + return $this; + } + + /** + * Deployment this profile corresponds to. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 3; + * @return \Google\Cloud\Profiler\V2\Deployment|null + */ + public function getDeployment() + { + return $this->deployment; + } + + public function hasDeployment() + { + return isset($this->deployment); + } + + public function clearDeployment() + { + unset($this->deployment); + } + + /** + * Deployment this profile corresponds to. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 3; + * @param \Google\Cloud\Profiler\V2\Deployment $var + * @return $this + */ + public function setDeployment($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Profiler\V2\Deployment::class); + $this->deployment = $var; + + return $this; + } + + /** + * 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). + * + * Generated from protobuf field .google.protobuf.Duration duration = 4; + * @return \Google\Protobuf\Duration|null + */ + public function getDuration() + { + return $this->duration; + } + + public function hasDuration() + { + return isset($this->duration); + } + + public function clearDuration() + { + unset($this->duration); + } + + /** + * 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). + * + * Generated from protobuf field .google.protobuf.Duration duration = 4; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setDuration($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->duration = $var; + + return $this; + } + + /** + * Input only. Profile bytes, as a gzip compressed serialized proto, the + * format is https://github.com/google/pprof/blob/master/proto/profile.proto. + * + * Generated from protobuf field bytes profile_bytes = 5 [(.google.api.field_behavior) = INPUT_ONLY]; + * @return string + */ + public function getProfileBytes() + { + return $this->profile_bytes; + } + + /** + * Input only. Profile bytes, as a gzip compressed serialized proto, the + * format is https://github.com/google/pprof/blob/master/proto/profile.proto. + * + * Generated from protobuf field bytes profile_bytes = 5 [(.google.api.field_behavior) = INPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setProfileBytes($var) + { + GPBUtil::checkString($var, False); + $this->profile_bytes = $var; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = INPUT_ONLY]; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabels() + { + return $this->labels; + } + + /** + * 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. + * + * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = INPUT_ONLY]; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->labels = $arr; + + return $this; + } + + /** + * Output only. Start time for the profile. + * This output is only present in response from the ListProfiles method. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * Output only. Start time for the profile. + * This output is only present in response from the ListProfiles method. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->start_time = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ProfileType.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ProfileType.php new file mode 100644 index 000000000000..c2adbcdd0ccf --- /dev/null +++ b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ProfileType.php @@ -0,0 +1,104 @@ +google.devtools.cloudprofiler.v2.ProfileType + */ +class ProfileType +{ + /** + * Unspecified profile type. + * + * Generated from protobuf enum PROFILE_TYPE_UNSPECIFIED = 0; + */ + const PROFILE_TYPE_UNSPECIFIED = 0; + /** + * Thread CPU time sampling. + * + * Generated from protobuf enum CPU = 1; + */ + const CPU = 1; + /** + * Wallclock time sampling. More expensive as stops all threads. + * + * Generated from protobuf enum WALL = 2; + */ + const WALL = 2; + /** + * In-use heap profile. Represents a snapshot of the allocations that are + * live at the time of the profiling. + * + * Generated from protobuf enum HEAP = 3; + */ + const HEAP = 3; + /** + * Single-shot collection of all thread stacks. + * + * Generated from protobuf enum THREADS = 4; + */ + const THREADS = 4; + /** + * Synchronization contention profile. + * + * Generated from protobuf enum CONTENTION = 5; + */ + const CONTENTION = 5; + /** + * Peak heap profile. + * + * Generated from protobuf enum PEAK_HEAP = 6; + */ + const PEAK_HEAP = 6; + /** + * 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. + * + * Generated from protobuf enum HEAP_ALLOC = 7; + */ + const HEAP_ALLOC = 7; + + private static $valueToName = [ + self::PROFILE_TYPE_UNSPECIFIED => 'PROFILE_TYPE_UNSPECIFIED', + self::CPU => 'CPU', + self::WALL => 'WALL', + self::HEAP => 'HEAP', + self::THREADS => 'THREADS', + self::CONTENTION => 'CONTENTION', + self::PEAK_HEAP => 'PEAK_HEAP', + self::HEAP_ALLOC => 'HEAP_ALLOC', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/UpdateProfileRequest.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/UpdateProfileRequest.php new file mode 100644 index 000000000000..3db9dcecdd2c --- /dev/null +++ b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/UpdateProfileRequest.php @@ -0,0 +1,151 @@ +google.devtools.cloudprofiler.v2.UpdateProfileRequest + */ +class UpdateProfileRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Profile to update. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 1; + */ + protected $profile = null; + /** + * Field mask used to specify the fields to be overwritten. Currently only + * profile_bytes and labels fields are supported by UpdateProfile, so only + * those fields can be specified in the mask. When no mask is provided, all + * fields are overwritten. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + */ + protected $update_mask = null; + + /** + * @param \Google\Cloud\Profiler\V2\Profile $profile Profile to update. + * @param \Google\Protobuf\FieldMask $updateMask Field mask used to specify the fields to be overwritten. Currently only + * profile_bytes and labels fields are supported by UpdateProfile, so only + * those fields can be specified in the mask. When no mask is provided, all + * fields are overwritten. + * + * @return \Google\Cloud\Profiler\V2\UpdateProfileRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Profiler\V2\Profile $profile, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setProfile($profile) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Profiler\V2\Profile $profile + * Profile to update. + * @type \Google\Protobuf\FieldMask $update_mask + * Field mask used to specify the fields to be overwritten. Currently only + * profile_bytes and labels fields are supported by UpdateProfile, so only + * those fields can be specified in the mask. When no mask is provided, all + * fields are overwritten. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); + parent::__construct($data); + } + + /** + * Profile to update. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 1; + * @return \Google\Cloud\Profiler\V2\Profile|null + */ + public function getProfile() + { + return $this->profile; + } + + public function hasProfile() + { + return isset($this->profile); + } + + public function clearProfile() + { + unset($this->profile); + } + + /** + * Profile to update. + * + * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 1; + * @param \Google\Cloud\Profiler\V2\Profile $var + * @return $this + */ + public function setProfile($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Profiler\V2\Profile::class); + $this->profile = $var; + + return $this; + } + + /** + * Field mask used to specify the fields to be overwritten. Currently only + * profile_bytes and labels fields are supported by UpdateProfile, so only + * those fields can be specified in the mask. When no mask is provided, all + * fields are overwritten. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Field mask used to specify the fields to be overwritten. Currently only + * profile_bytes and labels fields are supported by UpdateProfile, so only + * those fields can be specified in the mask. When no mask is provided, all + * fields are overwritten. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/owl-bot-staging/Profiler/v2/samples/V2/ExportServiceClient/list_profiles.php b/owl-bot-staging/Profiler/v2/samples/V2/ExportServiceClient/list_profiles.php new file mode 100644 index 000000000000..53e4656ca44f --- /dev/null +++ b/owl-bot-staging/Profiler/v2/samples/V2/ExportServiceClient/list_profiles.php @@ -0,0 +1,78 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $exportServiceClient->listProfiles($request); + + /** @var Profile $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = ExportServiceClient::projectName('[PROJECT]'); + + list_profiles_sample($formattedParent); +} +// [END cloudprofiler_v2_generated_ExportService_ListProfiles_sync] diff --git a/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_offline_profile.php b/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_offline_profile.php new file mode 100644 index 000000000000..153364e2d38e --- /dev/null +++ b/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_offline_profile.php @@ -0,0 +1,64 @@ +createOfflineProfile($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END cloudprofiler_v2_generated_ProfilerService_CreateOfflineProfile_sync] diff --git a/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_profile.php b/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_profile.php new file mode 100644 index 000000000000..9405319b6060 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_profile.php @@ -0,0 +1,75 @@ +createProfile($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END cloudprofiler_v2_generated_ProfilerService_CreateProfile_sync] diff --git a/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/update_profile.php b/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/update_profile.php new file mode 100644 index 000000000000..957343f00a4a --- /dev/null +++ b/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/update_profile.php @@ -0,0 +1,65 @@ +updateProfile($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END cloudprofiler_v2_generated_ProfilerService_UpdateProfile_sync] diff --git a/owl-bot-staging/Profiler/v2/src/V2/Client/ExportServiceClient.php b/owl-bot-staging/Profiler/v2/src/V2/Client/ExportServiceClient.php new file mode 100644 index 000000000000..d57b72df683a --- /dev/null +++ b/owl-bot-staging/Profiler/v2/src/V2/Client/ExportServiceClient.php @@ -0,0 +1,239 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/export_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/export_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/export_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/export_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a project + * resource. + * + * @param string $project + * + * @return string The formatted project resource. + */ + public static function projectName(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - project: projects/{project} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'cloudprofiler.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists profiles which have been collected so far and for which the caller + * has permission to view. + * + * The async variant is {@see ExportServiceClient::listProfilesAsync()} . + * + * @example samples/V2/ExportServiceClient/list_profiles.php + * + * @param ListProfilesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProfiles(ListProfilesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProfiles', $request, $callOptions); + } +} diff --git a/owl-bot-staging/Profiler/v2/src/V2/Client/ProfilerServiceClient.php b/owl-bot-staging/Profiler/v2/src/V2/Client/ProfilerServiceClient.php new file mode 100644 index 000000000000..6a5889cb8f31 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/src/V2/Client/ProfilerServiceClient.php @@ -0,0 +1,348 @@ + self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/profiler_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/profiler_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/profiler_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/profiler_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a profile + * resource. + * + * @param string $project + * @param string $profile + * + * @return string The formatted profile resource. + */ + public static function profileName(string $project, string $profile): string + { + return self::getPathTemplate('profile')->render([ + 'project' => $project, + 'profile' => $profile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project + * resource. + * + * @param string $project + * + * @return string The formatted project resource. + */ + public static function projectName(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - profile: projects/{project}/profiles/{profile} + * - project: projects/{project} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'cloudprofiler.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * 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._ + * + * The async variant is {@see ProfilerServiceClient::createOfflineProfileAsync()} . + * + * @example samples/V2/ProfilerServiceClient/create_offline_profile.php + * + * @param CreateOfflineProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Profile + * + * @throws ApiException Thrown if the API call fails. + */ + public function createOfflineProfile(CreateOfflineProfileRequest $request, array $callOptions = []): Profile + { + return $this->startApiCall('CreateOfflineProfile', $request, $callOptions)->wait(); + } + + /** + * 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". + * + * + * The async variant is {@see ProfilerServiceClient::createProfileAsync()} . + * + * @example samples/V2/ProfilerServiceClient/create_profile.php + * + * @param CreateProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Profile + * + * @throws ApiException Thrown if the API call fails. + */ + public function createProfile(CreateProfileRequest $request, array $callOptions = []): Profile + { + return $this->startApiCall('CreateProfile', $request, $callOptions)->wait(); + } + + /** + * 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._ + * + * The async variant is {@see ProfilerServiceClient::updateProfileAsync()} . + * + * @example samples/V2/ProfilerServiceClient/update_profile.php + * + * @param UpdateProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return Profile + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProfile(UpdateProfileRequest $request, array $callOptions = []): Profile + { + return $this->startApiCall('UpdateProfile', $request, $callOptions)->wait(); + } +} diff --git a/owl-bot-staging/Profiler/v2/src/V2/ExportServiceClient.php b/owl-bot-staging/Profiler/v2/src/V2/ExportServiceClient.php new file mode 100644 index 000000000000..15bf48139a94 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/src/V2/ExportServiceClient.php @@ -0,0 +1,34 @@ +projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $exportServiceClient->listProfiles($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $exportServiceClient->listProfiles($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $exportServiceClient->close(); + * } + * ``` + * + * Many parameters require resource names to be formatted in a particular way. To + * assist with these names, this class includes a format method for each type of + * name, and additionally a parseName method to extract the individual identifiers + * contained within formatted names that are returned by the API. + * + * @deprecated Please use the new service client {@see \Google\Cloud\Profiler\V2\Client\ExportServiceClient}. + */ +class ExportServiceGapicClient +{ + use GapicClientTrait; + + /** The name of the service. */ + const SERVICE_NAME = 'google.devtools.cloudprofiler.v2.ExportService'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + const SERVICE_ADDRESS = 'cloudprofiler.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'cloudprofiler.UNIVERSE_DOMAIN'; + + /** The default port of the service. */ + const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.write', + ]; + + private static $projectNameTemplate; + + private static $pathTemplateMap; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/export_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/export_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/export_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/export_service_rest_client_config.php', + ], + ], + ]; + } + + private static function getProjectNameTemplate() + { + if (self::$projectNameTemplate == null) { + self::$projectNameTemplate = new PathTemplate('projects/{project}'); + } + + return self::$projectNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'project' => self::getProjectNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a project + * resource. + * + * @param string $project + * + * @return string The formatted project resource. + */ + public static function projectName($project) + { + return self::getProjectNameTemplate()->render([ + 'project' => $project, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - project: projects/{project} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'cloudprofiler.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** + * Lists profiles which have been collected so far and for which the caller + * has permission to view. + * + * Sample code: + * ``` + * $exportServiceClient = new ExportServiceClient(); + * try { + * $formattedParent = $exportServiceClient->projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $exportServiceClient->listProfiles($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $exportServiceClient->listProfiles($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $exportServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The parent, which owns this collection of profiles. + * Format: projects/{user_project_id} + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listProfiles($parent, array $optionalArgs = []) + { + $request = new ListProfilesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListProfiles', $optionalArgs, ListProfilesResponse::class, $request); + } +} diff --git a/owl-bot-staging/Profiler/v2/src/V2/Gapic/ProfilerServiceGapicClient.php b/owl-bot-staging/Profiler/v2/src/V2/Gapic/ProfilerServiceGapicClient.php new file mode 100644 index 000000000000..c1471e834265 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/src/V2/Gapic/ProfilerServiceGapicClient.php @@ -0,0 +1,473 @@ +createOfflineProfile(); + * } finally { + * $profilerServiceClient->close(); + * } + * ``` + * + * Many parameters require resource names to be formatted in a particular way. To + * assist with these names, this class includes a format method for each type of + * name, and additionally a parseName method to extract the individual identifiers + * contained within formatted names that are returned by the API. + * + * @deprecated Please use the new service client {@see \Google\Cloud\Profiler\V2\Client\ProfilerServiceClient}. + */ +class ProfilerServiceGapicClient +{ + use GapicClientTrait; + + /** The name of the service. */ + const SERVICE_NAME = 'google.devtools.cloudprofiler.v2.ProfilerService'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + const SERVICE_ADDRESS = 'cloudprofiler.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'cloudprofiler.UNIVERSE_DOMAIN'; + + /** The default port of the service. */ + const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.write', + ]; + + private static $profileNameTemplate; + + private static $projectNameTemplate; + + private static $pathTemplateMap; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/profiler_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/profiler_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/profiler_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/profiler_service_rest_client_config.php', + ], + ], + ]; + } + + private static function getProfileNameTemplate() + { + if (self::$profileNameTemplate == null) { + self::$profileNameTemplate = new PathTemplate('projects/{project}/profiles/{profile}'); + } + + return self::$profileNameTemplate; + } + + private static function getProjectNameTemplate() + { + if (self::$projectNameTemplate == null) { + self::$projectNameTemplate = new PathTemplate('projects/{project}'); + } + + return self::$projectNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'profile' => self::getProfileNameTemplate(), + 'project' => self::getProjectNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a profile + * resource. + * + * @param string $project + * @param string $profile + * + * @return string The formatted profile resource. + */ + public static function profileName($project, $profile) + { + return self::getProfileNameTemplate()->render([ + 'project' => $project, + 'profile' => $profile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project + * resource. + * + * @param string $project + * + * @return string The formatted project resource. + */ + public static function projectName($project) + { + return self::getProjectNameTemplate()->render([ + 'project' => $project, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - profile: projects/{project}/profiles/{profile} + * - project: projects/{project} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'cloudprofiler.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** + * 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._ + * + * Sample code: + * ``` + * $profilerServiceClient = new ProfilerServiceClient(); + * try { + * $response = $profilerServiceClient->createOfflineProfile(); + * } finally { + * $profilerServiceClient->close(); + * } + * ``` + * + * @param array $optionalArgs { + * Optional. + * + * @type string $parent + * Parent project to create the profile in. + * @type Profile $profile + * Contents of the profile to create. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Profiler\V2\Profile + * + * @throws ApiException if the remote call fails + */ + public function createOfflineProfile(array $optionalArgs = []) + { + $request = new CreateOfflineProfileRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['parent'])) { + $request->setParent($optionalArgs['parent']); + $requestParamHeaders['parent'] = $optionalArgs['parent']; + } + + if (isset($optionalArgs['profile'])) { + $request->setProfile($optionalArgs['profile']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateOfflineProfile', Profile::class, $optionalArgs, $request)->wait(); + } + + /** + * 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". + * + * + * Sample code: + * ``` + * $profilerServiceClient = new ProfilerServiceClient(); + * try { + * $response = $profilerServiceClient->createProfile(); + * } finally { + * $profilerServiceClient->close(); + * } + * ``` + * + * @param array $optionalArgs { + * Optional. + * + * @type string $parent + * Parent project to create the profile in. + * @type Deployment $deployment + * Deployment details. + * @type int[] $profileType + * One or more profile types that the agent is capable of providing. + * For allowed values, use constants defined on {@see \Google\Cloud\Profiler\V2\ProfileType} + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Profiler\V2\Profile + * + * @throws ApiException if the remote call fails + */ + public function createProfile(array $optionalArgs = []) + { + $request = new CreateProfileRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['parent'])) { + $request->setParent($optionalArgs['parent']); + $requestParamHeaders['parent'] = $optionalArgs['parent']; + } + + if (isset($optionalArgs['deployment'])) { + $request->setDeployment($optionalArgs['deployment']); + } + + if (isset($optionalArgs['profileType'])) { + $request->setProfileType($optionalArgs['profileType']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateProfile', Profile::class, $optionalArgs, $request)->wait(); + } + + /** + * 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._ + * + * Sample code: + * ``` + * $profilerServiceClient = new ProfilerServiceClient(); + * try { + * $response = $profilerServiceClient->updateProfile(); + * } finally { + * $profilerServiceClient->close(); + * } + * ``` + * + * @param array $optionalArgs { + * Optional. + * + * @type Profile $profile + * Profile to update. + * @type FieldMask $updateMask + * Field mask used to specify the fields to be overwritten. Currently only + * profile_bytes and labels fields are supported by UpdateProfile, so only + * those fields can be specified in the mask. When no mask is provided, all + * fields are overwritten. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Profiler\V2\Profile + * + * @throws ApiException if the remote call fails + */ + public function updateProfile(array $optionalArgs = []) + { + $request = new UpdateProfileRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['profile'])) { + $request->setProfile($optionalArgs['profile']); + } + + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateProfile', Profile::class, $optionalArgs, $request)->wait(); + } +} diff --git a/owl-bot-staging/Profiler/v2/src/V2/ProfilerServiceClient.php b/owl-bot-staging/Profiler/v2/src/V2/ProfilerServiceClient.php new file mode 100644 index 000000000000..6aaa9bf26951 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/src/V2/ProfilerServiceClient.php @@ -0,0 +1,34 @@ + [ + 'google.devtools.cloudprofiler.v2.ExportService' => [ + 'ListProfiles' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getProfiles', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Profiler\V2\ListProfilesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'templateMap' => [ + 'project' => 'projects/{project}', + ], + ], + ], +]; diff --git a/owl-bot-staging/Profiler/v2/src/V2/resources/export_service_rest_client_config.php b/owl-bot-staging/Profiler/v2/src/V2/resources/export_service_rest_client_config.php new file mode 100644 index 000000000000..1d0ddfa982ce --- /dev/null +++ b/owl-bot-staging/Profiler/v2/src/V2/resources/export_service_rest_client_config.php @@ -0,0 +1,20 @@ + [ + 'google.devtools.cloudprofiler.v2.ExportService' => [ + 'ListProfiles' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=projects/*}/profiles', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_client_config.json b/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_client_config.json new file mode 100644 index 000000000000..3d4414a2036d --- /dev/null +++ b/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_client_config.json @@ -0,0 +1,69 @@ +{ + "interfaces": { + "google.devtools.cloudprofiler.v2.ProfilerService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ], + "no_retry_1_codes": [], + "no_retry_2_codes": [] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + }, + "no_retry_1_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 3610000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 3610000, + "total_timeout_millis": 3610000 + }, + "no_retry_2_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + } + }, + "methods": { + "CreateOfflineProfile": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_2_codes", + "retry_params_name": "no_retry_2_params" + }, + "CreateProfile": { + "timeout_millis": 3610000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "UpdateProfile": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_2_codes", + "retry_params_name": "no_retry_2_params" + } + } + } + } +} diff --git a/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_descriptor_config.php b/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_descriptor_config.php new file mode 100644 index 000000000000..6c16c0b3d285 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_descriptor_config.php @@ -0,0 +1,49 @@ + [ + 'google.devtools.cloudprofiler.v2.ProfilerService' => [ + 'CreateOfflineProfile' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Profiler\V2\Profile', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'CreateProfile' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Profiler\V2\Profile', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateProfile' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Profiler\V2\Profile', + 'headerParams' => [ + [ + 'keyName' => 'profile.name', + 'fieldAccessors' => [ + 'getProfile', + 'getName', + ], + ], + ], + ], + 'templateMap' => [ + 'profile' => 'projects/{project}/profiles/{profile}', + 'project' => 'projects/{project}', + ], + ], + ], +]; diff --git a/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_rest_client_config.php b/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_rest_client_config.php new file mode 100644 index 000000000000..29d974a28083 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_rest_client_config.php @@ -0,0 +1,46 @@ + [ + 'google.devtools.cloudprofiler.v2.ProfilerService' => [ + 'CreateOfflineProfile' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=projects/*}/profiles:createOffline', + 'body' => 'profile', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'CreateProfile' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=projects/*}/profiles', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateProfile' => [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{profile.name=projects/*/profiles/*}', + 'body' => 'profile', + 'placeholders' => [ + 'profile.name' => [ + 'getters' => [ + 'getProfile', + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ExportServiceClientTest.php b/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ExportServiceClientTest.php new file mode 100644 index 000000000000..8545dd2bd7a0 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ExportServiceClientTest.php @@ -0,0 +1,176 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return ExportServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new ExportServiceClient($options); + } + + /** @test */ + public function listProfilesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $skippedProfiles = 852593689; + $profilesElement = new Profile(); + $profiles = [ + $profilesElement, + ]; + $expectedResponse = new ListProfilesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setSkippedProfiles($skippedProfiles); + $expectedResponse->setProfiles($profiles); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListProfilesRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listProfiles($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getProfiles()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ExportService/ListProfiles', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listProfilesExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListProfilesRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listProfiles($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listProfilesAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $skippedProfiles = 852593689; + $profilesElement = new Profile(); + $profiles = [ + $profilesElement, + ]; + $expectedResponse = new ListProfilesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setSkippedProfiles($skippedProfiles); + $expectedResponse->setProfiles($profiles); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListProfilesRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listProfilesAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getProfiles()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ExportService/ListProfiles', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ProfilerServiceClientTest.php b/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ProfilerServiceClientTest.php new file mode 100644 index 000000000000..6dbf9f964f9b --- /dev/null +++ b/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ProfilerServiceClientTest.php @@ -0,0 +1,264 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return ProfilerServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new ProfilerServiceClient($options); + } + + /** @test */ + public function createOfflineProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $profileBytes = '85'; + $expectedResponse = new Profile(); + $expectedResponse->setName($name); + $expectedResponse->setProfileBytes($profileBytes); + $transport->addResponse($expectedResponse); + $request = new CreateOfflineProfileRequest(); + $response = $gapicClient->createOfflineProfile($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateOfflineProfile', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createOfflineProfileExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + $request = new CreateOfflineProfileRequest(); + try { + $gapicClient->createOfflineProfile($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $profileBytes = '85'; + $expectedResponse = new Profile(); + $expectedResponse->setName($name); + $expectedResponse->setProfileBytes($profileBytes); + $transport->addResponse($expectedResponse); + $request = new CreateProfileRequest(); + $response = $gapicClient->createProfile($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateProfile', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createProfileExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + $request = new CreateProfileRequest(); + try { + $gapicClient->createProfile($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $profileBytes = '85'; + $expectedResponse = new Profile(); + $expectedResponse->setName($name); + $expectedResponse->setProfileBytes($profileBytes); + $transport->addResponse($expectedResponse); + $request = new UpdateProfileRequest(); + $response = $gapicClient->updateProfile($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/UpdateProfile', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateProfileExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + $request = new UpdateProfileRequest(); + try { + $gapicClient->updateProfile($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createOfflineProfileAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $profileBytes = '85'; + $expectedResponse = new Profile(); + $expectedResponse->setName($name); + $expectedResponse->setProfileBytes($profileBytes); + $transport->addResponse($expectedResponse); + $request = new CreateOfflineProfileRequest(); + $response = $gapicClient->createOfflineProfileAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateOfflineProfile', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/owl-bot-staging/Profiler/v2/tests/Unit/V2/ExportServiceClientTest.php b/owl-bot-staging/Profiler/v2/tests/Unit/V2/ExportServiceClientTest.php new file mode 100644 index 000000000000..5bceafbcde84 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/tests/Unit/V2/ExportServiceClientTest.php @@ -0,0 +1,132 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return ExportServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new ExportServiceClient($options); + } + + /** @test */ + public function listProfilesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $skippedProfiles = 852593689; + $profilesElement = new Profile(); + $profiles = [ + $profilesElement, + ]; + $expectedResponse = new ListProfilesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setSkippedProfiles($skippedProfiles); + $expectedResponse->setProfiles($profiles); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $response = $gapicClient->listProfiles($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getProfiles()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ExportService/ListProfiles', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listProfilesExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + try { + $gapicClient->listProfiles($formattedParent); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/owl-bot-staging/Profiler/v2/tests/Unit/V2/ProfilerServiceClientTest.php b/owl-bot-staging/Profiler/v2/tests/Unit/V2/ProfilerServiceClientTest.php new file mode 100644 index 000000000000..737e80a730b5 --- /dev/null +++ b/owl-bot-staging/Profiler/v2/tests/Unit/V2/ProfilerServiceClientTest.php @@ -0,0 +1,229 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return ProfilerServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new ProfilerServiceClient($options); + } + + /** @test */ + public function createOfflineProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $profileBytes = '85'; + $expectedResponse = new Profile(); + $expectedResponse->setName($name); + $expectedResponse->setProfileBytes($profileBytes); + $transport->addResponse($expectedResponse); + $response = $gapicClient->createOfflineProfile(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateOfflineProfile', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createOfflineProfileExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + try { + $gapicClient->createOfflineProfile(); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $profileBytes = '85'; + $expectedResponse = new Profile(); + $expectedResponse->setName($name); + $expectedResponse->setProfileBytes($profileBytes); + $transport->addResponse($expectedResponse); + $response = $gapicClient->createProfile(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateProfile', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createProfileExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + try { + $gapicClient->createProfile(); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateProfileTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $profileBytes = '85'; + $expectedResponse = new Profile(); + $expectedResponse->setName($name); + $expectedResponse->setProfileBytes($profileBytes); + $transport->addResponse($expectedResponse); + $response = $gapicClient->updateProfile(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/UpdateProfile', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateProfileExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + try { + $gapicClient->updateProfile(); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } +} From b52bef20146414bb47dc2da6e3874da97a155b37 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Sat, 24 Feb 2024 04:09:37 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- Profiler/metadata/V2/Profiler.php | Bin 4034 -> 4189 bytes .../create_offline_profile.php | 11 +- .../ProfilerServiceClient/create_profile.php | 5 + .../ProfilerServiceClient/update_profile.php | 5 + .../src/V2/Client/ProfilerServiceClient.php | 26 +- .../V2/Gapic/ProfilerServiceGapicClient.php | 26 +- Profiler/src/V2/ListProfilesRequest.php | 23 +- Profiler/src/V2/Profile.php | 48 ++ .../Devtools/Cloudprofiler/V2/Profiler.php | Bin 4189 -> 0 bytes .../V2/CreateOfflineProfileRequest.php | 127 ----- .../Profiler/V2/CreateProfileRequest.php | 148 ------ .../Google/Cloud/Profiler/V2/Deployment.php | 199 -------- .../Cloud/Profiler/V2/ListProfilesRequest.php | 171 ------- .../Profiler/V2/ListProfilesResponse.php | 152 ------ .../src/Google/Cloud/Profiler/V2/Profile.php | 345 ------------- .../Google/Cloud/Profiler/V2/ProfileType.php | 104 ---- .../Profiler/V2/UpdateProfileRequest.php | 151 ------ .../V2/ExportServiceClient/list_profiles.php | 78 --- .../create_offline_profile.php | 64 --- .../ProfilerServiceClient/create_profile.php | 75 --- .../ProfilerServiceClient/update_profile.php | 65 --- .../v2/src/V2/Client/ExportServiceClient.php | 239 --------- .../src/V2/Client/ProfilerServiceClient.php | 348 ------------- .../v2/src/V2/ExportServiceClient.php | 34 -- .../src/V2/Gapic/ExportServiceGapicClient.php | 333 ------------ .../V2/Gapic/ProfilerServiceGapicClient.php | 473 ------------------ .../v2/src/V2/ProfilerServiceClient.php | 34 -- .../Profiler/v2/src/V2/gapic_metadata.json | 47 -- .../export_service_client_config.json | 39 -- .../export_service_descriptor_config.php | 31 -- .../export_service_rest_client_config.php | 20 - .../profiler_service_client_config.json | 69 --- .../profiler_service_descriptor_config.php | 49 -- .../profiler_service_rest_client_config.php | 46 -- .../V2/Client/ExportServiceClientTest.php | 176 ------- .../V2/Client/ProfilerServiceClientTest.php | 264 ---------- .../tests/Unit/V2/ExportServiceClientTest.php | 132 ----- .../Unit/V2/ProfilerServiceClientTest.php | 229 --------- 38 files changed, 125 insertions(+), 4261 deletions(-) delete mode 100644 owl-bot-staging/Profiler/v2/proto/src/GPBMetadata/Google/Devtools/Cloudprofiler/V2/Profiler.php delete mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateOfflineProfileRequest.php delete mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateProfileRequest.php delete mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Deployment.php delete mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesRequest.php delete mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesResponse.php delete mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Profile.php delete mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ProfileType.php delete mode 100644 owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/UpdateProfileRequest.php delete mode 100644 owl-bot-staging/Profiler/v2/samples/V2/ExportServiceClient/list_profiles.php delete mode 100644 owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_offline_profile.php delete mode 100644 owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_profile.php delete mode 100644 owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/update_profile.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/Client/ExportServiceClient.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/Client/ProfilerServiceClient.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/ExportServiceClient.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/Gapic/ExportServiceGapicClient.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/Gapic/ProfilerServiceGapicClient.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/ProfilerServiceClient.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/gapic_metadata.json delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/export_service_client_config.json delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/export_service_descriptor_config.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/export_service_rest_client_config.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_client_config.json delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_descriptor_config.php delete mode 100644 owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_rest_client_config.php delete mode 100644 owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ExportServiceClientTest.php delete mode 100644 owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ProfilerServiceClientTest.php delete mode 100644 owl-bot-staging/Profiler/v2/tests/Unit/V2/ExportServiceClientTest.php delete mode 100644 owl-bot-staging/Profiler/v2/tests/Unit/V2/ProfilerServiceClientTest.php diff --git a/Profiler/metadata/V2/Profiler.php b/Profiler/metadata/V2/Profiler.php index c93569743ebf6a196fc54e1170961c75db852a37..2ccee3ee6a7c23632bd0a812ccfc4687680aa274 100644 GIT binary patch delta 191 zcmX>ke^+6HAoJu|OtPFInYpROC5gEOlkYQ%O%`OV!Z delta 66 zcmV-I0KNa+Ai^K85d)J=11|!&7?XYj>a&Ri2Lb`Pvylcl0ki)H!vz!R0tyX9cyMoW YbW>$=c4=c}5~q{Z4SxYBvtADW0Tp5w>Hq)$ diff --git a/Profiler/samples/V2/ProfilerServiceClient/create_offline_profile.php b/Profiler/samples/V2/ProfilerServiceClient/create_offline_profile.php index a907d593028f..651eb52888e6 100644 --- a/Profiler/samples/V2/ProfilerServiceClient/create_offline_profile.php +++ b/Profiler/samples/V2/ProfilerServiceClient/create_offline_profile.php @@ -29,9 +29,14 @@ use Google\Cloud\Profiler\V2\Profile; /** - * 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. + * 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._ * * This sample has been automatically generated and should be regarded as a code * template only. It will require modifications to work: diff --git a/Profiler/samples/V2/ProfilerServiceClient/create_profile.php b/Profiler/samples/V2/ProfilerServiceClient/create_profile.php index b2ee70258f9b..ed42bdf474e0 100644 --- a/Profiler/samples/V2/ProfilerServiceClient/create_profile.php +++ b/Profiler/samples/V2/ProfilerServiceClient/create_profile.php @@ -31,6 +31,11 @@ /** * 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. diff --git a/Profiler/samples/V2/ProfilerServiceClient/update_profile.php b/Profiler/samples/V2/ProfilerServiceClient/update_profile.php index acc3317798f7..fbaa154ed454 100644 --- a/Profiler/samples/V2/ProfilerServiceClient/update_profile.php +++ b/Profiler/samples/V2/ProfilerServiceClient/update_profile.php @@ -34,6 +34,11 @@ * 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._ + * * This sample has been automatically generated and should be regarded as a code * template only. It will require modifications to work: * - It may require correct/in-range values for request initialization. diff --git a/Profiler/src/V2/Client/ProfilerServiceClient.php b/Profiler/src/V2/Client/ProfilerServiceClient.php index d95fb6c02521..953afbb92c89 100644 --- a/Profiler/src/V2/Client/ProfilerServiceClient.php +++ b/Profiler/src/V2/Client/ProfilerServiceClient.php @@ -42,9 +42,8 @@ * Service Description: Manage the collection of continuous profiling data provided by profiling * agents running in the cloud or by an offline provider of profiling data. * - * General guidelines: - * * Profiles for a single deployment must be created in ascending time order. - * * Profiles can be created in either online or offline mode, see below. + * __The APIs listed in this service are intended for use within our profiler + * agents only.__ * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. @@ -237,9 +236,14 @@ public function __call($method, $args) } /** - * 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. + * 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._ * * The async variant is {@see ProfilerServiceClient::createOfflineProfileAsync()} . * @@ -267,6 +271,11 @@ public function createOfflineProfile(CreateOfflineProfileRequest $request, array /** * 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. @@ -309,6 +318,11 @@ public function createProfile(CreateProfileRequest $request, array $callOptions * 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._ + * * The async variant is {@see ProfilerServiceClient::updateProfileAsync()} . * * @example samples/V2/ProfilerServiceClient/update_profile.php diff --git a/Profiler/src/V2/Gapic/ProfilerServiceGapicClient.php b/Profiler/src/V2/Gapic/ProfilerServiceGapicClient.php index 2a98eb092083..5d4a009bda68 100644 --- a/Profiler/src/V2/Gapic/ProfilerServiceGapicClient.php +++ b/Profiler/src/V2/Gapic/ProfilerServiceGapicClient.php @@ -44,9 +44,8 @@ * Service Description: Manage the collection of continuous profiling data provided by profiling * agents running in the cloud or by an offline provider of profiling data. * - * General guidelines: - * * Profiles for a single deployment must be created in ascending time order. - * * Profiles can be created in either online or offline mode, see below. + * __The APIs listed in this service are intended for use within our profiler + * agents only.__ * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: @@ -287,9 +286,14 @@ public function __construct(array $options = []) } /** - * 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. + * 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._ * * Sample code: * ``` @@ -339,6 +343,11 @@ public function createOfflineProfile(array $optionalArgs = []) /** * 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. @@ -410,6 +419,11 @@ public function createProfile(array $optionalArgs = []) * 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._ + * * Sample code: * ``` * $profilerServiceClient = new ProfilerServiceClient(); diff --git a/Profiler/src/V2/ListProfilesRequest.php b/Profiler/src/V2/ListProfilesRequest.php index 051d5de6efe6..83b04150dcac 100644 --- a/Profiler/src/V2/ListProfilesRequest.php +++ b/Profiler/src/V2/ListProfilesRequest.php @@ -26,7 +26,7 @@ class ListProfilesRequest extends \Google\Protobuf\Internal\Message /** * The maximum number of items to return. * Default page_size is 1000. - * Max limit is 10000. + * Max limit is 1000. * * Generated from protobuf field int32 page_size = 2; */ @@ -40,6 +40,21 @@ class ListProfilesRequest extends \Google\Protobuf\Internal\Message */ private $page_token = ''; + /** + * @param string $parent Required. The parent, which owns this collection of profiles. + * Format: projects/{user_project_id} + * Please see {@see ExportServiceClient::projectName()} for help formatting this field. + * + * @return \Google\Cloud\Profiler\V2\ListProfilesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * @@ -52,7 +67,7 @@ class ListProfilesRequest extends \Google\Protobuf\Internal\Message * @type int $page_size * The maximum number of items to return. * Default page_size is 1000. - * Max limit is 10000. + * Max limit is 1000. * @type string $page_token * The token to continue pagination and get profiles from a particular page. * When paginating, all other parameters provided to `ListProfiles` must match @@ -95,7 +110,7 @@ public function setParent($var) /** * The maximum number of items to return. * Default page_size is 1000. - * Max limit is 10000. + * Max limit is 1000. * * Generated from protobuf field int32 page_size = 2; * @return int @@ -108,7 +123,7 @@ public function getPageSize() /** * The maximum number of items to return. * Default page_size is 1000. - * Max limit is 10000. + * Max limit is 1000. * * Generated from protobuf field int32 page_size = 2; * @param int $var diff --git a/Profiler/src/V2/Profile.php b/Profiler/src/V2/Profile.php index 38396eff77fd..bd2298dadf24 100644 --- a/Profiler/src/V2/Profile.php +++ b/Profiler/src/V2/Profile.php @@ -61,6 +61,13 @@ class Profile extends \Google\Protobuf\Internal\Message * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = INPUT_ONLY]; */ private $labels; + /** + * Output only. Start time for the profile. + * This output is only present in response from the ListProfiles method. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $start_time = null; /** * Constructor. @@ -90,6 +97,9 @@ class Profile extends \Google\Protobuf\Internal\Message * 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. + * @type \Google\Protobuf\Timestamp $start_time + * Output only. Start time for the profile. + * This output is only present in response from the ListProfiles method. * } */ public function __construct($data = NULL) { @@ -293,5 +303,43 @@ public function setLabels($var) return $this; } + /** + * Output only. Start time for the profile. + * This output is only present in response from the ListProfiles method. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * Output only. Start time for the profile. + * This output is only present in response from the ListProfiles method. + * + * Generated from protobuf field .google.protobuf.Timestamp start_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->start_time = $var; + + return $this; + } + } diff --git a/owl-bot-staging/Profiler/v2/proto/src/GPBMetadata/Google/Devtools/Cloudprofiler/V2/Profiler.php b/owl-bot-staging/Profiler/v2/proto/src/GPBMetadata/Google/Devtools/Cloudprofiler/V2/Profiler.php deleted file mode 100644 index 2ccee3ee6a7c23632bd0a812ccfc4687680aa274..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4189 zcmdT{&2!sC6i0SGnst-9TW0FI9S|m+x@jVVGcZLVfMPpoAdNkVTL#868d+W^BC;f; zb<)tufsf(9l>-M3oMDC;{)gUrESz$o2Tnb3;K+gDt+Z0)q``J>F?y|=&jdtbY6 zzw2x}=v8rrSj5#RX^G8!k!};wacyerwkbBd?KW{m-R?MsNnA-3%T;l`S{Ezj)%q)- z>e*daC$hL@+gm0nw8$>CZPP30rrm9UnKn}^>=p~*TJmipWN97ZIhszymDLbaAg zwZ@8Xrcvf*8l||I#{J>~Lb|DWo>=3i(L*G{pVMuchAw(kqwq6rc&cF;)X+@hGw^Cr zY-^@RK>4I>yKCvxuq}}(R4tw4Z;F9UCOhqbH=rK^gJY=;q%>A7N?c1b0jj6FhC^+) z2BNaOMQB7P`;x!Ok7eeJwwMnv%JK=2iz0QqB!0Rmx`cLJYr)6O3>-wO#&c*>9HXIF zmd#kOEl-w@d^$35nqtW`h((9fSvH8-S|Z!pu3@{wscsOSIs=1@xG#4hS;4`<4~$fO zz;`uo=M1`a12UFs9q0MFeyYs9WAMaKTCFG#mZ1ppQRG-0Z=mn4pu&(vgL#!nVU$lfTg70pR;#@kjf? z0Ue>ia=#1c#ga>)2SKP<&)6WJc7bjD9vX8r7yQVKh(dm1>9xO=IdseS zJ4D&hENu&VQ-BgY_ax|71u*mp(U}F*B93YAcbF9ctfY#wT=;Y*rE;W$OXxfRXQ))V z?~qJFOy;MGbNy{_U+SQg`(8j-0}re1wrN4b=1OqLbG!y6*GiWD7i!S z1IF%m@kZaGByJ)(%=bS7$Rwwv6IL)fhD?H?@gYX6rd}2}uxgQ0D zVugkg;?kYm)(nsG5O`sSDn%VC zDBSs{N@D0HbrDTC(8N>^?km2dqnMGwK2dvzSQ(b66S=RUOnWhS4h(vN7tlFij*;pC zZ!DRHsME{nf<+!sHFlgIbeutHZ^v*P(o!Sq49MurR{~0LB3O6B*HEUmQC(hLtElyl zY8Ca~`evOI1d|&2^ z`M{T;E+jThVj($dM>7YJ7ulbM$I7+;>Tpk#Z-i}19ZxP4_V)I8z@kfs)}`CQ+h@)( zHQKh_&TK#Njtwsl+cm7MAw;D;*Px{MR{~8|9yqp3!}R|}K1}K_d zwV)H_UO!a$jm?ij4)-mI{~PH`zX>n}?M~lfU78Gg6Z}%UCVaf&r&g%QZmC=Lv8OVm z610$>6m*&k$Nv8*ky-Iy%2J6vki%<%E8Qgoogle.devtools.cloudprofiler.v2.CreateOfflineProfileRequest - */ -class CreateOfflineProfileRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Parent project to create the profile in. - * - * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { - */ - protected $parent = ''; - /** - * Contents of the profile to create. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 2; - */ - protected $profile = null; - - /** - * @param string $parent Parent project to create the profile in. - * @param \Google\Cloud\Profiler\V2\Profile $profile Contents of the profile to create. - * - * @return \Google\Cloud\Profiler\V2\CreateOfflineProfileRequest - * - * @experimental - */ - public static function build(string $parent, \Google\Cloud\Profiler\V2\Profile $profile): self - { - return (new self()) - ->setParent($parent) - ->setProfile($profile); - } - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $parent - * Parent project to create the profile in. - * @type \Google\Cloud\Profiler\V2\Profile $profile - * Contents of the profile to create. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); - parent::__construct($data); - } - - /** - * Parent project to create the profile in. - * - * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { - * @return string - */ - public function getParent() - { - return $this->parent; - } - - /** - * Parent project to create the profile in. - * - * Generated from protobuf field string parent = 1 [(.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setParent($var) - { - GPBUtil::checkString($var, True); - $this->parent = $var; - - return $this; - } - - /** - * Contents of the profile to create. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 2; - * @return \Google\Cloud\Profiler\V2\Profile|null - */ - public function getProfile() - { - return $this->profile; - } - - public function hasProfile() - { - return isset($this->profile); - } - - public function clearProfile() - { - unset($this->profile); - } - - /** - * Contents of the profile to create. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 2; - * @param \Google\Cloud\Profiler\V2\Profile $var - * @return $this - */ - public function setProfile($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Profiler\V2\Profile::class); - $this->profile = $var; - - return $this; - } - -} - diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateProfileRequest.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateProfileRequest.php deleted file mode 100644 index ef1a7c790639..000000000000 --- a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/CreateProfileRequest.php +++ /dev/null @@ -1,148 +0,0 @@ -google.devtools.cloudprofiler.v2.CreateProfileRequest - */ -class CreateProfileRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Parent project to create the profile in. - * - * Generated from protobuf field string parent = 4 [(.google.api.resource_reference) = { - */ - protected $parent = ''; - /** - * Deployment details. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 1; - */ - protected $deployment = null; - /** - * One or more profile types that the agent is capable of providing. - * - * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; - */ - private $profile_type; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $parent - * Parent project to create the profile in. - * @type \Google\Cloud\Profiler\V2\Deployment $deployment - * Deployment details. - * @type array|\Google\Protobuf\Internal\RepeatedField $profile_type - * One or more profile types that the agent is capable of providing. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); - parent::__construct($data); - } - - /** - * Parent project to create the profile in. - * - * Generated from protobuf field string parent = 4 [(.google.api.resource_reference) = { - * @return string - */ - public function getParent() - { - return $this->parent; - } - - /** - * Parent project to create the profile in. - * - * Generated from protobuf field string parent = 4 [(.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setParent($var) - { - GPBUtil::checkString($var, True); - $this->parent = $var; - - return $this; - } - - /** - * Deployment details. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 1; - * @return \Google\Cloud\Profiler\V2\Deployment|null - */ - public function getDeployment() - { - return $this->deployment; - } - - public function hasDeployment() - { - return isset($this->deployment); - } - - public function clearDeployment() - { - unset($this->deployment); - } - - /** - * Deployment details. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 1; - * @param \Google\Cloud\Profiler\V2\Deployment $var - * @return $this - */ - public function setDeployment($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Profiler\V2\Deployment::class); - $this->deployment = $var; - - return $this; - } - - /** - * One or more profile types that the agent is capable of providing. - * - * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getProfileType() - { - return $this->profile_type; - } - - /** - * One or more profile types that the agent is capable of providing. - * - * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; - * @param array|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setProfileType($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Profiler\V2\ProfileType::class); - $this->profile_type = $arr; - - return $this; - } - -} - diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Deployment.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Deployment.php deleted file mode 100644 index 4ee6e5aaebc1..000000000000 --- a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Deployment.php +++ /dev/null @@ -1,199 +0,0 @@ -google.devtools.cloudprofiler.v2.Deployment - */ -class Deployment extends \Google\Protobuf\Internal\Message -{ - /** - * Project ID is the ID of a cloud project. - * Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`. - * - * Generated from protobuf field string project_id = 1; - */ - protected $project_id = ''; - /** - * 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])?$`. - * - * Generated from protobuf field string target = 2; - */ - protected $target = ''; - /** - * 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". - * - * Generated from protobuf field map labels = 3; - */ - private $labels; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $project_id - * Project ID is the ID of a cloud project. - * Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`. - * @type string $target - * 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])?$`. - * @type array|\Google\Protobuf\Internal\MapField $labels - * 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". - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); - parent::__construct($data); - } - - /** - * Project ID is the ID of a cloud project. - * Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`. - * - * Generated from protobuf field string project_id = 1; - * @return string - */ - public function getProjectId() - { - return $this->project_id; - } - - /** - * Project ID is the ID of a cloud project. - * Validation regex: `^[a-z][-a-z0-9:.]{4,61}[a-z0-9]$`. - * - * Generated from protobuf field string project_id = 1; - * @param string $var - * @return $this - */ - public function setProjectId($var) - { - GPBUtil::checkString($var, True); - $this->project_id = $var; - - return $this; - } - - /** - * 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])?$`. - * - * Generated from protobuf field string target = 2; - * @return string - */ - public function getTarget() - { - return $this->target; - } - - /** - * 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])?$`. - * - * Generated from protobuf field string target = 2; - * @param string $var - * @return $this - */ - public function setTarget($var) - { - GPBUtil::checkString($var, True); - $this->target = $var; - - return $this; - } - - /** - * 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". - * - * Generated from protobuf field map labels = 3; - * @return \Google\Protobuf\Internal\MapField - */ - public function getLabels() - { - return $this->labels; - } - - /** - * 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". - * - * Generated from protobuf field map labels = 3; - * @param array|\Google\Protobuf\Internal\MapField $var - * @return $this - */ - public function setLabels($var) - { - $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); - $this->labels = $arr; - - return $this; - } - -} - diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesRequest.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesRequest.php deleted file mode 100644 index ff53a3c48f13..000000000000 --- a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesRequest.php +++ /dev/null @@ -1,171 +0,0 @@ -google.devtools.cloudprofiler.v2.ListProfilesRequest - */ -class ListProfilesRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Required. The parent, which owns this collection of profiles. - * Format: projects/{user_project_id} - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - */ - protected $parent = ''; - /** - * The maximum number of items to return. - * Default page_size is 1000. - * Max limit is 1000. - * - * Generated from protobuf field int32 page_size = 2; - */ - protected $page_size = 0; - /** - * 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. - * - * Generated from protobuf field string page_token = 3; - */ - protected $page_token = ''; - - /** - * @param string $parent Required. The parent, which owns this collection of profiles. - * Format: projects/{user_project_id} - * Please see {@see ExportServiceClient::projectName()} for help formatting this field. - * - * @return \Google\Cloud\Profiler\V2\ListProfilesRequest - * - * @experimental - */ - public static function build(string $parent): self - { - return (new self()) - ->setParent($parent); - } - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $parent - * Required. The parent, which owns this collection of profiles. - * Format: projects/{user_project_id} - * @type int $page_size - * The maximum number of items to return. - * Default page_size is 1000. - * Max limit is 1000. - * @type string $page_token - * 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. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); - parent::__construct($data); - } - - /** - * Required. The parent, which owns this collection of profiles. - * Format: projects/{user_project_id} - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @return string - */ - public function getParent() - { - return $this->parent; - } - - /** - * Required. The parent, which owns this collection of profiles. - * Format: projects/{user_project_id} - * - * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { - * @param string $var - * @return $this - */ - public function setParent($var) - { - GPBUtil::checkString($var, True); - $this->parent = $var; - - return $this; - } - - /** - * The maximum number of items to return. - * Default page_size is 1000. - * Max limit is 1000. - * - * Generated from protobuf field int32 page_size = 2; - * @return int - */ - public function getPageSize() - { - return $this->page_size; - } - - /** - * The maximum number of items to return. - * Default page_size is 1000. - * Max limit is 1000. - * - * Generated from protobuf field int32 page_size = 2; - * @param int $var - * @return $this - */ - public function setPageSize($var) - { - GPBUtil::checkInt32($var); - $this->page_size = $var; - - return $this; - } - - /** - * 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. - * - * Generated from protobuf field string page_token = 3; - * @return string - */ - public function getPageToken() - { - return $this->page_token; - } - - /** - * 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. - * - * Generated from protobuf field string page_token = 3; - * @param string $var - * @return $this - */ - public function setPageToken($var) - { - GPBUtil::checkString($var, True); - $this->page_token = $var; - - return $this; - } - -} - diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesResponse.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesResponse.php deleted file mode 100644 index a52a9ccd27a9..000000000000 --- a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ListProfilesResponse.php +++ /dev/null @@ -1,152 +0,0 @@ -google.devtools.cloudprofiler.v2.ListProfilesResponse - */ -class ListProfilesResponse extends \Google\Protobuf\Internal\Message -{ - /** - * List of profiles fetched. - * - * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; - */ - private $profiles; - /** - * Token to receive the next page of results. - * This field maybe empty if there are no more profiles to fetch. - * - * Generated from protobuf field string next_page_token = 2; - */ - protected $next_page_token = ''; - /** - * 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. - * - * Generated from protobuf field int32 skipped_profiles = 3; - */ - protected $skipped_profiles = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type array<\Google\Cloud\Profiler\V2\Profile>|\Google\Protobuf\Internal\RepeatedField $profiles - * List of profiles fetched. - * @type string $next_page_token - * Token to receive the next page of results. - * This field maybe empty if there are no more profiles to fetch. - * @type int $skipped_profiles - * 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. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); - parent::__construct($data); - } - - /** - * List of profiles fetched. - * - * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getProfiles() - { - return $this->profiles; - } - - /** - * List of profiles fetched. - * - * Generated from protobuf field repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; - * @param array<\Google\Cloud\Profiler\V2\Profile>|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setProfiles($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Profiler\V2\Profile::class); - $this->profiles = $arr; - - return $this; - } - - /** - * Token to receive the next page of results. - * This field maybe empty if there are no more profiles to fetch. - * - * Generated from protobuf field string next_page_token = 2; - * @return string - */ - public function getNextPageToken() - { - return $this->next_page_token; - } - - /** - * Token to receive the next page of results. - * This field maybe empty if there are no more profiles to fetch. - * - * Generated from protobuf field string next_page_token = 2; - * @param string $var - * @return $this - */ - public function setNextPageToken($var) - { - GPBUtil::checkString($var, True); - $this->next_page_token = $var; - - return $this; - } - - /** - * 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. - * - * Generated from protobuf field int32 skipped_profiles = 3; - * @return int - */ - public function getSkippedProfiles() - { - return $this->skipped_profiles; - } - - /** - * 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. - * - * Generated from protobuf field int32 skipped_profiles = 3; - * @param int $var - * @return $this - */ - public function setSkippedProfiles($var) - { - GPBUtil::checkInt32($var); - $this->skipped_profiles = $var; - - return $this; - } - -} - diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Profile.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Profile.php deleted file mode 100644 index 90f9a635a620..000000000000 --- a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/Profile.php +++ /dev/null @@ -1,345 +0,0 @@ -google.devtools.cloudprofiler.v2.Profile - */ -class Profile extends \Google\Protobuf\Internal\Message -{ - /** - * Output only. Opaque, server-assigned, unique ID for this profile. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - protected $name = ''; - /** - * 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. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; - */ - protected $profile_type = 0; - /** - * Deployment this profile corresponds to. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 3; - */ - protected $deployment = null; - /** - * 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). - * - * Generated from protobuf field .google.protobuf.Duration duration = 4; - */ - protected $duration = null; - /** - * Input only. Profile bytes, as a gzip compressed serialized proto, the - * format is https://github.com/google/pprof/blob/master/proto/profile.proto. - * - * Generated from protobuf field bytes profile_bytes = 5 [(.google.api.field_behavior) = INPUT_ONLY]; - */ - protected $profile_bytes = ''; - /** - * 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. - * - * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = INPUT_ONLY]; - */ - private $labels; - /** - * Output only. Start time for the profile. - * This output is only present in response from the ListProfiles method. - * - * Generated from protobuf field .google.protobuf.Timestamp start_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; - */ - protected $start_time = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type string $name - * Output only. Opaque, server-assigned, unique ID for this profile. - * @type int $profile_type - * 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. - * @type \Google\Cloud\Profiler\V2\Deployment $deployment - * Deployment this profile corresponds to. - * @type \Google\Protobuf\Duration $duration - * 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). - * @type string $profile_bytes - * Input only. Profile bytes, as a gzip compressed serialized proto, the - * format is https://github.com/google/pprof/blob/master/proto/profile.proto. - * @type array|\Google\Protobuf\Internal\MapField $labels - * 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. - * @type \Google\Protobuf\Timestamp $start_time - * Output only. Start time for the profile. - * This output is only present in response from the ListProfiles method. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); - parent::__construct($data); - } - - /** - * Output only. Opaque, server-assigned, unique ID for this profile. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Output only. Opaque, server-assigned, unique ID for this profile. - * - * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - - /** - * 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. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; - * @return int - */ - public function getProfileType() - { - return $this->profile_type; - } - - /** - * 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. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.ProfileType profile_type = 2; - * @param int $var - * @return $this - */ - public function setProfileType($var) - { - GPBUtil::checkEnum($var, \Google\Cloud\Profiler\V2\ProfileType::class); - $this->profile_type = $var; - - return $this; - } - - /** - * Deployment this profile corresponds to. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 3; - * @return \Google\Cloud\Profiler\V2\Deployment|null - */ - public function getDeployment() - { - return $this->deployment; - } - - public function hasDeployment() - { - return isset($this->deployment); - } - - public function clearDeployment() - { - unset($this->deployment); - } - - /** - * Deployment this profile corresponds to. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Deployment deployment = 3; - * @param \Google\Cloud\Profiler\V2\Deployment $var - * @return $this - */ - public function setDeployment($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Profiler\V2\Deployment::class); - $this->deployment = $var; - - return $this; - } - - /** - * 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). - * - * Generated from protobuf field .google.protobuf.Duration duration = 4; - * @return \Google\Protobuf\Duration|null - */ - public function getDuration() - { - return $this->duration; - } - - public function hasDuration() - { - return isset($this->duration); - } - - public function clearDuration() - { - unset($this->duration); - } - - /** - * 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). - * - * Generated from protobuf field .google.protobuf.Duration duration = 4; - * @param \Google\Protobuf\Duration $var - * @return $this - */ - public function setDuration($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); - $this->duration = $var; - - return $this; - } - - /** - * Input only. Profile bytes, as a gzip compressed serialized proto, the - * format is https://github.com/google/pprof/blob/master/proto/profile.proto. - * - * Generated from protobuf field bytes profile_bytes = 5 [(.google.api.field_behavior) = INPUT_ONLY]; - * @return string - */ - public function getProfileBytes() - { - return $this->profile_bytes; - } - - /** - * Input only. Profile bytes, as a gzip compressed serialized proto, the - * format is https://github.com/google/pprof/blob/master/proto/profile.proto. - * - * Generated from protobuf field bytes profile_bytes = 5 [(.google.api.field_behavior) = INPUT_ONLY]; - * @param string $var - * @return $this - */ - public function setProfileBytes($var) - { - GPBUtil::checkString($var, False); - $this->profile_bytes = $var; - - return $this; - } - - /** - * 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. - * - * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = INPUT_ONLY]; - * @return \Google\Protobuf\Internal\MapField - */ - public function getLabels() - { - return $this->labels; - } - - /** - * 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. - * - * Generated from protobuf field map labels = 6 [(.google.api.field_behavior) = INPUT_ONLY]; - * @param array|\Google\Protobuf\Internal\MapField $var - * @return $this - */ - public function setLabels($var) - { - $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); - $this->labels = $arr; - - return $this; - } - - /** - * Output only. Start time for the profile. - * This output is only present in response from the ListProfiles method. - * - * Generated from protobuf field .google.protobuf.Timestamp start_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @return \Google\Protobuf\Timestamp|null - */ - public function getStartTime() - { - return $this->start_time; - } - - public function hasStartTime() - { - return isset($this->start_time); - } - - public function clearStartTime() - { - unset($this->start_time); - } - - /** - * Output only. Start time for the profile. - * This output is only present in response from the ListProfiles method. - * - * Generated from protobuf field .google.protobuf.Timestamp start_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * @param \Google\Protobuf\Timestamp $var - * @return $this - */ - public function setStartTime($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); - $this->start_time = $var; - - return $this; - } - -} - diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ProfileType.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ProfileType.php deleted file mode 100644 index c2adbcdd0ccf..000000000000 --- a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/ProfileType.php +++ /dev/null @@ -1,104 +0,0 @@ -google.devtools.cloudprofiler.v2.ProfileType - */ -class ProfileType -{ - /** - * Unspecified profile type. - * - * Generated from protobuf enum PROFILE_TYPE_UNSPECIFIED = 0; - */ - const PROFILE_TYPE_UNSPECIFIED = 0; - /** - * Thread CPU time sampling. - * - * Generated from protobuf enum CPU = 1; - */ - const CPU = 1; - /** - * Wallclock time sampling. More expensive as stops all threads. - * - * Generated from protobuf enum WALL = 2; - */ - const WALL = 2; - /** - * In-use heap profile. Represents a snapshot of the allocations that are - * live at the time of the profiling. - * - * Generated from protobuf enum HEAP = 3; - */ - const HEAP = 3; - /** - * Single-shot collection of all thread stacks. - * - * Generated from protobuf enum THREADS = 4; - */ - const THREADS = 4; - /** - * Synchronization contention profile. - * - * Generated from protobuf enum CONTENTION = 5; - */ - const CONTENTION = 5; - /** - * Peak heap profile. - * - * Generated from protobuf enum PEAK_HEAP = 6; - */ - const PEAK_HEAP = 6; - /** - * 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. - * - * Generated from protobuf enum HEAP_ALLOC = 7; - */ - const HEAP_ALLOC = 7; - - private static $valueToName = [ - self::PROFILE_TYPE_UNSPECIFIED => 'PROFILE_TYPE_UNSPECIFIED', - self::CPU => 'CPU', - self::WALL => 'WALL', - self::HEAP => 'HEAP', - self::THREADS => 'THREADS', - self::CONTENTION => 'CONTENTION', - self::PEAK_HEAP => 'PEAK_HEAP', - self::HEAP_ALLOC => 'HEAP_ALLOC', - ]; - - public static function name($value) - { - if (!isset(self::$valueToName[$value])) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', __CLASS__, $value)); - } - return self::$valueToName[$value]; - } - - - public static function value($name) - { - $const = __CLASS__ . '::' . strtoupper($name); - if (!defined($const)) { - throw new UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', __CLASS__, $name)); - } - return constant($const); - } -} - diff --git a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/UpdateProfileRequest.php b/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/UpdateProfileRequest.php deleted file mode 100644 index 3db9dcecdd2c..000000000000 --- a/owl-bot-staging/Profiler/v2/proto/src/Google/Cloud/Profiler/V2/UpdateProfileRequest.php +++ /dev/null @@ -1,151 +0,0 @@ -google.devtools.cloudprofiler.v2.UpdateProfileRequest - */ -class UpdateProfileRequest extends \Google\Protobuf\Internal\Message -{ - /** - * Profile to update. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 1; - */ - protected $profile = null; - /** - * Field mask used to specify the fields to be overwritten. Currently only - * profile_bytes and labels fields are supported by UpdateProfile, so only - * those fields can be specified in the mask. When no mask is provided, all - * fields are overwritten. - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; - */ - protected $update_mask = null; - - /** - * @param \Google\Cloud\Profiler\V2\Profile $profile Profile to update. - * @param \Google\Protobuf\FieldMask $updateMask Field mask used to specify the fields to be overwritten. Currently only - * profile_bytes and labels fields are supported by UpdateProfile, so only - * those fields can be specified in the mask. When no mask is provided, all - * fields are overwritten. - * - * @return \Google\Cloud\Profiler\V2\UpdateProfileRequest - * - * @experimental - */ - public static function build(\Google\Cloud\Profiler\V2\Profile $profile, \Google\Protobuf\FieldMask $updateMask): self - { - return (new self()) - ->setProfile($profile) - ->setUpdateMask($updateMask); - } - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Profiler\V2\Profile $profile - * Profile to update. - * @type \Google\Protobuf\FieldMask $update_mask - * Field mask used to specify the fields to be overwritten. Currently only - * profile_bytes and labels fields are supported by UpdateProfile, so only - * those fields can be specified in the mask. When no mask is provided, all - * fields are overwritten. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Devtools\Cloudprofiler\V2\Profiler::initOnce(); - parent::__construct($data); - } - - /** - * Profile to update. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 1; - * @return \Google\Cloud\Profiler\V2\Profile|null - */ - public function getProfile() - { - return $this->profile; - } - - public function hasProfile() - { - return isset($this->profile); - } - - public function clearProfile() - { - unset($this->profile); - } - - /** - * Profile to update. - * - * Generated from protobuf field .google.devtools.cloudprofiler.v2.Profile profile = 1; - * @param \Google\Cloud\Profiler\V2\Profile $var - * @return $this - */ - public function setProfile($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Profiler\V2\Profile::class); - $this->profile = $var; - - return $this; - } - - /** - * Field mask used to specify the fields to be overwritten. Currently only - * profile_bytes and labels fields are supported by UpdateProfile, so only - * those fields can be specified in the mask. When no mask is provided, all - * fields are overwritten. - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; - * @return \Google\Protobuf\FieldMask|null - */ - public function getUpdateMask() - { - return $this->update_mask; - } - - public function hasUpdateMask() - { - return isset($this->update_mask); - } - - public function clearUpdateMask() - { - unset($this->update_mask); - } - - /** - * Field mask used to specify the fields to be overwritten. Currently only - * profile_bytes and labels fields are supported by UpdateProfile, so only - * those fields can be specified in the mask. When no mask is provided, all - * fields are overwritten. - * - * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; - * @param \Google\Protobuf\FieldMask $var - * @return $this - */ - public function setUpdateMask($var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); - $this->update_mask = $var; - - return $this; - } - -} - diff --git a/owl-bot-staging/Profiler/v2/samples/V2/ExportServiceClient/list_profiles.php b/owl-bot-staging/Profiler/v2/samples/V2/ExportServiceClient/list_profiles.php deleted file mode 100644 index 53e4656ca44f..000000000000 --- a/owl-bot-staging/Profiler/v2/samples/V2/ExportServiceClient/list_profiles.php +++ /dev/null @@ -1,78 +0,0 @@ -setParent($formattedParent); - - // Call the API and handle any network failures. - try { - /** @var PagedListResponse $response */ - $response = $exportServiceClient->listProfiles($request); - - /** @var Profile $element */ - foreach ($response as $element) { - printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); - } - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} - -/** - * Helper to execute the sample. - * - * This sample has been automatically generated and should be regarded as a code - * template only. It will require modifications to work: - * - It may require correct/in-range values for request initialization. - * - It may require specifying regional endpoints when creating the service client, - * please see the apiEndpoint client configuration option for more details. - */ -function callSample(): void -{ - $formattedParent = ExportServiceClient::projectName('[PROJECT]'); - - list_profiles_sample($formattedParent); -} -// [END cloudprofiler_v2_generated_ExportService_ListProfiles_sync] diff --git a/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_offline_profile.php b/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_offline_profile.php deleted file mode 100644 index 153364e2d38e..000000000000 --- a/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_offline_profile.php +++ /dev/null @@ -1,64 +0,0 @@ -createOfflineProfile($request); - printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} -// [END cloudprofiler_v2_generated_ProfilerService_CreateOfflineProfile_sync] diff --git a/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_profile.php b/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_profile.php deleted file mode 100644 index 9405319b6060..000000000000 --- a/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/create_profile.php +++ /dev/null @@ -1,75 +0,0 @@ -createProfile($request); - printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} -// [END cloudprofiler_v2_generated_ProfilerService_CreateProfile_sync] diff --git a/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/update_profile.php b/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/update_profile.php deleted file mode 100644 index 957343f00a4a..000000000000 --- a/owl-bot-staging/Profiler/v2/samples/V2/ProfilerServiceClient/update_profile.php +++ /dev/null @@ -1,65 +0,0 @@ -updateProfile($request); - printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); - } catch (ApiException $ex) { - printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); - } -} -// [END cloudprofiler_v2_generated_ProfilerService_UpdateProfile_sync] diff --git a/owl-bot-staging/Profiler/v2/src/V2/Client/ExportServiceClient.php b/owl-bot-staging/Profiler/v2/src/V2/Client/ExportServiceClient.php deleted file mode 100644 index d57b72df683a..000000000000 --- a/owl-bot-staging/Profiler/v2/src/V2/Client/ExportServiceClient.php +++ /dev/null @@ -1,239 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/export_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/export_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/export_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/export_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a project - * resource. - * - * @param string $project - * - * @return string The formatted project resource. - */ - public static function projectName(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - project: projects/{project} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'cloudprofiler.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Lists profiles which have been collected so far and for which the caller - * has permission to view. - * - * The async variant is {@see ExportServiceClient::listProfilesAsync()} . - * - * @example samples/V2/ExportServiceClient/list_profiles.php - * - * @param ListProfilesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProfiles(ListProfilesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProfiles', $request, $callOptions); - } -} diff --git a/owl-bot-staging/Profiler/v2/src/V2/Client/ProfilerServiceClient.php b/owl-bot-staging/Profiler/v2/src/V2/Client/ProfilerServiceClient.php deleted file mode 100644 index 6a5889cb8f31..000000000000 --- a/owl-bot-staging/Profiler/v2/src/V2/Client/ProfilerServiceClient.php +++ /dev/null @@ -1,348 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/profiler_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/profiler_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/profiler_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/profiler_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a profile - * resource. - * - * @param string $project - * @param string $profile - * - * @return string The formatted profile resource. - */ - public static function profileName(string $project, string $profile): string - { - return self::getPathTemplate('profile')->render([ - 'project' => $project, - 'profile' => $profile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a project - * resource. - * - * @param string $project - * - * @return string The formatted project resource. - */ - public static function projectName(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - profile: projects/{project}/profiles/{profile} - * - project: projects/{project} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'cloudprofiler.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * 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._ - * - * The async variant is {@see ProfilerServiceClient::createOfflineProfileAsync()} . - * - * @example samples/V2/ProfilerServiceClient/create_offline_profile.php - * - * @param CreateOfflineProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return Profile - * - * @throws ApiException Thrown if the API call fails. - */ - public function createOfflineProfile(CreateOfflineProfileRequest $request, array $callOptions = []): Profile - { - return $this->startApiCall('CreateOfflineProfile', $request, $callOptions)->wait(); - } - - /** - * 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". - * - * - * The async variant is {@see ProfilerServiceClient::createProfileAsync()} . - * - * @example samples/V2/ProfilerServiceClient/create_profile.php - * - * @param CreateProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return Profile - * - * @throws ApiException Thrown if the API call fails. - */ - public function createProfile(CreateProfileRequest $request, array $callOptions = []): Profile - { - return $this->startApiCall('CreateProfile', $request, $callOptions)->wait(); - } - - /** - * 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._ - * - * The async variant is {@see ProfilerServiceClient::updateProfileAsync()} . - * - * @example samples/V2/ProfilerServiceClient/update_profile.php - * - * @param UpdateProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return Profile - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProfile(UpdateProfileRequest $request, array $callOptions = []): Profile - { - return $this->startApiCall('UpdateProfile', $request, $callOptions)->wait(); - } -} diff --git a/owl-bot-staging/Profiler/v2/src/V2/ExportServiceClient.php b/owl-bot-staging/Profiler/v2/src/V2/ExportServiceClient.php deleted file mode 100644 index 15bf48139a94..000000000000 --- a/owl-bot-staging/Profiler/v2/src/V2/ExportServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ -projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $exportServiceClient->listProfiles($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $exportServiceClient->listProfiles($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $exportServiceClient->close(); - * } - * ``` - * - * Many parameters require resource names to be formatted in a particular way. To - * assist with these names, this class includes a format method for each type of - * name, and additionally a parseName method to extract the individual identifiers - * contained within formatted names that are returned by the API. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Profiler\V2\Client\ExportServiceClient}. - */ -class ExportServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.devtools.cloudprofiler.v2.ExportService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'cloudprofiler.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'cloudprofiler.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.write', - ]; - - private static $projectNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/export_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/export_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/export_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/export_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getProjectNameTemplate() - { - if (self::$projectNameTemplate == null) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); - } - - return self::$projectNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'project' => self::getProjectNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a project - * resource. - * - * @param string $project - * - * @return string The formatted project resource. - */ - public static function projectName($project) - { - return self::getProjectNameTemplate()->render([ - 'project' => $project, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - project: projects/{project} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'cloudprofiler.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Lists profiles which have been collected so far and for which the caller - * has permission to view. - * - * Sample code: - * ``` - * $exportServiceClient = new ExportServiceClient(); - * try { - * $formattedParent = $exportServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $exportServiceClient->listProfiles($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $exportServiceClient->listProfiles($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $exportServiceClient->close(); - * } - * ``` - * - * @param string $parent Required. The parent, which owns this collection of profiles. - * Format: projects/{user_project_id} - * @param array $optionalArgs { - * Optional. - * - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listProfiles($parent, array $optionalArgs = []) - { - $request = new ListProfilesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListProfiles', $optionalArgs, ListProfilesResponse::class, $request); - } -} diff --git a/owl-bot-staging/Profiler/v2/src/V2/Gapic/ProfilerServiceGapicClient.php b/owl-bot-staging/Profiler/v2/src/V2/Gapic/ProfilerServiceGapicClient.php deleted file mode 100644 index c1471e834265..000000000000 --- a/owl-bot-staging/Profiler/v2/src/V2/Gapic/ProfilerServiceGapicClient.php +++ /dev/null @@ -1,473 +0,0 @@ -createOfflineProfile(); - * } finally { - * $profilerServiceClient->close(); - * } - * ``` - * - * Many parameters require resource names to be formatted in a particular way. To - * assist with these names, this class includes a format method for each type of - * name, and additionally a parseName method to extract the individual identifiers - * contained within formatted names that are returned by the API. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Profiler\V2\Client\ProfilerServiceClient}. - */ -class ProfilerServiceGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.devtools.cloudprofiler.v2.ProfilerService'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'cloudprofiler.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'cloudprofiler.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/monitoring', - 'https://www.googleapis.com/auth/monitoring.write', - ]; - - private static $profileNameTemplate; - - private static $projectNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/profiler_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/profiler_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/profiler_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/profiler_service_rest_client_config.php', - ], - ], - ]; - } - - private static function getProfileNameTemplate() - { - if (self::$profileNameTemplate == null) { - self::$profileNameTemplate = new PathTemplate('projects/{project}/profiles/{profile}'); - } - - return self::$profileNameTemplate; - } - - private static function getProjectNameTemplate() - { - if (self::$projectNameTemplate == null) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); - } - - return self::$projectNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'profile' => self::getProfileNameTemplate(), - 'project' => self::getProjectNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a profile - * resource. - * - * @param string $project - * @param string $profile - * - * @return string The formatted profile resource. - */ - public static function profileName($project, $profile) - { - return self::getProfileNameTemplate()->render([ - 'project' => $project, - 'profile' => $profile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a project - * resource. - * - * @param string $project - * - * @return string The formatted project resource. - */ - public static function projectName($project) - { - return self::getProjectNameTemplate()->render([ - 'project' => $project, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - profile: projects/{project}/profiles/{profile} - * - project: projects/{project} - * - * The optional $template argument can be supplied to specify a particular pattern, - * and must match one of the templates listed above. If no $template argument is - * provided, or if the $template argument does not match one of the templates - * listed, then parseName will check each of the supported templates, and return - * the first match. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'cloudprofiler.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * Client method configuration, including retry settings. This option can be either - * a path to a JSON file, or a PHP array containing the decoded JSON data. By - * default this settings points to the default client config file, which is - * provided in the resources folder. - * @type string|TransportInterface $transport - * The transport used for executing network requests. May be either the string - * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. - * *Advanced usage*: Additionally, it is possible to pass in an already - * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * Configuration options that will be used to construct the transport. Options for - * each supported transport type should be passed in a key for that transport. For - * example: - * $transportConfig = [ - * 'grpc' => [...], - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * A callable which returns the client cert as a string. This can be used to - * provide a certificate and private key to the transport layer for mTLS. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * 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._ - * - * Sample code: - * ``` - * $profilerServiceClient = new ProfilerServiceClient(); - * try { - * $response = $profilerServiceClient->createOfflineProfile(); - * } finally { - * $profilerServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $parent - * Parent project to create the profile in. - * @type Profile $profile - * Contents of the profile to create. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Profiler\V2\Profile - * - * @throws ApiException if the remote call fails - */ - public function createOfflineProfile(array $optionalArgs = []) - { - $request = new CreateOfflineProfileRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['parent']; - } - - if (isset($optionalArgs['profile'])) { - $request->setProfile($optionalArgs['profile']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateOfflineProfile', Profile::class, $optionalArgs, $request)->wait(); - } - - /** - * 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". - * - * - * Sample code: - * ``` - * $profilerServiceClient = new ProfilerServiceClient(); - * try { - * $response = $profilerServiceClient->createProfile(); - * } finally { - * $profilerServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type string $parent - * Parent project to create the profile in. - * @type Deployment $deployment - * Deployment details. - * @type int[] $profileType - * One or more profile types that the agent is capable of providing. - * For allowed values, use constants defined on {@see \Google\Cloud\Profiler\V2\ProfileType} - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Profiler\V2\Profile - * - * @throws ApiException if the remote call fails - */ - public function createProfile(array $optionalArgs = []) - { - $request = new CreateProfileRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['parent'])) { - $request->setParent($optionalArgs['parent']); - $requestParamHeaders['parent'] = $optionalArgs['parent']; - } - - if (isset($optionalArgs['deployment'])) { - $request->setDeployment($optionalArgs['deployment']); - } - - if (isset($optionalArgs['profileType'])) { - $request->setProfileType($optionalArgs['profileType']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateProfile', Profile::class, $optionalArgs, $request)->wait(); - } - - /** - * 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._ - * - * Sample code: - * ``` - * $profilerServiceClient = new ProfilerServiceClient(); - * try { - * $response = $profilerServiceClient->updateProfile(); - * } finally { - * $profilerServiceClient->close(); - * } - * ``` - * - * @param array $optionalArgs { - * Optional. - * - * @type Profile $profile - * Profile to update. - * @type FieldMask $updateMask - * Field mask used to specify the fields to be overwritten. Currently only - * profile_bytes and labels fields are supported by UpdateProfile, so only - * those fields can be specified in the mask. When no mask is provided, all - * fields are overwritten. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an - * associative array of retry settings parameters. See the documentation on - * {@see RetrySettings} for example usage. - * } - * - * @return \Google\Cloud\Profiler\V2\Profile - * - * @throws ApiException if the remote call fails - */ - public function updateProfile(array $optionalArgs = []) - { - $request = new UpdateProfileRequest(); - $requestParamHeaders = []; - if (isset($optionalArgs['profile'])) { - $request->setProfile($optionalArgs['profile']); - } - - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateProfile', Profile::class, $optionalArgs, $request)->wait(); - } -} diff --git a/owl-bot-staging/Profiler/v2/src/V2/ProfilerServiceClient.php b/owl-bot-staging/Profiler/v2/src/V2/ProfilerServiceClient.php deleted file mode 100644 index 6aaa9bf26951..000000000000 --- a/owl-bot-staging/Profiler/v2/src/V2/ProfilerServiceClient.php +++ /dev/null @@ -1,34 +0,0 @@ - [ - 'google.devtools.cloudprofiler.v2.ExportService' => [ - 'ListProfiles' => [ - 'pageStreaming' => [ - 'requestPageTokenGetMethod' => 'getPageToken', - 'requestPageTokenSetMethod' => 'setPageToken', - 'requestPageSizeGetMethod' => 'getPageSize', - 'requestPageSizeSetMethod' => 'setPageSize', - 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getProfiles', - ], - 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, - 'responseType' => 'Google\Cloud\Profiler\V2\ListProfilesResponse', - 'headerParams' => [ - [ - 'keyName' => 'parent', - 'fieldAccessors' => [ - 'getParent', - ], - ], - ], - ], - 'templateMap' => [ - 'project' => 'projects/{project}', - ], - ], - ], -]; diff --git a/owl-bot-staging/Profiler/v2/src/V2/resources/export_service_rest_client_config.php b/owl-bot-staging/Profiler/v2/src/V2/resources/export_service_rest_client_config.php deleted file mode 100644 index 1d0ddfa982ce..000000000000 --- a/owl-bot-staging/Profiler/v2/src/V2/resources/export_service_rest_client_config.php +++ /dev/null @@ -1,20 +0,0 @@ - [ - 'google.devtools.cloudprofiler.v2.ExportService' => [ - 'ListProfiles' => [ - 'method' => 'get', - 'uriTemplate' => '/v2/{parent=projects/*}/profiles', - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - ], - ], - 'numericEnums' => true, -]; diff --git a/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_client_config.json b/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_client_config.json deleted file mode 100644 index 3d4414a2036d..000000000000 --- a/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_client_config.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "interfaces": { - "google.devtools.cloudprofiler.v2.ProfilerService": { - "retry_codes": { - "no_retry_codes": [], - "retry_policy_1_codes": [ - "UNAVAILABLE" - ], - "no_retry_1_codes": [], - "no_retry_2_codes": [] - }, - "retry_params": { - "no_retry_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 0, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 0, - "total_timeout_millis": 0 - }, - "retry_policy_1_params": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 60000 - }, - "no_retry_1_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 3610000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 3610000, - "total_timeout_millis": 3610000 - }, - "no_retry_2_params": { - "initial_retry_delay_millis": 0, - "retry_delay_multiplier": 0.0, - "max_retry_delay_millis": 0, - "initial_rpc_timeout_millis": 30000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 30000, - "total_timeout_millis": 30000 - } - }, - "methods": { - "CreateOfflineProfile": { - "timeout_millis": 30000, - "retry_codes_name": "no_retry_2_codes", - "retry_params_name": "no_retry_2_params" - }, - "CreateProfile": { - "timeout_millis": 3610000, - "retry_codes_name": "no_retry_1_codes", - "retry_params_name": "no_retry_1_params" - }, - "UpdateProfile": { - "timeout_millis": 30000, - "retry_codes_name": "no_retry_2_codes", - "retry_params_name": "no_retry_2_params" - } - } - } - } -} diff --git a/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_descriptor_config.php b/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_descriptor_config.php deleted file mode 100644 index 6c16c0b3d285..000000000000 --- a/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_descriptor_config.php +++ /dev/null @@ -1,49 +0,0 @@ - [ - 'google.devtools.cloudprofiler.v2.ProfilerService' => [ - 'CreateOfflineProfile' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Cloud\Profiler\V2\Profile', - 'headerParams' => [ - [ - 'keyName' => 'parent', - 'fieldAccessors' => [ - 'getParent', - ], - ], - ], - ], - 'CreateProfile' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Cloud\Profiler\V2\Profile', - 'headerParams' => [ - [ - 'keyName' => 'parent', - 'fieldAccessors' => [ - 'getParent', - ], - ], - ], - ], - 'UpdateProfile' => [ - 'callType' => \Google\ApiCore\Call::UNARY_CALL, - 'responseType' => 'Google\Cloud\Profiler\V2\Profile', - 'headerParams' => [ - [ - 'keyName' => 'profile.name', - 'fieldAccessors' => [ - 'getProfile', - 'getName', - ], - ], - ], - ], - 'templateMap' => [ - 'profile' => 'projects/{project}/profiles/{profile}', - 'project' => 'projects/{project}', - ], - ], - ], -]; diff --git a/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_rest_client_config.php b/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_rest_client_config.php deleted file mode 100644 index 29d974a28083..000000000000 --- a/owl-bot-staging/Profiler/v2/src/V2/resources/profiler_service_rest_client_config.php +++ /dev/null @@ -1,46 +0,0 @@ - [ - 'google.devtools.cloudprofiler.v2.ProfilerService' => [ - 'CreateOfflineProfile' => [ - 'method' => 'post', - 'uriTemplate' => '/v2/{parent=projects/*}/profiles:createOffline', - 'body' => 'profile', - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'CreateProfile' => [ - 'method' => 'post', - 'uriTemplate' => '/v2/{parent=projects/*}/profiles', - 'body' => '*', - 'placeholders' => [ - 'parent' => [ - 'getters' => [ - 'getParent', - ], - ], - ], - ], - 'UpdateProfile' => [ - 'method' => 'patch', - 'uriTemplate' => '/v2/{profile.name=projects/*/profiles/*}', - 'body' => 'profile', - 'placeholders' => [ - 'profile.name' => [ - 'getters' => [ - 'getProfile', - 'getName', - ], - ], - ], - ], - ], - ], - 'numericEnums' => true, -]; diff --git a/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ExportServiceClientTest.php b/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ExportServiceClientTest.php deleted file mode 100644 index 8545dd2bd7a0..000000000000 --- a/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ExportServiceClientTest.php +++ /dev/null @@ -1,176 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ExportServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ExportServiceClient($options); - } - - /** @test */ - public function listProfilesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $skippedProfiles = 852593689; - $profilesElement = new Profile(); - $profiles = [ - $profilesElement, - ]; - $expectedResponse = new ListProfilesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSkippedProfiles($skippedProfiles); - $expectedResponse->setProfiles($profiles); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->projectName('[PROJECT]'); - $request = (new ListProfilesRequest()) - ->setParent($formattedParent); - $response = $gapicClient->listProfiles($request); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getProfiles()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ExportService/ListProfiles', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listProfilesExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $formattedParent = $gapicClient->projectName('[PROJECT]'); - $request = (new ListProfilesRequest()) - ->setParent($formattedParent); - try { - $gapicClient->listProfiles($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listProfilesAsyncTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $skippedProfiles = 852593689; - $profilesElement = new Profile(); - $profiles = [ - $profilesElement, - ]; - $expectedResponse = new ListProfilesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSkippedProfiles($skippedProfiles); - $expectedResponse->setProfiles($profiles); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->projectName('[PROJECT]'); - $request = (new ListProfilesRequest()) - ->setParent($formattedParent); - $response = $gapicClient->listProfilesAsync($request)->wait(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getProfiles()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ExportService/ListProfiles', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ProfilerServiceClientTest.php b/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ProfilerServiceClientTest.php deleted file mode 100644 index 6dbf9f964f9b..000000000000 --- a/owl-bot-staging/Profiler/v2/tests/Unit/V2/Client/ProfilerServiceClientTest.php +++ /dev/null @@ -1,264 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ProfilerServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ProfilerServiceClient($options); - } - - /** @test */ - public function createOfflineProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $profileBytes = '85'; - $expectedResponse = new Profile(); - $expectedResponse->setName($name); - $expectedResponse->setProfileBytes($profileBytes); - $transport->addResponse($expectedResponse); - $request = new CreateOfflineProfileRequest(); - $response = $gapicClient->createOfflineProfile($request); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateOfflineProfile', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createOfflineProfileExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - $request = new CreateOfflineProfileRequest(); - try { - $gapicClient->createOfflineProfile($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $profileBytes = '85'; - $expectedResponse = new Profile(); - $expectedResponse->setName($name); - $expectedResponse->setProfileBytes($profileBytes); - $transport->addResponse($expectedResponse); - $request = new CreateProfileRequest(); - $response = $gapicClient->createProfile($request); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateProfile', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createProfileExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - $request = new CreateProfileRequest(); - try { - $gapicClient->createProfile($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $profileBytes = '85'; - $expectedResponse = new Profile(); - $expectedResponse->setName($name); - $expectedResponse->setProfileBytes($profileBytes); - $transport->addResponse($expectedResponse); - $request = new UpdateProfileRequest(); - $response = $gapicClient->updateProfile($request); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/UpdateProfile', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateProfileExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - $request = new UpdateProfileRequest(); - try { - $gapicClient->updateProfile($request); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createOfflineProfileAsyncTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $profileBytes = '85'; - $expectedResponse = new Profile(); - $expectedResponse->setName($name); - $expectedResponse->setProfileBytes($profileBytes); - $transport->addResponse($expectedResponse); - $request = new CreateOfflineProfileRequest(); - $response = $gapicClient->createOfflineProfileAsync($request)->wait(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateOfflineProfile', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/owl-bot-staging/Profiler/v2/tests/Unit/V2/ExportServiceClientTest.php b/owl-bot-staging/Profiler/v2/tests/Unit/V2/ExportServiceClientTest.php deleted file mode 100644 index 5bceafbcde84..000000000000 --- a/owl-bot-staging/Profiler/v2/tests/Unit/V2/ExportServiceClientTest.php +++ /dev/null @@ -1,132 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ExportServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ExportServiceClient($options); - } - - /** @test */ - public function listProfilesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $skippedProfiles = 852593689; - $profilesElement = new Profile(); - $profiles = [ - $profilesElement, - ]; - $expectedResponse = new ListProfilesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSkippedProfiles($skippedProfiles); - $expectedResponse->setProfiles($profiles); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->projectName('[PROJECT]'); - $response = $gapicClient->listProfiles($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getProfiles()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ExportService/ListProfiles', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listProfilesExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - // Mock request - $formattedParent = $gapicClient->projectName('[PROJECT]'); - try { - $gapicClient->listProfiles($formattedParent); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -} diff --git a/owl-bot-staging/Profiler/v2/tests/Unit/V2/ProfilerServiceClientTest.php b/owl-bot-staging/Profiler/v2/tests/Unit/V2/ProfilerServiceClientTest.php deleted file mode 100644 index 737e80a730b5..000000000000 --- a/owl-bot-staging/Profiler/v2/tests/Unit/V2/ProfilerServiceClientTest.php +++ /dev/null @@ -1,229 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return ProfilerServiceClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new ProfilerServiceClient($options); - } - - /** @test */ - public function createOfflineProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $profileBytes = '85'; - $expectedResponse = new Profile(); - $expectedResponse->setName($name); - $expectedResponse->setProfileBytes($profileBytes); - $transport->addResponse($expectedResponse); - $response = $gapicClient->createOfflineProfile(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateOfflineProfile', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createOfflineProfileExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->createOfflineProfile(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $profileBytes = '85'; - $expectedResponse = new Profile(); - $expectedResponse->setName($name); - $expectedResponse->setProfileBytes($profileBytes); - $transport->addResponse($expectedResponse); - $response = $gapicClient->createProfile(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/CreateProfile', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createProfileExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->createProfile(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $profileBytes = '85'; - $expectedResponse = new Profile(); - $expectedResponse->setName($name); - $expectedResponse->setProfileBytes($profileBytes); - $transport->addResponse($expectedResponse); - $response = $gapicClient->updateProfile(); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.devtools.cloudprofiler.v2.ProfilerService/UpdateProfile', $actualFuncCall); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateProfileExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - $status = new stdClass(); - $status->code = Code::DATA_LOSS; - $status->details = 'internal error'; - $expectedExceptionMessage = json_encode([ - 'message' => 'internal error', - 'code' => Code::DATA_LOSS, - 'status' => 'DATA_LOSS', - 'details' => [], - ], JSON_PRETTY_PRINT); - $transport->addResponse(null, $status); - try { - $gapicClient->updateProfile(); - // If the $gapicClient method call did not throw, fail the test - $this->fail('Expected an ApiException, but no exception was thrown.'); - } catch (ApiException $ex) { - $this->assertEquals($status->code, $ex->getCode()); - $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); - } - // Call popReceivedCalls to ensure the stub is exhausted - $transport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - } -}