diff --git a/Monitoring/metadata/V3/Alert.php b/Monitoring/metadata/V3/Alert.php index cb97c4e4902..e681f2e916e 100644 Binary files a/Monitoring/metadata/V3/Alert.php and b/Monitoring/metadata/V3/Alert.php differ diff --git a/Monitoring/metadata/V3/AlertService.php b/Monitoring/metadata/V3/AlertService.php index a60b5c01e82..b5ca2fc73a9 100644 --- a/Monitoring/metadata/V3/AlertService.php +++ b/Monitoring/metadata/V3/AlertService.php @@ -21,84 +21,42 @@ public static function initOnce() { \GPBMetadata\Google\Monitoring\V3\Alert::initOnce(); \GPBMetadata\Google\Protobuf\GPBEmpty::initOnce(); \GPBMetadata\Google\Protobuf\FieldMask::initOnce(); - $pool->internalAddGeneratedFile(hex2bin( - "0ad2110a28676f6f676c652f6d6f6e69746f72696e672f76332f616c6572" . - "745f736572766963652e70726f746f1214676f6f676c652e6d6f6e69746f" . - "72696e672e76331a17676f6f676c652f6170692f636c69656e742e70726f" . - "746f1a1f676f6f676c652f6170692f6669656c645f6265686176696f722e" . - "70726f746f1a19676f6f676c652f6170692f7265736f757263652e70726f" . - "746f1a20676f6f676c652f6d6f6e69746f72696e672f76332f616c657274" . - "2e70726f746f1a1b676f6f676c652f70726f746f6275662f656d7074792e" . - "70726f746f1a20676f6f676c652f70726f746f6275662f6669656c645f6d" . - "61736b2e70726f746f2295010a18437265617465416c657274506f6c6963" . - "7952657175657374123b0a046e616d65180320012809422de04102fa4127" . - "12256d6f6e69746f72696e672e676f6f676c65617069732e636f6d2f416c" . - "657274506f6c696379123c0a0c616c6572745f706f6c6963791802200128" . - "0b32212e676f6f676c652e6d6f6e69746f72696e672e76332e416c657274" . - "506f6c6963794203e0410222540a15476574416c657274506f6c69637952" . - "657175657374123b0a046e616d65180320012809422de04102fa41270a25" . - "6d6f6e69746f72696e672e676f6f676c65617069732e636f6d2f416c6572" . - "74506f6c69637922a0010a184c697374416c657274506f6c696369657352" . - "657175657374123b0a046e616d65180420012809422de04102fa41271225" . - "6d6f6e69746f72696e672e676f6f676c65617069732e636f6d2f416c6572" . - "74506f6c696379120e0a0666696c74657218052001280912100a086f7264" . - "65725f627918062001280912110a09706167655f73697a65180220012805" . - "12120a0a706167655f746f6b656e180320012809226f0a194c697374416c" . - "657274506f6c6963696573526573706f6e736512390a0e616c6572745f70" . - "6f6c696369657318032003280b32212e676f6f676c652e6d6f6e69746f72" . - "696e672e76332e416c657274506f6c69637912170a0f6e6578745f706167" . - "655f746f6b656e1802200128092289010a18557064617465416c65727450" . - "6f6c69637952657175657374122f0a0b7570646174655f6d61736b180220" . - "01280b321a2e676f6f676c652e70726f746f6275662e4669656c644d6173" . - "6b123c0a0c616c6572745f706f6c69637918032001280b32212e676f6f67" . - "6c652e6d6f6e69746f72696e672e76332e416c657274506f6c6963794203" . - "e0410222570a1844656c657465416c657274506f6c696379526571756573" . - "74123b0a046e616d65180320012809422de04102fa41270a256d6f6e6974" . - "6f72696e672e676f6f676c65617069732e636f6d2f416c657274506f6c69" . - "6379329e080a12416c657274506f6c6963795365727669636512a8010a11" . - "4c697374416c657274506f6c6963696573122e2e676f6f676c652e6d6f6e" . - "69746f72696e672e76332e4c697374416c657274506f6c69636965735265" . - "71756573741a2f2e676f6f676c652e6d6f6e69746f72696e672e76332e4c" . - "697374416c657274506f6c6963696573526573706f6e7365223282d3e493" . - "022512232f76332f7b6e616d653d70726f6a656374732f2a7d2f616c6572" . - "74506f6c6963696573da41046e616d651296010a0e476574416c65727450" . - "6f6c696379122b2e676f6f676c652e6d6f6e69746f72696e672e76332e47" . - "6574416c657274506f6c696379526571756573741a212e676f6f676c652e" . - "6d6f6e69746f72696e672e76332e416c657274506f6c696379223482d3e4" . - "93022712252f76332f7b6e616d653d70726f6a656374732f2a2f616c6572" . - "74506f6c69636965732f2a7dda41046e616d6512b5010a11437265617465" . - "416c657274506f6c696379122e2e676f6f676c652e6d6f6e69746f72696e" . - "672e76332e437265617465416c657274506f6c696379526571756573741a" . - "212e676f6f676c652e6d6f6e69746f72696e672e76332e416c657274506f" . - "6c696379224d82d3e493023322232f76332f7b6e616d653d70726f6a6563" . - "74732f2a7d2f616c657274506f6c69636965733a0c616c6572745f706f6c" . - "696379da41116e616d652c616c6572745f706f6c6963791291010a114465" . - "6c657465416c657274506f6c696379122e2e676f6f676c652e6d6f6e6974" . - "6f72696e672e76332e44656c657465416c657274506f6c69637952657175" . - "6573741a162e676f6f676c652e70726f746f6275662e456d707479223482" . - "d3e49302272a252f76332f7b6e616d653d70726f6a656374732f2a2f616c" . - "657274506f6c69636965732f2a7dda41046e616d6512cb010a1155706461" . - "7465416c657274506f6c696379122e2e676f6f676c652e6d6f6e69746f72" . - "696e672e76332e557064617465416c657274506f6c696379526571756573" . - "741a212e676f6f676c652e6d6f6e69746f72696e672e76332e416c657274" . - "506f6c696379226382d3e493024232322f76332f7b616c6572745f706f6c" . - "6963792e6e616d653d70726f6a656374732f2a2f616c657274506f6c6963" . - "6965732f2a7d3a0c616c6572745f706f6c696379da41187570646174655f" . - "6d61736b2c616c6572745f706f6c6963791aa901ca41196d6f6e69746f72" . - "696e672e676f6f676c65617069732e636f6dd241890168747470733a2f2f" . - "7777772e676f6f676c65617069732e636f6d2f617574682f636c6f75642d" . - "706c6174666f726d2c68747470733a2f2f7777772e676f6f676c65617069" . - "732e636f6d2f617574682f6d6f6e69746f72696e672c68747470733a2f2f" . - "7777772e676f6f676c65617069732e636f6d2f617574682f6d6f6e69746f" . - "72696e672e7265616442c9010a18636f6d2e676f6f676c652e6d6f6e6974" . - "6f72696e672e76334211416c6572745365727669636550726f746f50015a" . - "3e676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f676f" . - "6f676c65617069732f6d6f6e69746f72696e672f76333b6d6f6e69746f72" . - "696e67aa021a476f6f676c652e436c6f75642e4d6f6e69746f72696e672e" . - "5633ca021a476f6f676c655c436c6f75645c4d6f6e69746f72696e675c56" . - "33ea021d476f6f676c653a3a436c6f75643a3a4d6f6e69746f72696e673a" . - "3a5633620670726f746f33" - ), true); + $pool->internalAddGeneratedFile( + ' +ç +(google/monitoring/v3/alert_service.protogoogle.monitoring.v3google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto google/monitoring/v3/alert.protogoogle/protobuf/empty.proto google/protobuf/field_mask.proto"• +CreateAlertPolicyRequest; +name ( B-àAúA\'%monitoring.googleapis.com/AlertPolicy< + alert_policy ( 2!.google.monitoring.v3.AlertPolicyBàA"T +GetAlertPolicyRequest; +name ( B-àAúA\' +%monitoring.googleapis.com/AlertPolicy"  +ListAlertPoliciesRequest; +name ( B-àAúA\'%monitoring.googleapis.com/AlertPolicy +filter (  +order_by (  + page_size ( + +page_token ( "ƒ +ListAlertPoliciesResponse9 +alert_policies ( 2!.google.monitoring.v3.AlertPolicy +next_page_token (  + +total_size ("‰ +UpdateAlertPolicyRequest/ + update_mask ( 2.google.protobuf.FieldMask< + alert_policy ( 2!.google.monitoring.v3.AlertPolicyBàA"W +DeleteAlertPolicyRequest; +name ( B-àAúA\' +%monitoring.googleapis.com/AlertPolicy2ž +AlertPolicyService¨ +ListAlertPolicies..google.monitoring.v3.ListAlertPoliciesRequest/.google.monitoring.v3.ListAlertPoliciesResponse"2‚Óä“%#/v3/{name=projects/*}/alertPoliciesÚAname– +GetAlertPolicy+.google.monitoring.v3.GetAlertPolicyRequest!.google.monitoring.v3.AlertPolicy"4‚Óä“\'%/v3/{name=projects/*/alertPolicies/*}ÚAnameµ +CreateAlertPolicy..google.monitoring.v3.CreateAlertPolicyRequest!.google.monitoring.v3.AlertPolicy"M‚Óä“3"#/v3/{name=projects/*}/alertPolicies: alert_policyÚAname,alert_policy‘ +DeleteAlertPolicy..google.monitoring.v3.DeleteAlertPolicyRequest.google.protobuf.Empty"4‚Óä“\'*%/v3/{name=projects/*/alertPolicies/*}ÚAnameË +UpdateAlertPolicy..google.monitoring.v3.UpdateAlertPolicyRequest!.google.monitoring.v3.AlertPolicy"c‚Óä“B22/v3/{alert_policy.name=projects/*/alertPolicies/*}: alert_policyÚAupdate_mask,alert_policy©ÊAmonitoring.googleapis.comÒA‰https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/monitoring,https://www.googleapis.com/auth/monitoring.readBÉ +com.google.monitoring.v3BAlertServiceProtoPZ>google.golang.org/genproto/googleapis/monitoring/v3;monitoringªGoogle.Cloud.Monitoring.V3ÊGoogle\\Cloud\\Monitoring\\V3êGoogle::Cloud::Monitoring::V3bproto3' + , true); static::$is_initialized = true; } diff --git a/Monitoring/metadata/V3/Common.php b/Monitoring/metadata/V3/Common.php index 8417f981284..57253ec061b 100644 Binary files a/Monitoring/metadata/V3/Common.php and b/Monitoring/metadata/V3/Common.php differ diff --git a/Monitoring/metadata/V3/DroppedLabels.php b/Monitoring/metadata/V3/DroppedLabels.php index b0275f95156..7e7a042ea75 100644 --- a/Monitoring/metadata/V3/DroppedLabels.php +++ b/Monitoring/metadata/V3/DroppedLabels.php @@ -14,22 +14,18 @@ public static function initOnce() { if (static::$is_initialized == true) { return; } - $pool->internalAddGeneratedFile(hex2bin( - "0a94030a29676f6f676c652f6d6f6e69746f72696e672f76332f64726f70" . - "7065645f6c6162656c732e70726f746f1214676f6f676c652e6d6f6e6974" . - "6f72696e672e7633227c0a0d44726f707065644c6162656c73123d0a056c" . - "6162656c18012003280b322e2e676f6f676c652e6d6f6e69746f72696e67" . - "2e76332e44726f707065644c6162656c732e4c6162656c456e7472791a2c" . - "0a0a4c6162656c456e747279120b0a036b6579180120012809120d0a0576" . - "616c75651802200128093a02380142ca010a18636f6d2e676f6f676c652e" . - "6d6f6e69746f72696e672e7633421244726f707065644c6162656c735072" . - "6f746f50015a3e676f6f676c652e676f6c616e672e6f72672f67656e7072" . - "6f746f2f676f6f676c65617069732f6d6f6e69746f72696e672f76333b6d" . - "6f6e69746f72696e67aa021a476f6f676c652e436c6f75642e4d6f6e6974" . - "6f72696e672e5633ca021a476f6f676c655c436c6f75645c4d6f6e69746f" . - "72696e675c5633ea021d476f6f676c653a3a436c6f75643a3a4d6f6e6974" . - "6f72696e673a3a5633620670726f746f33" - ), true); + $pool->internalAddGeneratedFile( + ' +” +)google/monitoring/v3/dropped_labels.protogoogle.monitoring.v3"| + DroppedLabels= +label ( 2..google.monitoring.v3.DroppedLabels.LabelEntry, + +LabelEntry +key (  +value ( :8BÊ +com.google.monitoring.v3BDroppedLabelsProtoPZ>google.golang.org/genproto/googleapis/monitoring/v3;monitoringªGoogle.Cloud.Monitoring.V3ÊGoogle\\Cloud\\Monitoring\\V3êGoogle::Cloud::Monitoring::V3bproto3' + , true); static::$is_initialized = true; } diff --git a/Monitoring/metadata/V3/Group.php b/Monitoring/metadata/V3/Group.php index 4c476a3ecd3..e3e95437843 100644 --- a/Monitoring/metadata/V3/Group.php +++ b/Monitoring/metadata/V3/Group.php @@ -15,26 +15,21 @@ public static function initOnce() { return; } \GPBMetadata\Google\Api\Resource::initOnce(); - $pool->internalAddGeneratedFile(hex2bin( - "0a88040a20676f6f676c652f6d6f6e69746f72696e672f76332f67726f75" . - "702e70726f746f1214676f6f676c652e6d6f6e69746f72696e672e763322" . - "80020a0547726f7570120c0a046e616d6518012001280912140a0c646973" . - "706c61795f6e616d6518022001280912130a0b706172656e745f6e616d65" . - "180320012809120e0a0666696c74657218052001280912120a0a69735f63" . - "6c75737465721806200128083a9901ea4195010a1f6d6f6e69746f72696e" . - "672e676f6f676c65617069732e636f6d2f47726f7570122170726f6a6563" . - "74732f7b70726f6a6563747d2f67726f7570732f7b67726f75707d122b6f" . - "7267616e697a6174696f6e732f7b6f7267616e697a6174696f6e7d2f6772" . - "6f7570732f7b67726f75707d121f666f6c646572732f7b666f6c6465727d" . - "2f67726f7570732f7b67726f75707d12012a42c2010a18636f6d2e676f6f" . - "676c652e6d6f6e69746f72696e672e7633420a47726f757050726f746f50" . - "015a3e676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f" . - "676f6f676c65617069732f6d6f6e69746f72696e672f76333b6d6f6e6974" . - "6f72696e67aa021a476f6f676c652e436c6f75642e4d6f6e69746f72696e" . - "672e5633ca021a476f6f676c655c436c6f75645c4d6f6e69746f72696e67" . - "5c5633ea021d476f6f676c653a3a436c6f75643a3a4d6f6e69746f72696e" . - "673a3a5633620670726f746f33" - ), true); + $pool->internalAddGeneratedFile( + ' +ˆ + google/monitoring/v3/group.protogoogle.monitoring.v3"€ +Group +name (  + display_name (  + parent_name (  +filter (  + +is_cluster (:™êA• +monitoring.googleapis.com/Group!projects/{project}/groups/{group}+organizations/{organization}/groups/{group}folders/{folder}/groups/{group}*B +com.google.monitoring.v3B +GroupProtoPZ>google.golang.org/genproto/googleapis/monitoring/v3;monitoringªGoogle.Cloud.Monitoring.V3ÊGoogle\\Cloud\\Monitoring\\V3êGoogle::Cloud::Monitoring::V3bproto3' + , true); static::$is_initialized = true; } diff --git a/Monitoring/metadata/V3/GroupService.php b/Monitoring/metadata/V3/GroupService.php index c3cae380f95..d1d73f8f1d7 100644 Binary files a/Monitoring/metadata/V3/GroupService.php and b/Monitoring/metadata/V3/GroupService.php differ diff --git a/Monitoring/metadata/V3/Metric.php b/Monitoring/metadata/V3/Metric.php index ce16d6d102d..af2fd6043ed 100644 Binary files a/Monitoring/metadata/V3/Metric.php and b/Monitoring/metadata/V3/Metric.php differ diff --git a/Monitoring/metadata/V3/MetricService.php b/Monitoring/metadata/V3/MetricService.php index 0efd3ea9324..ba32291f711 100644 Binary files a/Monitoring/metadata/V3/MetricService.php and b/Monitoring/metadata/V3/MetricService.php differ diff --git a/Monitoring/metadata/V3/MutationRecord.php b/Monitoring/metadata/V3/MutationRecord.php index 9d6416ce7ef..605c2f19932 100644 --- a/Monitoring/metadata/V3/MutationRecord.php +++ b/Monitoring/metadata/V3/MutationRecord.php @@ -15,21 +15,16 @@ public static function initOnce() { return; } \GPBMetadata\Google\Protobuf\Timestamp::initOnce(); - $pool->internalAddGeneratedFile(hex2bin( - "0aef020a2a676f6f676c652f6d6f6e69746f72696e672f76332f6d757461" . - "74696f6e5f7265636f72642e70726f746f1214676f6f676c652e6d6f6e69" . - "746f72696e672e763322550a0e4d75746174696f6e5265636f7264122f0a" . - "0b6d75746174655f74696d6518012001280b321a2e676f6f676c652e7072" . - "6f746f6275662e54696d657374616d7012120a0a6d7574617465645f6279" . - "18022001280942cb010a18636f6d2e676f6f676c652e6d6f6e69746f7269" . - "6e672e763342134d75746174696f6e5265636f726450726f746f50015a3e" . - "676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f676f6f" . - "676c65617069732f6d6f6e69746f72696e672f76333b6d6f6e69746f7269" . - "6e67aa021a476f6f676c652e436c6f75642e4d6f6e69746f72696e672e56" . - "33ca021a476f6f676c655c436c6f75645c4d6f6e69746f72696e675c5633" . - "ea021d476f6f676c653a3a436c6f75643a3a4d6f6e69746f72696e673a3a" . - "5633620670726f746f33" - ), true); + $pool->internalAddGeneratedFile( + ' +ï +*google/monitoring/v3/mutation_record.protogoogle.monitoring.v3"U +MutationRecord/ + mutate_time ( 2.google.protobuf.Timestamp + +mutated_by ( BË +com.google.monitoring.v3BMutationRecordProtoPZ>google.golang.org/genproto/googleapis/monitoring/v3;monitoringªGoogle.Cloud.Monitoring.V3ÊGoogle\\Cloud\\Monitoring\\V3êGoogle::Cloud::Monitoring::V3bproto3' + , true); static::$is_initialized = true; } diff --git a/Monitoring/metadata/V3/Notification.php b/Monitoring/metadata/V3/Notification.php index 32754cc94ea..dc1082ca1ed 100644 Binary files a/Monitoring/metadata/V3/Notification.php and b/Monitoring/metadata/V3/Notification.php differ diff --git a/Monitoring/metadata/V3/NotificationService.php b/Monitoring/metadata/V3/NotificationService.php index 58ec5f3713f..c99cbe7ef68 100644 --- a/Monitoring/metadata/V3/NotificationService.php +++ b/Monitoring/metadata/V3/NotificationService.php @@ -23,169 +23,74 @@ public static function initOnce() { \GPBMetadata\Google\Protobuf\FieldMask::initOnce(); \GPBMetadata\Google\Protobuf\Struct::initOnce(); \GPBMetadata\Google\Protobuf\Timestamp::initOnce(); - $pool->internalAddGeneratedFile(hex2bin( - "0ac3250a2f676f6f676c652f6d6f6e69746f72696e672f76332f6e6f7469" . - "6669636174696f6e5f736572766963652e70726f746f1214676f6f676c65" . - "2e6d6f6e69746f72696e672e76331a17676f6f676c652f6170692f636c69" . - "656e742e70726f746f1a1f676f6f676c652f6170692f6669656c645f6265" . - "686176696f722e70726f746f1a19676f6f676c652f6170692f7265736f75" . - "7263652e70726f746f1a27676f6f676c652f6d6f6e69746f72696e672f76" . - "332f6e6f74696669636174696f6e2e70726f746f1a1b676f6f676c652f70" . - "726f746f6275662f656d7074792e70726f746f1a20676f6f676c652f7072" . - "6f746f6275662f6669656c645f6d61736b2e70726f746f1a1c676f6f676c" . - "652f70726f746f6275662f7374727563742e70726f746f1a1f676f6f676c" . - "652f70726f746f6275662f74696d657374616d702e70726f746f22a1010a" . - "294c6973744e6f74696669636174696f6e4368616e6e656c446573637269" . - "70746f727352657175657374124d0a046e616d65180420012809423fe041" . - "02fa413912376d6f6e69746f72696e672e676f6f676c65617069732e636f" . - "6d2f4e6f74696669636174696f6e4368616e6e656c44657363726970746f" . - "7212110a09706167655f73697a6518022001280512120a0a706167655f74" . - "6f6b656e1803200128092297010a2a4c6973744e6f74696669636174696f" . - "6e4368616e6e656c44657363726970746f7273526573706f6e736512500a" . - "136368616e6e656c5f64657363726970746f727318012003280b32332e67" . - "6f6f676c652e6d6f6e69746f72696e672e76332e4e6f7469666963617469" . - "6f6e4368616e6e656c44657363726970746f7212170a0f6e6578745f7061" . - "67655f746f6b656e18022001280922780a274765744e6f74696669636174" . - "696f6e4368616e6e656c44657363726970746f7252657175657374124d0a" . - "046e616d65180320012809423fe04102fa41390a376d6f6e69746f72696e" . - "672e676f6f676c65617069732e636f6d2f4e6f74696669636174696f6e43" . - "68616e6e656c44657363726970746f7222b5010a204372656174654e6f74" . - "696669636174696f6e4368616e6e656c5265717565737412430a046e616d" . - "651803200128094235e04102fa412f122d6d6f6e69746f72696e672e676f" . - "6f676c65617069732e636f6d2f4e6f74696669636174696f6e4368616e6e" . - "656c124c0a146e6f74696669636174696f6e5f6368616e6e656c18022001" . - "280b32292e676f6f676c652e6d6f6e69746f72696e672e76332e4e6f7469" . - "6669636174696f6e4368616e6e656c4203e0410222af010a1f4c6973744e" . - "6f74696669636174696f6e4368616e6e656c735265717565737412430a04" . - "6e616d651805200128094235e04102fa412f122d6d6f6e69746f72696e67" . - "2e676f6f676c65617069732e636f6d2f4e6f74696669636174696f6e4368" . - "616e6e656c120e0a0666696c74657218062001280912100a086f72646572" . - "5f627918072001280912110a09706167655f73697a651803200128051212" . - "0a0a706167655f746f6b656e1804200128092285010a204c6973744e6f74" . - "696669636174696f6e4368616e6e656c73526573706f6e736512480a156e" . - "6f74696669636174696f6e5f6368616e6e656c7318032003280b32292e67" . - "6f6f676c652e6d6f6e69746f72696e672e76332e4e6f7469666963617469" . - "6f6e4368616e6e656c12170a0f6e6578745f706167655f746f6b656e1802" . - "2001280922640a1d4765744e6f74696669636174696f6e4368616e6e656c" . - "5265717565737412430a046e616d651803200128094235e04102fa412f0a" . - "2d6d6f6e69746f72696e672e676f6f676c65617069732e636f6d2f4e6f74" . - "696669636174696f6e4368616e6e656c22a1010a205570646174654e6f74" . - "696669636174696f6e4368616e6e656c52657175657374122f0a0b757064" . - "6174655f6d61736b18022001280b321a2e676f6f676c652e70726f746f62" . - "75662e4669656c644d61736b124c0a146e6f74696669636174696f6e5f63" . - "68616e6e656c18032001280b32292e676f6f676c652e6d6f6e69746f7269" . - "6e672e76332e4e6f74696669636174696f6e4368616e6e656c4203e04102" . - "22760a2044656c6574654e6f74696669636174696f6e4368616e6e656c52" . - "65717565737412430a046e616d651803200128094235e04102fa412f0a2d" . - "6d6f6e69746f72696e672e676f6f676c65617069732e636f6d2f4e6f7469" . - "6669636174696f6e4368616e6e656c120d0a05666f726365180520012808" . - "22750a2e53656e644e6f74696669636174696f6e4368616e6e656c566572" . - "696669636174696f6e436f64655265717565737412430a046e616d651801" . - "200128094235e04102fa412f0a2d6d6f6e69746f72696e672e676f6f676c" . - "65617069732e636f6d2f4e6f74696669636174696f6e4368616e6e656c22" . - "a5010a2d4765744e6f74696669636174696f6e4368616e6e656c56657269" . - "6669636174696f6e436f64655265717565737412430a046e616d65180120" . - "0128094235e04102fa412f0a2d6d6f6e69746f72696e672e676f6f676c65" . - "617069732e636f6d2f4e6f74696669636174696f6e4368616e6e656c122f" . - "0a0b6578706972655f74696d6518022001280b321a2e676f6f676c652e70" . - "726f746f6275662e54696d657374616d70226f0a2e4765744e6f74696669" . - "636174696f6e4368616e6e656c566572696669636174696f6e436f646552" . - "6573706f6e7365120c0a04636f6465180120012809122f0a0b6578706972" . - "655f74696d6518022001280b321a2e676f6f676c652e70726f746f627566" . - "2e54696d657374616d70227a0a205665726966794e6f7469666963617469" . - "6f6e4368616e6e656c5265717565737412430a046e616d65180120012809" . - "4235e04102fa412f0a2d6d6f6e69746f72696e672e676f6f676c65617069" . - "732e636f6d2f4e6f74696669636174696f6e4368616e6e656c12110a0463" . - "6f64651802200128094203e0410232ea120a1a4e6f74696669636174696f" . - "6e4368616e6e656c5365727669636512ec010a224c6973744e6f74696669" . - "636174696f6e4368616e6e656c44657363726970746f7273123f2e676f6f" . - "676c652e6d6f6e69746f72696e672e76332e4c6973744e6f746966696361" . - "74696f6e4368616e6e656c44657363726970746f7273526571756573741a" . - "402e676f6f676c652e6d6f6e69746f72696e672e76332e4c6973744e6f74" . - "696669636174696f6e4368616e6e656c44657363726970746f7273526573" . - "706f6e7365224382d3e493023612342f76332f7b6e616d653d70726f6a65" . - "6374732f2a7d2f6e6f74696669636174696f6e4368616e6e656c44657363" . - "726970746f7273da41046e616d6512dd010a204765744e6f746966696361" . - "74696f6e4368616e6e656c44657363726970746f72123d2e676f6f676c65" . - "2e6d6f6e69746f72696e672e76332e4765744e6f74696669636174696f6e" . - "4368616e6e656c44657363726970746f72526571756573741a332e676f6f" . - "676c652e6d6f6e69746f72696e672e76332e4e6f74696669636174696f6e" . - "4368616e6e656c44657363726970746f72224582d3e493023812362f7633" . - "2f7b6e616d653d70726f6a656374732f2a2f6e6f74696669636174696f6e" . - "4368616e6e656c44657363726970746f72732f2a7dda41046e616d6512c4" . - "010a184c6973744e6f74696669636174696f6e4368616e6e656c7312352e" . - "676f6f676c652e6d6f6e69746f72696e672e76332e4c6973744e6f746966" . - "69636174696f6e4368616e6e656c73526571756573741a362e676f6f676c" . - "652e6d6f6e69746f72696e672e76332e4c6973744e6f7469666963617469" . - "6f6e4368616e6e656c73526573706f6e7365223982d3e493022c122a2f76" . - "332f7b6e616d653d70726f6a656374732f2a7d2f6e6f7469666963617469" . - "6f6e4368616e6e656c73da41046e616d6512b5010a164765744e6f746966" . - "69636174696f6e4368616e6e656c12332e676f6f676c652e6d6f6e69746f" . - "72696e672e76332e4765744e6f74696669636174696f6e4368616e6e656c" . - "526571756573741a292e676f6f676c652e6d6f6e69746f72696e672e7633" . - "2e4e6f74696669636174696f6e4368616e6e656c223b82d3e493022e122c" . - "2f76332f7b6e616d653d70726f6a656374732f2a2f6e6f74696669636174" . - "696f6e4368616e6e656c732f2a7dda41046e616d6512e4010a1943726561" . - "74654e6f74696669636174696f6e4368616e6e656c12362e676f6f676c65" . - "2e6d6f6e69746f72696e672e76332e4372656174654e6f74696669636174" . - "696f6e4368616e6e656c526571756573741a292e676f6f676c652e6d6f6e" . - "69746f72696e672e76332e4e6f74696669636174696f6e4368616e6e656c" . - "226482d3e4930242222a2f76332f7b6e616d653d70726f6a656374732f2a" . - "7d2f6e6f74696669636174696f6e4368616e6e656c733a146e6f74696669" . - "636174696f6e5f6368616e6e656cda41196e616d652c6e6f746966696361" . - "74696f6e5f6368616e6e656c1283020a195570646174654e6f7469666963" . - "6174696f6e4368616e6e656c12362e676f6f676c652e6d6f6e69746f7269" . - "6e672e76332e5570646174654e6f74696669636174696f6e4368616e6e65" . - "6c526571756573741a292e676f6f676c652e6d6f6e69746f72696e672e76" . - "332e4e6f74696669636174696f6e4368616e6e656c22820182d3e4930259" . - "32412f76332f7b6e6f74696669636174696f6e5f6368616e6e656c2e6e61" . - "6d653d70726f6a656374732f2a2f6e6f74696669636174696f6e4368616e" . - "6e656c732f2a7d3a146e6f74696669636174696f6e5f6368616e6e656cda" . - "41207570646174655f6d61736b2c6e6f74696669636174696f6e5f636861" . - "6e6e656c12ae010a1944656c6574654e6f74696669636174696f6e436861" . - "6e6e656c12362e676f6f676c652e6d6f6e69746f72696e672e76332e4465" . - "6c6574654e6f74696669636174696f6e4368616e6e656c52657175657374" . - "1a162e676f6f676c652e70726f746f6275662e456d707479224182d3e493" . - "022e2a2c2f76332f7b6e616d653d70726f6a656374732f2a2f6e6f746966" . - "69636174696f6e4368616e6e656c732f2a7dda410a6e616d652c666f7263" . - "6512dc010a2753656e644e6f74696669636174696f6e4368616e6e656c56" . - "6572696669636174696f6e436f646512442e676f6f676c652e6d6f6e6974" . - "6f72696e672e76332e53656e644e6f74696669636174696f6e4368616e6e" . - "656c566572696669636174696f6e436f6465526571756573741a162e676f" . - "6f676c652e70726f746f6275662e456d707479225382d3e493024622412f" . - "76332f7b6e616d653d70726f6a656374732f2a2f6e6f7469666963617469" . - "6f6e4368616e6e656c732f2a7d3a73656e64566572696669636174696f6e" . - "436f64653a012ada41046e616d651287020a264765744e6f746966696361" . - "74696f6e4368616e6e656c566572696669636174696f6e436f646512432e" . - "676f6f676c652e6d6f6e69746f72696e672e76332e4765744e6f74696669" . - "636174696f6e4368616e6e656c566572696669636174696f6e436f646552" . - "6571756573741a442e676f6f676c652e6d6f6e69746f72696e672e76332e" . - "4765744e6f74696669636174696f6e4368616e6e656c5665726966696361" . - "74696f6e436f6465526573706f6e7365225282d3e493024522402f76332f" . - "7b6e616d653d70726f6a656374732f2a2f6e6f74696669636174696f6e43" . - "68616e6e656c732f2a7d3a676574566572696669636174696f6e436f6465" . - "3a012ada41046e616d6512ca010a195665726966794e6f74696669636174" . - "696f6e4368616e6e656c12362e676f6f676c652e6d6f6e69746f72696e67" . - "2e76332e5665726966794e6f74696669636174696f6e4368616e6e656c52" . - "6571756573741a292e676f6f676c652e6d6f6e69746f72696e672e76332e" . - "4e6f74696669636174696f6e4368616e6e656c224a82d3e493023822332f" . - "76332f7b6e616d653d70726f6a656374732f2a2f6e6f7469666963617469" . - "6f6e4368616e6e656c732f2a7d3a7665726966793a012ada41096e616d65" . - "2c636f64651aa901ca41196d6f6e69746f72696e672e676f6f676c656170" . - "69732e636f6dd241890168747470733a2f2f7777772e676f6f676c656170" . - "69732e636f6d2f617574682f636c6f75642d706c6174666f726d2c687474" . - "70733a2f2f7777772e676f6f676c65617069732e636f6d2f617574682f6d" . - "6f6e69746f72696e672c68747470733a2f2f7777772e676f6f676c656170" . - "69732e636f6d2f617574682f6d6f6e69746f72696e672e7265616442d001" . - "0a18636f6d2e676f6f676c652e6d6f6e69746f72696e672e763342184e6f" . - "74696669636174696f6e5365727669636550726f746f50015a3e676f6f67" . - "6c652e676f6c616e672e6f72672f67656e70726f746f2f676f6f676c6561" . - "7069732f6d6f6e69746f72696e672f76333b6d6f6e69746f72696e67aa02" . - "1a476f6f676c652e436c6f75642e4d6f6e69746f72696e672e5633ca021a" . - "476f6f676c655c436c6f75645c4d6f6e69746f72696e675c5633ea021d47" . - "6f6f676c653a3a436c6f75643a3a4d6f6e69746f72696e673a3a56336206" . - "70726f746f33" - ), true); + $pool->internalAddGeneratedFile( + ' +×% +/google/monitoring/v3/notification_service.protogoogle.monitoring.v3google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto\'google/monitoring/v3/notification.protogoogle/protobuf/empty.proto google/protobuf/field_mask.protogoogle/protobuf/struct.protogoogle/protobuf/timestamp.proto"¡ +)ListNotificationChannelDescriptorsRequestM +name ( B?àAúA97monitoring.googleapis.com/NotificationChannelDescriptor + page_size ( + +page_token ( "— +*ListNotificationChannelDescriptorsResponseP +channel_descriptors ( 23.google.monitoring.v3.NotificationChannelDescriptor +next_page_token ( "x +\'GetNotificationChannelDescriptorRequestM +name ( B?àAúA9 +7monitoring.googleapis.com/NotificationChannelDescriptor"µ + CreateNotificationChannelRequestC +name ( B5àAúA/-monitoring.googleapis.com/NotificationChannelL +notification_channel ( 2).google.monitoring.v3.NotificationChannelBàA"¯ +ListNotificationChannelsRequestC +name ( B5àAúA/-monitoring.googleapis.com/NotificationChannel +filter (  +order_by (  + page_size ( + +page_token ( "™ + ListNotificationChannelsResponseH +notification_channels ( 2).google.monitoring.v3.NotificationChannel +next_page_token (  + +total_size ("d +GetNotificationChannelRequestC +name ( B5àAúA/ +-monitoring.googleapis.com/NotificationChannel"¡ + UpdateNotificationChannelRequest/ + update_mask ( 2.google.protobuf.FieldMaskL +notification_channel ( 2).google.monitoring.v3.NotificationChannelBàA"v + DeleteNotificationChannelRequestC +name ( B5àAúA/ +-monitoring.googleapis.com/NotificationChannel +force ("u +.SendNotificationChannelVerificationCodeRequestC +name ( B5àAúA/ +-monitoring.googleapis.com/NotificationChannel"¥ +-GetNotificationChannelVerificationCodeRequestC +name ( B5àAúA/ +-monitoring.googleapis.com/NotificationChannel/ + expire_time ( 2.google.protobuf.Timestamp"o +.GetNotificationChannelVerificationCodeResponse +code ( / + expire_time ( 2.google.protobuf.Timestamp"z + VerifyNotificationChannelRequestC +name ( B5àAúA/ +-monitoring.googleapis.com/NotificationChannel +code ( BàA2ê +NotificationChannelServiceì +"ListNotificationChannelDescriptors?.google.monitoring.v3.ListNotificationChannelDescriptorsRequest@.google.monitoring.v3.ListNotificationChannelDescriptorsResponse"C‚Óä“64/v3/{name=projects/*}/notificationChannelDescriptorsÚAnameÝ + GetNotificationChannelDescriptor=.google.monitoring.v3.GetNotificationChannelDescriptorRequest3.google.monitoring.v3.NotificationChannelDescriptor"E‚Óä“86/v3/{name=projects/*/notificationChannelDescriptors/*}ÚAnameÄ +ListNotificationChannels5.google.monitoring.v3.ListNotificationChannelsRequest6.google.monitoring.v3.ListNotificationChannelsResponse"9‚Óä“,*/v3/{name=projects/*}/notificationChannelsÚAnameµ +GetNotificationChannel3.google.monitoring.v3.GetNotificationChannelRequest).google.monitoring.v3.NotificationChannel";‚Óä“.,/v3/{name=projects/*/notificationChannels/*}ÚAnameä +CreateNotificationChannel6.google.monitoring.v3.CreateNotificationChannelRequest).google.monitoring.v3.NotificationChannel"d‚Óä“B"*/v3/{name=projects/*}/notificationChannels:notification_channelÚAname,notification_channelƒ +UpdateNotificationChannel6.google.monitoring.v3.UpdateNotificationChannelRequest).google.monitoring.v3.NotificationChannel"‚‚Óä“Y2A/v3/{notification_channel.name=projects/*/notificationChannels/*}:notification_channelÚA update_mask,notification_channel® +DeleteNotificationChannel6.google.monitoring.v3.DeleteNotificationChannelRequest.google.protobuf.Empty"A‚Óä“.*,/v3/{name=projects/*/notificationChannels/*}ÚA +name,forceÜ +\'SendNotificationChannelVerificationCodeD.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest.google.protobuf.Empty"S‚Óä“F"A/v3/{name=projects/*/notificationChannels/*}:sendVerificationCode:*ÚAname‡ +&GetNotificationChannelVerificationCodeC.google.monitoring.v3.GetNotificationChannelVerificationCodeRequestD.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse"R‚Óä“E"@/v3/{name=projects/*/notificationChannels/*}:getVerificationCode:*ÚAnameÊ +VerifyNotificationChannel6.google.monitoring.v3.VerifyNotificationChannelRequest).google.monitoring.v3.NotificationChannel"J‚Óä“8"3/v3/{name=projects/*/notificationChannels/*}:verify:*ÚA name,code©ÊAmonitoring.googleapis.comÒA‰https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/monitoring,https://www.googleapis.com/auth/monitoring.readBÐ +com.google.monitoring.v3BNotificationServiceProtoPZ>google.golang.org/genproto/googleapis/monitoring/v3;monitoringªGoogle.Cloud.Monitoring.V3ÊGoogle\\Cloud\\Monitoring\\V3êGoogle::Cloud::Monitoring::V3bproto3' + , true); static::$is_initialized = true; } diff --git a/Monitoring/metadata/V3/QueryService.php b/Monitoring/metadata/V3/QueryService.php new file mode 100644 index 00000000000..fbd9c9ead5a --- /dev/null +++ b/Monitoring/metadata/V3/QueryService.php @@ -0,0 +1,34 @@ +internalAddGeneratedFile( + ' +ô +(google/monitoring/v3/query_service.protogoogle.monitoring.v3google/api/label.proto!google/monitoring/v3/metric.proto)google/monitoring/v3/metric_service.protogoogle/api/client.proto2Þ + QueryService¡ +QueryTimeSeries,.google.monitoring.v3.QueryTimeSeriesRequest-.google.monitoring.v3.QueryTimeSeriesResponse"1‚Óä“+"&/v3/{name=projects/*}/timeSeries:query:*©ÊAmonitoring.googleapis.comÒA‰https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/monitoring,https://www.googleapis.com/auth/monitoring.readBÉ +com.google.monitoring.v3BQueryServiceProtoPZ>google.golang.org/genproto/googleapis/monitoring/v3;monitoringªGoogle.Cloud.Monitoring.V3ÊGoogle\\Cloud\\Monitoring\\V3êGoogle::Cloud::Monitoring::V3bproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/Monitoring/metadata/V3/Service.php b/Monitoring/metadata/V3/Service.php index b21615349f1..4aef5a25c91 100644 Binary files a/Monitoring/metadata/V3/Service.php and b/Monitoring/metadata/V3/Service.php differ diff --git a/Monitoring/metadata/V3/ServiceService.php b/Monitoring/metadata/V3/ServiceService.php index 3d080f9dd8f..f1b7d60262f 100644 --- a/Monitoring/metadata/V3/ServiceService.php +++ b/Monitoring/metadata/V3/ServiceService.php @@ -21,149 +21,73 @@ public static function initOnce() { \GPBMetadata\Google\Monitoring\V3\Service::initOnce(); \GPBMetadata\Google\Protobuf\GPBEmpty::initOnce(); \GPBMetadata\Google\Protobuf\FieldMask::initOnce(); - $pool->internalAddGeneratedFile(hex2bin( - "0af0200a2a676f6f676c652f6d6f6e69746f72696e672f76332f73657276" . - "6963655f736572766963652e70726f746f1214676f6f676c652e6d6f6e69" . - "746f72696e672e76331a17676f6f676c652f6170692f636c69656e742e70" . - "726f746f1a1f676f6f676c652f6170692f6669656c645f6265686176696f" . - "722e70726f746f1a19676f6f676c652f6170692f7265736f757263652e70" . - "726f746f1a22676f6f676c652f6d6f6e69746f72696e672f76332f736572" . - "766963652e70726f746f1a1b676f6f676c652f70726f746f6275662f656d" . - "7074792e70726f746f1a20676f6f676c652f70726f746f6275662f666965" . - "6c645f6d61736b2e70726f746f229a010a14437265617465536572766963" . - "655265717565737412390a06706172656e741801200128094229e04102fa" . - "412312216d6f6e69746f72696e672e676f6f676c65617069732e636f6d2f" . - "5365727669636512120a0a736572766963655f696418032001280912330a" . - "077365727669636518022001280b321d2e676f6f676c652e6d6f6e69746f" . - "72696e672e76332e536572766963654203e04102224c0a11476574536572" . - "766963655265717565737412370a046e616d651801200128094229e04102" . - "fa41230a216d6f6e69746f72696e672e676f6f676c65617069732e636f6d" . - "2f536572766963652287010a134c69737453657276696365735265717565" . - "737412390a06706172656e741801200128094229e04102fa412312216d6f" . - "6e69746f72696e672e676f6f676c65617069732e636f6d2f536572766963" . - "65120e0a0666696c74657218022001280912110a09706167655f73697a65" . - "18032001280512120a0a706167655f746f6b656e18042001280922600a14" . - "4c6973745365727669636573526573706f6e7365122f0a08736572766963" . - "657318012003280b321d2e676f6f676c652e6d6f6e69746f72696e672e76" . - "332e5365727669636512170a0f6e6578745f706167655f746f6b656e1802" . - "20012809227c0a1455706461746553657276696365526571756573741233" . - "0a077365727669636518012001280b321d2e676f6f676c652e6d6f6e6974" . - "6f72696e672e76332e536572766963654203e04102122f0a0b7570646174" . - "655f6d61736b18022001280b321a2e676f6f676c652e70726f746f627566" . - "2e4669656c644d61736b224f0a1444656c65746553657276696365526571" . - "7565737412370a046e616d651801200128094229e04102fa41230a216d6f" . - "6e69746f72696e672e676f6f676c65617069732e636f6d2f536572766963" . - "6522d6010a22437265617465536572766963654c6576656c4f626a656374" . - "6976655265717565737412390a06706172656e741801200128094229e041" . - "02fa41230a216d6f6e69746f72696e672e676f6f676c65617069732e636f" . - "6d2f5365727669636512220a1a736572766963655f6c6576656c5f6f626a" . - "6563746976655f696418032001280912510a17736572766963655f6c6576" . - "656c5f6f626a65637469766518022001280b322b2e676f6f676c652e6d6f" . - "6e69746f72696e672e76332e536572766963654c6576656c4f626a656374" . - "6976654203e0410222a8010a1f476574536572766963654c6576656c4f62" . - "6a6563746976655265717565737412450a046e616d651801200128094237" . - "e04102fa41310a2f6d6f6e69746f72696e672e676f6f676c65617069732e" . - "636f6d2f536572766963654c6576656c4f626a656374697665123e0a0476" . - "69657718022001280e32302e676f6f676c652e6d6f6e69746f72696e672e" . - "76332e536572766963654c6576656c4f626a6563746976652e5669657722" . - "d5010a214c697374536572766963654c6576656c4f626a65637469766573" . - "5265717565737412390a06706172656e741801200128094229e04102fa41" . - "230a216d6f6e69746f72696e672e676f6f676c65617069732e636f6d2f53" . - "657276696365120e0a0666696c74657218022001280912110a0970616765" . - "5f73697a6518032001280512120a0a706167655f746f6b656e1804200128" . - "09123e0a047669657718052001280e32302e676f6f676c652e6d6f6e6974" . - "6f72696e672e76332e536572766963654c6576656c4f626a656374697665" . - "2e56696577228c010a224c697374536572766963654c6576656c4f626a65" . - "637469766573526573706f6e7365124d0a18736572766963655f6c657665" . - "6c5f6f626a6563746976657318012003280b322b2e676f6f676c652e6d6f" . - "6e69746f72696e672e76332e536572766963654c6576656c4f626a656374" . - "69766512170a0f6e6578745f706167655f746f6b656e18022001280922a8" . - "010a22557064617465536572766963654c6576656c4f626a656374697665" . - "5265717565737412510a17736572766963655f6c6576656c5f6f626a6563" . - "7469766518012001280b322b2e676f6f676c652e6d6f6e69746f72696e67" . - "2e76332e536572766963654c6576656c4f626a6563746976654203e04102" . - "122f0a0b7570646174655f6d61736b18022001280b321a2e676f6f676c65" . - "2e70726f746f6275662e4669656c644d61736b226b0a2244656c65746553" . - "6572766963654c6576656c4f626a6563746976655265717565737412450a" . - "046e616d651801200128094237e04102fa41310a2f6d6f6e69746f72696e" . - "672e676f6f676c65617069732e636f6d2f536572766963654c6576656c4f" . - "626a65637469766532ea0f0a18536572766963654d6f6e69746f72696e67" . - "536572766963651297010a0d43726561746553657276696365122a2e676f" . - "6f676c652e6d6f6e69746f72696e672e76332e4372656174655365727669" . - "6365526571756573741a1d2e676f6f676c652e6d6f6e69746f72696e672e" . - "76332e53657276696365223b82d3e493022422192f76332f7b706172656e" . - "743d2a2f2a7d2f73657276696365733a0773657276696365da410e706172" . - "656e742c73657276696365127e0a0a4765745365727669636512272e676f" . - "6f676c652e6d6f6e69746f72696e672e76332e4765745365727669636552" . - "6571756573741a1d2e676f6f676c652e6d6f6e69746f72696e672e76332e" . - "53657276696365222882d3e493021b12192f76332f7b6e616d653d2a2f2a" . - "2f73657276696365732f2a7dda41046e616d651291010a0c4c6973745365" . - "72766963657312292e676f6f676c652e6d6f6e69746f72696e672e76332e" . - "4c6973745365727669636573526571756573741a2a2e676f6f676c652e6d" . - "6f6e69746f72696e672e76332e4c6973745365727669636573526573706f" . - "6e7365222a82d3e493021b12192f76332f7b706172656e743d2a2f2a7d2f" . - "7365727669636573da4106706172656e741298010a0d5570646174655365" . - "7276696365122a2e676f6f676c652e6d6f6e69746f72696e672e76332e55" . - "706461746553657276696365526571756573741a1d2e676f6f676c652e6d" . - "6f6e69746f72696e672e76332e53657276696365223c82d3e493022c3221" . - "2f76332f7b736572766963652e6e616d653d2a2f2a2f7365727669636573" . - "2f2a7d3a0773657276696365da410773657276696365127d0a0d44656c65" . - "746553657276696365122a2e676f6f676c652e6d6f6e69746f72696e672e" . - "76332e44656c65746553657276696365526571756573741a162e676f6f67" . - "6c652e70726f746f6275662e456d707479222882d3e493021b2a192f7633" . - "2f7b6e616d653d2a2f2a2f73657276696365732f2a7dda41046e616d6512" . - "fa010a1b437265617465536572766963654c6576656c4f626a6563746976" . - "6512382e676f6f676c652e6d6f6e69746f72696e672e76332e4372656174" . - "65536572766963654c6576656c4f626a656374697665526571756573741a" . - "2b2e676f6f676c652e6d6f6e69746f72696e672e76332e53657276696365" . - "4c6576656c4f626a656374697665227482d3e493024d22322f76332f7b70" . - "6172656e743d2a2f2a2f73657276696365732f2a7d2f736572766963654c" . - "6576656c4f626a656374697665733a17736572766963655f6c6576656c5f" . - "6f626a656374697665da411e706172656e742c736572766963655f6c6576" . - "656c5f6f626a65637469766512c1010a18476574536572766963654c6576" . - "656c4f626a65637469766512352e676f6f676c652e6d6f6e69746f72696e" . - "672e76332e476574536572766963654c6576656c4f626a65637469766552" . - "6571756573741a2b2e676f6f676c652e6d6f6e69746f72696e672e76332e" . - "536572766963654c6576656c4f626a656374697665224182d3e493023412" . - "322f76332f7b6e616d653d2a2f2a2f73657276696365732f2a2f73657276" . - "6963654c6576656c4f626a656374697665732f2a7dda41046e616d6512d4" . - "010a1a4c697374536572766963654c6576656c4f626a6563746976657312" . - "372e676f6f676c652e6d6f6e69746f72696e672e76332e4c697374536572" . - "766963654c6576656c4f626a65637469766573526571756573741a382e67" . - "6f6f676c652e6d6f6e69746f72696e672e76332e4c697374536572766963" . - "654c6576656c4f626a65637469766573526573706f6e7365224382d3e493" . - "023412322f76332f7b706172656e743d2a2f2a2f73657276696365732f2a" . - "7d2f736572766963654c6576656c4f626a65637469766573da4106706172" . - "656e74128c020a1b557064617465536572766963654c6576656c4f626a65" . - "637469766512382e676f6f676c652e6d6f6e69746f72696e672e76332e55" . - "7064617465536572766963654c6576656c4f626a65637469766552657175" . - "6573741a2b2e676f6f676c652e6d6f6e69746f72696e672e76332e536572" . - "766963654c6576656c4f626a65637469766522850182d3e4930265324a2f" . - "76332f7b736572766963655f6c6576656c5f6f626a6563746976652e6e61" . - "6d653d2a2f2a2f73657276696365732f2a2f736572766963654c6576656c" . - "4f626a656374697665732f2a7d3a17736572766963655f6c6576656c5f6f" . - "626a656374697665da4117736572766963655f6c6576656c5f6f626a6563" . - "7469766512b2010a1b44656c657465536572766963654c6576656c4f626a" . - "65637469766512382e676f6f676c652e6d6f6e69746f72696e672e76332e" . - "44656c657465536572766963654c6576656c4f626a656374697665526571" . - "756573741a162e676f6f676c652e70726f746f6275662e456d7074792241" . - "82d3e49302342a322f76332f7b6e616d653d2a2f2a2f7365727669636573" . - "2f2a2f736572766963654c6576656c4f626a656374697665732f2a7dda41" . - "046e616d651aa901ca41196d6f6e69746f72696e672e676f6f676c656170" . - "69732e636f6dd241890168747470733a2f2f7777772e676f6f676c656170" . - "69732e636f6d2f617574682f636c6f75642d706c6174666f726d2c687474" . - "70733a2f2f7777772e676f6f676c65617069732e636f6d2f617574682f6d" . - "6f6e69746f72696e672c68747470733a2f2f7777772e676f6f676c656170" . - "69732e636f6d2f617574682f6d6f6e69746f72696e672e7265616442d501" . - "0a18636f6d2e676f6f676c652e6d6f6e69746f72696e672e7633421d5365" . - "72766963654d6f6e69746f72696e675365727669636550726f746f50015a" . - "3e676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f676f" . - "6f676c65617069732f6d6f6e69746f72696e672f76333b6d6f6e69746f72" . - "696e67aa021a476f6f676c652e436c6f75642e4d6f6e69746f72696e672e" . - "5633ca021a476f6f676c655c436c6f75645c4d6f6e69746f72696e675c56" . - "33ea021d476f6f676c653a3a436c6f75643a3a4d6f6e69746f72696e673a" . - "3a5633620670726f746f33" - ), true); + $pool->internalAddGeneratedFile( + ' +ð +*google/monitoring/v3/service_service.protogoogle.monitoring.v3google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto"google/monitoring/v3/service.protogoogle/protobuf/empty.proto google/protobuf/field_mask.proto"š +CreateServiceRequest9 +parent ( B)àAúA#!monitoring.googleapis.com/Service + +service_id ( 3 +service ( 2.google.monitoring.v3.ServiceBàA"L +GetServiceRequest7 +name ( B)àAúA# +!monitoring.googleapis.com/Service"‡ +ListServicesRequest9 +parent ( B)àAúA#!monitoring.googleapis.com/Service +filter (  + page_size ( + +page_token ( "` +ListServicesResponse/ +services ( 2.google.monitoring.v3.Service +next_page_token ( "| +UpdateServiceRequest3 +service ( 2.google.monitoring.v3.ServiceBàA/ + update_mask ( 2.google.protobuf.FieldMask"O +DeleteServiceRequest7 +name ( B)àAúA# +!monitoring.googleapis.com/Service"Ö +"CreateServiceLevelObjectiveRequest9 +parent ( B)àAúA# +!monitoring.googleapis.com/Service" +service_level_objective_id ( Q +service_level_objective ( 2+.google.monitoring.v3.ServiceLevelObjectiveBàA"¨ +GetServiceLevelObjectiveRequestE +name ( B7àAúA1 +/monitoring.googleapis.com/ServiceLevelObjective> +view (20.google.monitoring.v3.ServiceLevelObjective.View"Õ +!ListServiceLevelObjectivesRequest9 +parent ( B)àAúA# +!monitoring.googleapis.com/Service +filter (  + page_size ( + +page_token ( > +view (20.google.monitoring.v3.ServiceLevelObjective.View"Œ +"ListServiceLevelObjectivesResponseM +service_level_objectives ( 2+.google.monitoring.v3.ServiceLevelObjective +next_page_token ( "¨ +"UpdateServiceLevelObjectiveRequestQ +service_level_objective ( 2+.google.monitoring.v3.ServiceLevelObjectiveBàA/ + update_mask ( 2.google.protobuf.FieldMask"k +"DeleteServiceLevelObjectiveRequestE +name ( B7àAúA1 +/monitoring.googleapis.com/ServiceLevelObjective2ê +ServiceMonitoringService— + CreateService*.google.monitoring.v3.CreateServiceRequest.google.monitoring.v3.Service";‚Óä“$"/v3/{parent=*/*}/services:serviceÚAparent,service~ + +GetService\'.google.monitoring.v3.GetServiceRequest.google.monitoring.v3.Service"(‚Óä“/v3/{name=*/*/services/*}ÚAname‘ + ListServices).google.monitoring.v3.ListServicesRequest*.google.monitoring.v3.ListServicesResponse"*‚Óä“/v3/{parent=*/*}/servicesÚAparent˜ + UpdateService*.google.monitoring.v3.UpdateServiceRequest.google.monitoring.v3.Service"<‚Óä“,2!/v3/{service.name=*/*/services/*}:serviceÚAservice} + DeleteService*.google.monitoring.v3.DeleteServiceRequest.google.protobuf.Empty"(‚Óä“*/v3/{name=*/*/services/*}ÚAnameú +CreateServiceLevelObjective8.google.monitoring.v3.CreateServiceLevelObjectiveRequest+.google.monitoring.v3.ServiceLevelObjective"t‚Óä“M"2/v3/{parent=*/*/services/*}/serviceLevelObjectives:service_level_objectiveÚAparent,service_level_objectiveÁ +GetServiceLevelObjective5.google.monitoring.v3.GetServiceLevelObjectiveRequest+.google.monitoring.v3.ServiceLevelObjective"A‚Óä“42/v3/{name=*/*/services/*/serviceLevelObjectives/*}ÚAnameÔ +ListServiceLevelObjectives7.google.monitoring.v3.ListServiceLevelObjectivesRequest8.google.monitoring.v3.ListServiceLevelObjectivesResponse"C‚Óä“42/v3/{parent=*/*/services/*}/serviceLevelObjectivesÚAparentŒ +UpdateServiceLevelObjective8.google.monitoring.v3.UpdateServiceLevelObjectiveRequest+.google.monitoring.v3.ServiceLevelObjective"…‚Óä“e2J/v3/{service_level_objective.name=*/*/services/*/serviceLevelObjectives/*}:service_level_objectiveÚAservice_level_objective² +DeleteServiceLevelObjective8.google.monitoring.v3.DeleteServiceLevelObjectiveRequest.google.protobuf.Empty"A‚Óä“4*2/v3/{name=*/*/services/*/serviceLevelObjectives/*}ÚAname©ÊAmonitoring.googleapis.comÒA‰https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/monitoring,https://www.googleapis.com/auth/monitoring.readBÕ +com.google.monitoring.v3BServiceMonitoringServiceProtoPZ>google.golang.org/genproto/googleapis/monitoring/v3;monitoringªGoogle.Cloud.Monitoring.V3ÊGoogle\\Cloud\\Monitoring\\V3êGoogle::Cloud::Monitoring::V3bproto3' + , true); static::$is_initialized = true; } diff --git a/Monitoring/metadata/V3/SpanContext.php b/Monitoring/metadata/V3/SpanContext.php index db690e55771..959e03af5ad 100644 --- a/Monitoring/metadata/V3/SpanContext.php +++ b/Monitoring/metadata/V3/SpanContext.php @@ -14,19 +14,14 @@ public static function initOnce() { if (static::$is_initialized == true) { return; } - $pool->internalAddGeneratedFile(hex2bin( - "0ab4020a27676f6f676c652f6d6f6e69746f72696e672f76332f7370616e" . - "5f636f6e746578742e70726f746f1214676f6f676c652e6d6f6e69746f72" . - "696e672e763322200a0b5370616e436f6e7465787412110a097370616e5f" . - "6e616d6518012001280942c8010a18636f6d2e676f6f676c652e6d6f6e69" . - "746f72696e672e763342105370616e436f6e7465787450726f746f50015a" . - "3e676f6f676c652e676f6c616e672e6f72672f67656e70726f746f2f676f" . - "6f676c65617069732f6d6f6e69746f72696e672f76333b6d6f6e69746f72" . - "696e67aa021a476f6f676c652e436c6f75642e4d6f6e69746f72696e672e" . - "5633ca021a476f6f676c655c436c6f75645c4d6f6e69746f72696e675c56" . - "33ea021d476f6f676c653a3a436c6f75643a3a4d6f6e69746f72696e673a" . - "3a5633620670726f746f33" - ), true); + $pool->internalAddGeneratedFile( + ' +´ +\'google/monitoring/v3/span_context.protogoogle.monitoring.v3" + SpanContext + span_name ( BÈ +com.google.monitoring.v3BSpanContextProtoPZ>google.golang.org/genproto/googleapis/monitoring/v3;monitoringªGoogle.Cloud.Monitoring.V3ÊGoogle\\Cloud\\Monitoring\\V3êGoogle::Cloud::Monitoring::V3bproto3' + , true); static::$is_initialized = true; } diff --git a/Monitoring/metadata/V3/Uptime.php b/Monitoring/metadata/V3/Uptime.php index 563d73af539..21923666291 100644 Binary files a/Monitoring/metadata/V3/Uptime.php and b/Monitoring/metadata/V3/Uptime.php differ diff --git a/Monitoring/metadata/V3/UptimeService.php b/Monitoring/metadata/V3/UptimeService.php index 3ca4219b4e5..3f79d39437f 100644 --- a/Monitoring/metadata/V3/UptimeService.php +++ b/Monitoring/metadata/V3/UptimeService.php @@ -18,108 +18,54 @@ public static function initOnce() { \GPBMetadata\Google\Api\Client::initOnce(); \GPBMetadata\Google\Api\FieldBehavior::initOnce(); \GPBMetadata\Google\Api\Resource::initOnce(); + \GPBMetadata\Google\Longrunning\Operations::initOnce(); \GPBMetadata\Google\Monitoring\V3\Uptime::initOnce(); \GPBMetadata\Google\Protobuf\Duration::initOnce(); \GPBMetadata\Google\Protobuf\GPBEmpty::initOnce(); \GPBMetadata\Google\Protobuf\FieldMask::initOnce(); - $pool->internalAddGeneratedFile(hex2bin( - "0aa5160a29676f6f676c652f6d6f6e69746f72696e672f76332f75707469" . - "6d655f736572766963652e70726f746f1214676f6f676c652e6d6f6e6974" . - "6f72696e672e76331a17676f6f676c652f6170692f636c69656e742e7072" . - "6f746f1a1f676f6f676c652f6170692f6669656c645f6265686176696f72" . - "2e70726f746f1a19676f6f676c652f6170692f7265736f757263652e7072" . - "6f746f1a21676f6f676c652f6d6f6e69746f72696e672f76332f75707469" . - "6d652e70726f746f1a1e676f6f676c652f70726f746f6275662f64757261" . - "74696f6e2e70726f746f1a1b676f6f676c652f70726f746f6275662f656d" . - "7074792e70726f746f1a20676f6f676c652f70726f746f6275662f666965" . - "6c645f6d61736b2e70726f746f228b010a1d4c697374557074696d654368" . - "65636b436f6e666967735265717565737412430a06706172656e74180120" . - "0128094233e04102fa412d122b6d6f6e69746f72696e672e676f6f676c65" . - "617069732e636f6d2f557074696d65436865636b436f6e66696712110a09" . - "706167655f73697a6518032001280512120a0a706167655f746f6b656e18" . - "04200128092294010a1e4c697374557074696d65436865636b436f6e6669" . - "6773526573706f6e736512450a14757074696d655f636865636b5f636f6e" . - "6669677318012003280b32272e676f6f676c652e6d6f6e69746f72696e67" . - "2e76332e557074696d65436865636b436f6e66696712170a0f6e6578745f" . - "706167655f746f6b656e18022001280912120a0a746f74616c5f73697a65" . - "18032001280522600a1b476574557074696d65436865636b436f6e666967" . - "5265717565737412410a046e616d651801200128094233e04102fa412d0a" . - "2b6d6f6e69746f72696e672e676f6f676c65617069732e636f6d2f557074" . - "696d65436865636b436f6e66696722b0010a1e437265617465557074696d" . - "65436865636b436f6e6669675265717565737412430a06706172656e7418" . - "01200128094233e04102fa412d122b6d6f6e69746f72696e672e676f6f67" . - "6c65617069732e636f6d2f557074696d65436865636b436f6e6669671249" . - "0a13757074696d655f636865636b5f636f6e66696718022001280b32272e" . - "676f6f676c652e6d6f6e69746f72696e672e76332e557074696d65436865" . - "636b436f6e6669674203e04102229c010a1e557064617465557074696d65" . - "436865636b436f6e66696752657175657374122f0a0b7570646174655f6d" . - "61736b18022001280b321a2e676f6f676c652e70726f746f6275662e4669" . - "656c644d61736b12490a13757074696d655f636865636b5f636f6e666967" . - "18032001280b32272e676f6f676c652e6d6f6e69746f72696e672e76332e" . - "557074696d65436865636b436f6e6669674203e0410222630a1e44656c65" . - "7465557074696d65436865636b436f6e6669675265717565737412410a04" . - "6e616d651801200128094233e04102fa412d0a2b6d6f6e69746f72696e67" . - "2e676f6f676c65617069732e636f6d2f557074696d65436865636b436f6e" . - "66696722420a194c697374557074696d65436865636b4970735265717565" . - "737412110a09706167655f73697a6518022001280512120a0a706167655f" . - "746f6b656e18032001280922740a1a4c697374557074696d65436865636b" . - "497073526573706f6e7365123d0a10757074696d655f636865636b5f6970" . - "7318012003280b32232e676f6f676c652e6d6f6e69746f72696e672e7633" . - "2e557074696d65436865636b497012170a0f6e6578745f706167655f746f" . - "6b656e18022001280932bd0a0a12557074696d65436865636b5365727669" . - "636512c0010a164c697374557074696d65436865636b436f6e6669677312" . - "332e676f6f676c652e6d6f6e69746f72696e672e76332e4c697374557074" . - "696d65436865636b436f6e66696773526571756573741a342e676f6f676c" . - "652e6d6f6e69746f72696e672e76332e4c697374557074696d6543686563" . - "6b436f6e66696773526573706f6e7365223b82d3e493022c122a2f76332f" . - "7b706172656e743d70726f6a656374732f2a7d2f757074696d6543686563" . - "6b436f6e66696773da4106706172656e7412ad010a14476574557074696d" . - "65436865636b436f6e66696712312e676f6f676c652e6d6f6e69746f7269" . - "6e672e76332e476574557074696d65436865636b436f6e66696752657175" . - "6573741a272e676f6f676c652e6d6f6e69746f72696e672e76332e557074" . - "696d65436865636b436f6e666967223982d3e493022c122a2f76332f7b6e" . - "616d653d70726f6a656374732f2a2f757074696d65436865636b436f6e66" . - "6967732f2a7dda41046e616d6512de010a17437265617465557074696d65" . - "436865636b436f6e66696712342e676f6f676c652e6d6f6e69746f72696e" . - "672e76332e437265617465557074696d65436865636b436f6e6669675265" . - "71756573741a272e676f6f676c652e6d6f6e69746f72696e672e76332e55" . - "7074696d65436865636b436f6e666967226482d3e4930241222a2f76332f" . - "7b706172656e743d70726f6a656374732f2a7d2f757074696d6543686563" . - "6b436f6e666967733a13757074696d655f636865636b5f636f6e666967da" . - "411a706172656e742c757074696d655f636865636b5f636f6e66696712eb" . - "010a17557064617465557074696d65436865636b436f6e66696712342e67" . - "6f6f676c652e6d6f6e69746f72696e672e76332e55706461746555707469" . - "6d65436865636b436f6e666967526571756573741a272e676f6f676c652e" . - "6d6f6e69746f72696e672e76332e557074696d65436865636b436f6e6669" . - "67227182d3e4930255323e2f76332f7b757074696d655f636865636b5f63" . - "6f6e6669672e6e616d653d70726f6a656374732f2a2f757074696d654368" . - "65636b436f6e666967732f2a7d3a13757074696d655f636865636b5f636f" . - "6e666967da4113757074696d655f636865636b5f636f6e66696712a2010a" . - "1744656c657465557074696d65436865636b436f6e66696712342e676f6f" . - "676c652e6d6f6e69746f72696e672e76332e44656c657465557074696d65" . - "436865636b436f6e666967526571756573741a162e676f6f676c652e7072" . - "6f746f6275662e456d707479223982d3e493022c2a2a2f76332f7b6e616d" . - "653d70726f6a656374732f2a2f757074696d65436865636b436f6e666967" . - "732f2a7dda41046e616d651293010a124c697374557074696d6543686563" . - "6b497073122f2e676f6f676c652e6d6f6e69746f72696e672e76332e4c69" . - "7374557074696d65436865636b497073526571756573741a302e676f6f67" . - "6c652e6d6f6e69746f72696e672e76332e4c697374557074696d65436865" . - "636b497073526573706f6e7365221a82d3e493021412122f76332f757074" . - "696d65436865636b4970731aa901ca41196d6f6e69746f72696e672e676f" . - "6f676c65617069732e636f6dd241890168747470733a2f2f7777772e676f" . - "6f676c65617069732e636f6d2f617574682f636c6f75642d706c6174666f" . - "726d2c68747470733a2f2f7777772e676f6f676c65617069732e636f6d2f" . - "617574682f6d6f6e69746f72696e672c68747470733a2f2f7777772e676f" . - "6f676c65617069732e636f6d2f617574682f6d6f6e69746f72696e672e72" . - "65616442ca010a18636f6d2e676f6f676c652e6d6f6e69746f72696e672e" . - "76334212557074696d655365727669636550726f746f50015a3e676f6f67" . - "6c652e676f6c616e672e6f72672f67656e70726f746f2f676f6f676c6561" . - "7069732f6d6f6e69746f72696e672f76333b6d6f6e69746f72696e67aa02" . - "1a476f6f676c652e436c6f75642e4d6f6e69746f72696e672e5633ca021a" . - "476f6f676c655c436c6f75645c4d6f6e69746f72696e675c5633ea021d47" . - "6f6f676c653a3a436c6f75643a3a4d6f6e69746f72696e673a3a56336206" . - "70726f746f33" - ), true); + $pool->internalAddGeneratedFile( + ' +Ê +)google/monitoring/v3/uptime_service.protogoogle.monitoring.v3google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.proto#google/longrunning/operations.proto!google/monitoring/v3/uptime.protogoogle/protobuf/duration.protogoogle/protobuf/empty.proto google/protobuf/field_mask.proto"‹ +ListUptimeCheckConfigsRequestC +parent ( B3àAúA-+monitoring.googleapis.com/UptimeCheckConfig + page_size ( + +page_token ( "” +ListUptimeCheckConfigsResponseE +uptime_check_configs ( 2\'.google.monitoring.v3.UptimeCheckConfig +next_page_token (  + +total_size ("` +GetUptimeCheckConfigRequestA +name ( B3àAúA- ++monitoring.googleapis.com/UptimeCheckConfig"° +CreateUptimeCheckConfigRequestC +parent ( B3àAúA-+monitoring.googleapis.com/UptimeCheckConfigI +uptime_check_config ( 2\'.google.monitoring.v3.UptimeCheckConfigBàA"œ +UpdateUptimeCheckConfigRequest/ + update_mask ( 2.google.protobuf.FieldMaskI +uptime_check_config ( 2\'.google.monitoring.v3.UptimeCheckConfigBàA"c +DeleteUptimeCheckConfigRequestA +name ( B3àAúA- ++monitoring.googleapis.com/UptimeCheckConfig"B +ListUptimeCheckIpsRequest + page_size ( + +page_token ( "t +ListUptimeCheckIpsResponse= +uptime_check_ips ( 2#.google.monitoring.v3.UptimeCheckIp +next_page_token ( 2½ + +UptimeCheckServiceÀ +ListUptimeCheckConfigs3.google.monitoring.v3.ListUptimeCheckConfigsRequest4.google.monitoring.v3.ListUptimeCheckConfigsResponse";‚Óä“,*/v3/{parent=projects/*}/uptimeCheckConfigsÚAparent­ +GetUptimeCheckConfig1.google.monitoring.v3.GetUptimeCheckConfigRequest\'.google.monitoring.v3.UptimeCheckConfig"9‚Óä“,*/v3/{name=projects/*/uptimeCheckConfigs/*}ÚAnameÞ +CreateUptimeCheckConfig4.google.monitoring.v3.CreateUptimeCheckConfigRequest\'.google.monitoring.v3.UptimeCheckConfig"d‚Óä“A"*/v3/{parent=projects/*}/uptimeCheckConfigs:uptime_check_configÚAparent,uptime_check_configë +UpdateUptimeCheckConfig4.google.monitoring.v3.UpdateUptimeCheckConfigRequest\'.google.monitoring.v3.UptimeCheckConfig"q‚Óä“U2>/v3/{uptime_check_config.name=projects/*/uptimeCheckConfigs/*}:uptime_check_configÚAuptime_check_config¢ +DeleteUptimeCheckConfig4.google.monitoring.v3.DeleteUptimeCheckConfigRequest.google.protobuf.Empty"9‚Óä“,**/v3/{name=projects/*/uptimeCheckConfigs/*}ÚAname“ +ListUptimeCheckIps/.google.monitoring.v3.ListUptimeCheckIpsRequest0.google.monitoring.v3.ListUptimeCheckIpsResponse"‚Óä“/v3/uptimeCheckIps©ÊAmonitoring.googleapis.comÒA‰https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/monitoring,https://www.googleapis.com/auth/monitoring.readBÊ +com.google.monitoring.v3BUptimeServiceProtoPZ>google.golang.org/genproto/googleapis/monitoring/v3;monitoringªGoogle.Cloud.Monitoring.V3ÊGoogle\\Cloud\\Monitoring\\V3êGoogle::Cloud::Monitoring::V3bproto3' + , true); static::$is_initialized = true; } diff --git a/Monitoring/src/V3/Aggregation.php b/Monitoring/src/V3/Aggregation.php index a3cf18f7d00..bce4facea7b 100644 --- a/Monitoring/src/V3/Aggregation.php +++ b/Monitoring/src/V3/Aggregation.php @@ -43,10 +43,12 @@ class Aggregation extends \Google\Protobuf\Internal\Message * [time series][google.monitoring.v3.TimeSeries] into consistent blocks of * time. This will be done before the per-series aligner can be applied to * the data. - * The value must be at least 60 seconds. If a per-series aligner other than - * `ALIGN_NONE` is specified, this field is required or an error is returned. - * If no per-series aligner is specified, or the aligner `ALIGN_NONE` is - * specified, then this field is ignored. + * The value must be at least 60 seconds. If a per-series + * aligner other than `ALIGN_NONE` is specified, this field is required or an + * error is returned. If no per-series aligner is specified, or the aligner + * `ALIGN_NONE` is specified, then this field is ignored. + * The maximum value of the `alignment_period` is 104 weeks (2 years) for + * charts, and 90,000 seconds (25 hours) for alerting policies. * * Generated from protobuf field .google.protobuf.Duration alignment_period = 1; */ @@ -119,10 +121,12 @@ class Aggregation extends \Google\Protobuf\Internal\Message * [time series][google.monitoring.v3.TimeSeries] into consistent blocks of * time. This will be done before the per-series aligner can be applied to * the data. - * The value must be at least 60 seconds. If a per-series aligner other than - * `ALIGN_NONE` is specified, this field is required or an error is returned. - * If no per-series aligner is specified, or the aligner `ALIGN_NONE` is - * specified, then this field is ignored. + * The value must be at least 60 seconds. If a per-series + * aligner other than `ALIGN_NONE` is specified, this field is required or an + * error is returned. If no per-series aligner is specified, or the aligner + * `ALIGN_NONE` is specified, then this field is ignored. + * The maximum value of the `alignment_period` is 104 weeks (2 years) for + * charts, and 90,000 seconds (25 hours) for alerting policies. * @type int $per_series_aligner * An `Aligner` describes how to bring the data points in a single * time series into temporal alignment. Except for `ALIGN_NONE`, all @@ -179,29 +183,43 @@ public function __construct($data = NULL) { * [time series][google.monitoring.v3.TimeSeries] into consistent blocks of * time. This will be done before the per-series aligner can be applied to * the data. - * The value must be at least 60 seconds. If a per-series aligner other than - * `ALIGN_NONE` is specified, this field is required or an error is returned. - * If no per-series aligner is specified, or the aligner `ALIGN_NONE` is - * specified, then this field is ignored. + * The value must be at least 60 seconds. If a per-series + * aligner other than `ALIGN_NONE` is specified, this field is required or an + * error is returned. If no per-series aligner is specified, or the aligner + * `ALIGN_NONE` is specified, then this field is ignored. + * The maximum value of the `alignment_period` is 104 weeks (2 years) for + * charts, and 90,000 seconds (25 hours) for alerting policies. * * Generated from protobuf field .google.protobuf.Duration alignment_period = 1; - * @return \Google\Protobuf\Duration + * @return \Google\Protobuf\Duration|null */ public function getAlignmentPeriod() { return $this->alignment_period; } + public function hasAlignmentPeriod() + { + return isset($this->alignment_period); + } + + public function clearAlignmentPeriod() + { + unset($this->alignment_period); + } + /** * The `alignment_period` specifies a time interval, in seconds, that is used * to divide the data in all the * [time series][google.monitoring.v3.TimeSeries] into consistent blocks of * time. This will be done before the per-series aligner can be applied to * the data. - * The value must be at least 60 seconds. If a per-series aligner other than - * `ALIGN_NONE` is specified, this field is required or an error is returned. - * If no per-series aligner is specified, or the aligner `ALIGN_NONE` is - * specified, then this field is ignored. + * The value must be at least 60 seconds. If a per-series + * aligner other than `ALIGN_NONE` is specified, this field is required or an + * error is returned. If no per-series aligner is specified, or the aligner + * `ALIGN_NONE` is specified, then this field is ignored. + * The maximum value of the `alignment_period` is 104 weeks (2 years) for + * charts, and 90,000 seconds (25 hours) for alerting policies. * * Generated from protobuf field .google.protobuf.Duration alignment_period = 1; * @param \Google\Protobuf\Duration $var @@ -261,7 +279,7 @@ public function getPerSeriesAligner() */ public function setPerSeriesAligner($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\Aggregation_Aligner::class); + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\Aggregation\Aligner::class); $this->per_series_aligner = $var; return $this; @@ -309,7 +327,7 @@ public function getCrossSeriesReducer() */ public function setCrossSeriesReducer($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\Aggregation_Reducer::class); + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\Aggregation\Reducer::class); $this->cross_series_reducer = $var; return $this; diff --git a/Monitoring/src/V3/AlertPolicy.php b/Monitoring/src/V3/AlertPolicy.php index 0ef95d64d09..51020322f39 100644 --- a/Monitoring/src/V3/AlertPolicy.php +++ b/Monitoring/src/V3/AlertPolicy.php @@ -23,7 +23,7 @@ class AlertPolicy extends \Google\Protobuf\Internal\Message * format is: * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] * `[ALERT_POLICY_ID]` is assigned by Stackdriver Monitoring when the policy - * is created. When calling the + * is created. When calling the * [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy] * method, do not include the `name` field in the alerting policy passed as * part of the request. @@ -126,6 +126,12 @@ class AlertPolicy extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.monitoring.v3.MutationRecord mutation_record = 11; */ private $mutation_record = null; + /** + * Control over how this alert policy's notification channels are notified. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.AlertStrategy alert_strategy = 21; + */ + private $alert_strategy = null; /** * Constructor. @@ -138,7 +144,7 @@ class AlertPolicy extends \Google\Protobuf\Internal\Message * format is: * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] * `[ALERT_POLICY_ID]` is assigned by Stackdriver Monitoring when the policy - * is created. When calling the + * is created. When calling the * [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy] * method, do not include the `name` field in the alerting policy passed as * part of the request. @@ -197,6 +203,8 @@ class AlertPolicy extends \Google\Protobuf\Internal\Message * @type \Google\Cloud\Monitoring\V3\MutationRecord $mutation_record * A read-only record of the most recent change to the alerting policy. If * provided in a call to create or update, this field will be ignored. + * @type \Google\Cloud\Monitoring\V3\AlertPolicy\AlertStrategy $alert_strategy + * Control over how this alert policy's notification channels are notified. * } */ public function __construct($data = NULL) { @@ -209,7 +217,7 @@ public function __construct($data = NULL) { * format is: * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] * `[ALERT_POLICY_ID]` is assigned by Stackdriver Monitoring when the policy - * is created. When calling the + * is created. When calling the * [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy] * method, do not include the `name` field in the alerting policy passed as * part of the request. @@ -227,7 +235,7 @@ public function getName() * format is: * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] * `[ALERT_POLICY_ID]` is assigned by Stackdriver Monitoring when the policy - * is created. When calling the + * is created. When calling the * [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy] * method, do not include the `name` field in the alerting policy passed as * part of the request. @@ -284,13 +292,23 @@ public function setDisplayName($var) * that have limited capacity might not show this documentation. * * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Documentation documentation = 13; - * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Documentation + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Documentation|null */ public function getDocumentation() { return $this->documentation; } + public function hasDocumentation() + { + return isset($this->documentation); + } + + public function clearDocumentation() + { + unset($this->documentation); + } + /** * Documentation that is included with notifications and incidents related to * this policy. Best practice is for the documentation to include information @@ -304,7 +322,7 @@ public function getDocumentation() */ public function setDocumentation($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy_Documentation::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Documentation::class); $this->documentation = $var; return $this; @@ -408,7 +426,7 @@ public function getCombiner() */ public function setCombiner($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\AlertPolicy_ConditionCombinerType::class); + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\AlertPolicy\ConditionCombinerType::class); $this->combiner = $var; return $this; @@ -422,13 +440,23 @@ public function setCombiner($var) * a field projection has been specified that strips it out. * * Generated from protobuf field .google.protobuf.BoolValue enabled = 17; - * @return \Google\Protobuf\BoolValue + * @return \Google\Protobuf\BoolValue|null */ public function getEnabled() { return $this->enabled; } + public function hasEnabled() + { + return isset($this->enabled); + } + + public function clearEnabled() + { + unset($this->enabled); + } + /** * Returns the unboxed value from getEnabled() @@ -488,13 +516,23 @@ public function setEnabledValue($var) * policy is valid. If not OK, the alert policy will not generate incidents. * * Generated from protobuf field .google.rpc.Status validity = 18; - * @return \Google\Rpc\Status + * @return \Google\Rpc\Status|null */ public function getValidity() { return $this->validity; } + public function hasValidity() + { + return isset($this->validity); + } + + public function clearValidity() + { + unset($this->validity); + } + /** * Read-only description of how the alert policy is invalid. OK if the alert * policy is valid. If not OK, the alert policy will not generate incidents. @@ -558,13 +596,23 @@ public function setNotificationChannels($var) * in a call to create or update, this field will be ignored. * * Generated from protobuf field .google.monitoring.v3.MutationRecord creation_record = 10; - * @return \Google\Cloud\Monitoring\V3\MutationRecord + * @return \Google\Cloud\Monitoring\V3\MutationRecord|null */ public function getCreationRecord() { return $this->creation_record; } + public function hasCreationRecord() + { + return isset($this->creation_record); + } + + public function clearCreationRecord() + { + unset($this->creation_record); + } + /** * A read-only record of the creation of the alerting policy. If provided * in a call to create or update, this field will be ignored. @@ -586,13 +634,23 @@ public function setCreationRecord($var) * provided in a call to create or update, this field will be ignored. * * Generated from protobuf field .google.monitoring.v3.MutationRecord mutation_record = 11; - * @return \Google\Cloud\Monitoring\V3\MutationRecord + * @return \Google\Cloud\Monitoring\V3\MutationRecord|null */ public function getMutationRecord() { return $this->mutation_record; } + public function hasMutationRecord() + { + return isset($this->mutation_record); + } + + public function clearMutationRecord() + { + unset($this->mutation_record); + } + /** * A read-only record of the most recent change to the alerting policy. If * provided in a call to create or update, this field will be ignored. @@ -609,5 +667,41 @@ public function setMutationRecord($var) return $this; } + /** + * Control over how this alert policy's notification channels are notified. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.AlertStrategy alert_strategy = 21; + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\AlertStrategy|null + */ + public function getAlertStrategy() + { + return $this->alert_strategy; + } + + public function hasAlertStrategy() + { + return isset($this->alert_strategy); + } + + public function clearAlertStrategy() + { + unset($this->alert_strategy); + } + + /** + * Control over how this alert policy's notification channels are notified. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.AlertStrategy alert_strategy = 21; + * @param \Google\Cloud\Monitoring\V3\AlertPolicy\AlertStrategy $var + * @return $this + */ + public function setAlertStrategy($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\AlertStrategy::class); + $this->alert_strategy = $var; + + return $this; + } + } diff --git a/Monitoring/src/V3/AlertPolicy/AlertStrategy.php b/Monitoring/src/V3/AlertPolicy/AlertStrategy.php new file mode 100644 index 00000000000..6aaf9a89f10 --- /dev/null +++ b/Monitoring/src/V3/AlertPolicy/AlertStrategy.php @@ -0,0 +1,133 @@ +google.monitoring.v3.AlertPolicy.AlertStrategy + */ +class AlertStrategy extends \Google\Protobuf\Internal\Message +{ + /** + * Required for alert policies with a `LogMatch` condition. + * This limit is not implemented for alert policies that are not log-based. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.AlertStrategy.NotificationRateLimit notification_rate_limit = 1; + */ + private $notification_rate_limit = null; + /** + * If an alert policy that was active has no data for this long, any open + * incidents will close + * + * Generated from protobuf field .google.protobuf.Duration auto_close = 3; + */ + private $auto_close = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Monitoring\V3\AlertPolicy\AlertStrategy\NotificationRateLimit $notification_rate_limit + * Required for alert policies with a `LogMatch` condition. + * This limit is not implemented for alert policies that are not log-based. + * @type \Google\Protobuf\Duration $auto_close + * If an alert policy that was active has no data for this long, any open + * incidents will close + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Monitoring\V3\Alert::initOnce(); + parent::__construct($data); + } + + /** + * Required for alert policies with a `LogMatch` condition. + * This limit is not implemented for alert policies that are not log-based. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.AlertStrategy.NotificationRateLimit notification_rate_limit = 1; + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\AlertStrategy\NotificationRateLimit|null + */ + public function getNotificationRateLimit() + { + return $this->notification_rate_limit; + } + + public function hasNotificationRateLimit() + { + return isset($this->notification_rate_limit); + } + + public function clearNotificationRateLimit() + { + unset($this->notification_rate_limit); + } + + /** + * Required for alert policies with a `LogMatch` condition. + * This limit is not implemented for alert policies that are not log-based. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.AlertStrategy.NotificationRateLimit notification_rate_limit = 1; + * @param \Google\Cloud\Monitoring\V3\AlertPolicy\AlertStrategy\NotificationRateLimit $var + * @return $this + */ + public function setNotificationRateLimit($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\AlertStrategy\NotificationRateLimit::class); + $this->notification_rate_limit = $var; + + return $this; + } + + /** + * If an alert policy that was active has no data for this long, any open + * incidents will close + * + * Generated from protobuf field .google.protobuf.Duration auto_close = 3; + * @return \Google\Protobuf\Duration|null + */ + public function getAutoClose() + { + return $this->auto_close; + } + + public function hasAutoClose() + { + return isset($this->auto_close); + } + + public function clearAutoClose() + { + unset($this->auto_close); + } + + /** + * If an alert policy that was active has no data for this long, any open + * incidents will close + * + * Generated from protobuf field .google.protobuf.Duration auto_close = 3; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setAutoClose($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->auto_close = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(AlertStrategy::class, \Google\Cloud\Monitoring\V3\AlertPolicy_AlertStrategy::class); + diff --git a/Monitoring/src/V3/AlertPolicy/AlertStrategy/NotificationRateLimit.php b/Monitoring/src/V3/AlertPolicy/AlertStrategy/NotificationRateLimit.php new file mode 100644 index 00000000000..3df6a8d2d95 --- /dev/null +++ b/Monitoring/src/V3/AlertPolicy/AlertStrategy/NotificationRateLimit.php @@ -0,0 +1,81 @@ +google.monitoring.v3.AlertPolicy.AlertStrategy.NotificationRateLimit + */ +class NotificationRateLimit extends \Google\Protobuf\Internal\Message +{ + /** + * Not more than one notification per `period`. + * + * Generated from protobuf field .google.protobuf.Duration period = 1; + */ + private $period = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Duration $period + * Not more than one notification per `period`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Monitoring\V3\Alert::initOnce(); + parent::__construct($data); + } + + /** + * Not more than one notification per `period`. + * + * Generated from protobuf field .google.protobuf.Duration period = 1; + * @return \Google\Protobuf\Duration|null + */ + public function getPeriod() + { + return $this->period; + } + + public function hasPeriod() + { + return isset($this->period); + } + + public function clearPeriod() + { + unset($this->period); + } + + /** + * Not more than one notification per `period`. + * + * Generated from protobuf field .google.protobuf.Duration period = 1; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setPeriod($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->period = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(NotificationRateLimit::class, \Google\Cloud\Monitoring\V3\AlertPolicy_AlertStrategy_NotificationRateLimit::class); + diff --git a/Monitoring/src/V3/AlertPolicy/Condition.php b/Monitoring/src/V3/AlertPolicy/Condition.php index 6058da4752f..a9759b44754 100644 --- a/Monitoring/src/V3/AlertPolicy/Condition.php +++ b/Monitoring/src/V3/AlertPolicy/Condition.php @@ -88,10 +88,12 @@ class Condition extends \Google\Protobuf\Internal\Message * @type \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MetricAbsence $condition_absent * A condition that checks that a time series continues to * receive new data points. - * @type \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\TimeSeriesQueryLanguageCondition $condition_time_series_query_language + * @type \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\LogMatch $condition_matched_log + * A condition that checks for log messages matching given constraints. If + * set, no other conditions can be present. + * @type \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MonitoringQueryLanguageCondition $condition_monitoring_query_language * A condition that uses the Monitoring Query Language to define * alerts. - * If set, no other conditions can be present. * } */ public function __construct($data = NULL) { @@ -197,13 +199,18 @@ public function setDisplayName($var) * A condition that compares a time series against a threshold. * * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.MetricThreshold condition_threshold = 1; - * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MetricThreshold + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MetricThreshold|null */ public function getConditionThreshold() { return $this->readOneof(1); } + public function hasConditionThreshold() + { + return $this->hasOneof(1); + } + /** * A condition that compares a time series against a threshold. * @@ -213,7 +220,7 @@ public function getConditionThreshold() */ public function setConditionThreshold($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_MetricThreshold::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MetricThreshold::class); $this->writeOneof(1, $var); return $this; @@ -224,13 +231,18 @@ public function setConditionThreshold($var) * receive new data points. * * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.MetricAbsence condition_absent = 2; - * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MetricAbsence + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MetricAbsence|null */ public function getConditionAbsent() { return $this->readOneof(2); } + public function hasConditionAbsent() + { + return $this->hasOneof(2); + } + /** * A condition that checks that a time series continues to * receive new data points. @@ -241,38 +253,74 @@ public function getConditionAbsent() */ public function setConditionAbsent($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_MetricAbsence::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MetricAbsence::class); $this->writeOneof(2, $var); return $this; } + /** + * A condition that checks for log messages matching given constraints. If + * set, no other conditions can be present. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.LogMatch condition_matched_log = 20; + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\LogMatch|null + */ + public function getConditionMatchedLog() + { + return $this->readOneof(20); + } + + public function hasConditionMatchedLog() + { + return $this->hasOneof(20); + } + + /** + * A condition that checks for log messages matching given constraints. If + * set, no other conditions can be present. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.LogMatch condition_matched_log = 20; + * @param \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\LogMatch $var + * @return $this + */ + public function setConditionMatchedLog($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\LogMatch::class); + $this->writeOneof(20, $var); + + return $this; + } + /** * A condition that uses the Monitoring Query Language to define * alerts. - * If set, no other conditions can be present. * - * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.TimeSeriesQueryLanguageCondition condition_time_series_query_language = 14; - * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\TimeSeriesQueryLanguageCondition + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.MonitoringQueryLanguageCondition condition_monitoring_query_language = 19; + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MonitoringQueryLanguageCondition|null */ - public function getConditionTimeSeriesQueryLanguage() + public function getConditionMonitoringQueryLanguage() + { + return $this->readOneof(19); + } + + public function hasConditionMonitoringQueryLanguage() { - return $this->readOneof(14); + return $this->hasOneof(19); } /** * A condition that uses the Monitoring Query Language to define * alerts. - * If set, no other conditions can be present. * - * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.TimeSeriesQueryLanguageCondition condition_time_series_query_language = 14; - * @param \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\TimeSeriesQueryLanguageCondition $var + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.MonitoringQueryLanguageCondition condition_monitoring_query_language = 19; + * @param \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MonitoringQueryLanguageCondition $var * @return $this */ - public function setConditionTimeSeriesQueryLanguage($var) + public function setConditionMonitoringQueryLanguage($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_TimeSeriesQueryLanguageCondition::class); - $this->writeOneof(14, $var); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\MonitoringQueryLanguageCondition::class); + $this->writeOneof(19, $var); return $this; } diff --git a/Monitoring/src/V3/AlertPolicy/Condition/LogMatch.php b/Monitoring/src/V3/AlertPolicy/Condition/LogMatch.php new file mode 100644 index 00000000000..0b94984551f --- /dev/null +++ b/Monitoring/src/V3/AlertPolicy/Condition/LogMatch.php @@ -0,0 +1,151 @@ +google.monitoring.v3.AlertPolicy.Condition.LogMatch + */ +class LogMatch extends \Google\Protobuf\Internal\Message +{ + /** + * Required. A logs-based filter. See [Advanced Logs + * Queries](https://cloud.google.com/logging/docs/view/advanced-queries) + * for how this filter should be constructed. + * + * Generated from protobuf field string filter = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $filter = ''; + /** + * Optional. A map from a label key to an extractor expression, which is + * used to extract the value for this label key. Each entry in this map is + * a specification for how data should be extracted from log entries that + * match `filter`. Each combination of extracted values is treated as a + * separate rule for the purposes of triggering notifications. Label keys + * and corresponding values can be used in notifications generated by this + * condition. + * Please see [the documentation on logs-based metric + * `valueExtractor`s](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric.FIELDS.value_extractor) + * for syntax and examples. + * + * Generated from protobuf field map label_extractors = 2; + */ + private $label_extractors; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $filter + * Required. A logs-based filter. See [Advanced Logs + * Queries](https://cloud.google.com/logging/docs/view/advanced-queries) + * for how this filter should be constructed. + * @type array|\Google\Protobuf\Internal\MapField $label_extractors + * Optional. A map from a label key to an extractor expression, which is + * used to extract the value for this label key. Each entry in this map is + * a specification for how data should be extracted from log entries that + * match `filter`. Each combination of extracted values is treated as a + * separate rule for the purposes of triggering notifications. Label keys + * and corresponding values can be used in notifications generated by this + * condition. + * Please see [the documentation on logs-based metric + * `valueExtractor`s](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric.FIELDS.value_extractor) + * for syntax and examples. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Monitoring\V3\Alert::initOnce(); + parent::__construct($data); + } + + /** + * Required. A logs-based filter. See [Advanced Logs + * Queries](https://cloud.google.com/logging/docs/view/advanced-queries) + * for how this filter should be constructed. + * + * Generated from protobuf field string filter = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Required. A logs-based filter. See [Advanced Logs + * Queries](https://cloud.google.com/logging/docs/view/advanced-queries) + * for how this filter should be constructed. + * + * Generated from protobuf field string filter = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Optional. A map from a label key to an extractor expression, which is + * used to extract the value for this label key. Each entry in this map is + * a specification for how data should be extracted from log entries that + * match `filter`. Each combination of extracted values is treated as a + * separate rule for the purposes of triggering notifications. Label keys + * and corresponding values can be used in notifications generated by this + * condition. + * Please see [the documentation on logs-based metric + * `valueExtractor`s](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric.FIELDS.value_extractor) + * for syntax and examples. + * + * Generated from protobuf field map label_extractors = 2; + * @return \Google\Protobuf\Internal\MapField + */ + public function getLabelExtractors() + { + return $this->label_extractors; + } + + /** + * Optional. A map from a label key to an extractor expression, which is + * used to extract the value for this label key. Each entry in this map is + * a specification for how data should be extracted from log entries that + * match `filter`. Each combination of extracted values is treated as a + * separate rule for the purposes of triggering notifications. Label keys + * and corresponding values can be used in notifications generated by this + * condition. + * Please see [the documentation on logs-based metric + * `valueExtractor`s](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric.FIELDS.value_extractor) + * for syntax and examples. + * + * Generated from protobuf field map label_extractors = 2; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setLabelExtractors($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->label_extractors = $arr; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(LogMatch::class, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_LogMatch::class); + diff --git a/Monitoring/src/V3/AlertPolicy/Condition/MetricAbsence.php b/Monitoring/src/V3/AlertPolicy/Condition/MetricAbsence.php index ca3c3a5838d..d3ae3b5d11c 100644 --- a/Monitoring/src/V3/AlertPolicy/Condition/MetricAbsence.php +++ b/Monitoring/src/V3/AlertPolicy/Condition/MetricAbsence.php @@ -20,17 +20,17 @@ class MetricAbsence extends \Google\Protobuf\Internal\Message { /** - * A [filter](https://cloud.google.com/monitoring/api/v3/filters) that + * Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that * identifies which time series should be compared with the threshold. * The filter is similar to the one that is specified in the * [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) * (that call is useful to verify the time series that will be retrieved / - * processed) and must specify the metric type and optionally may contain - * restrictions on resource type, resource labels, and metric labels. - * This field may not exceed 2048 Unicode characters in length. + * processed). The filter must specify the metric type and the resource + * type. Optionally, it can specify resource labels and metric labels. + * This field must not exceed 2048 Unicode characters in length. * - * Generated from protobuf field string filter = 1; + * Generated from protobuf field string filter = 1 [(.google.api.field_behavior) = REQUIRED]; */ private $filter = ''; /** @@ -38,7 +38,7 @@ class MetricAbsence extends \Google\Protobuf\Internal\Message * well as how to combine the retrieved time series together (such as * when aggregating multiple streams on each resource to a single * stream for each resource or when aggregating streams across all - * members of a group of resrouces). Multiple aggregations + * members of a group of resources). Multiple aggregations * are applied in the order specified. * This field is similar to the one in the [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). @@ -50,9 +50,10 @@ class MetricAbsence extends \Google\Protobuf\Internal\Message private $aggregations; /** * The amount of time that a time series must fail to report new - * data to be considered failing. Currently, only values that - * are a multiple of a minute--e.g. 60, 120, or 300 - * seconds--are supported. If an invalid value is given, an + * data to be considered failing. The minimum value of this field + * is 120 seconds. Larger values that are a multiple of a + * minute--for example, 240 or 300 seconds--are supported. + * If an invalid value is given, an * error will be returned. The `Duration.nanos` field is * ignored. * @@ -76,21 +77,21 @@ class MetricAbsence extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $filter - * A [filter](https://cloud.google.com/monitoring/api/v3/filters) that + * Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that * identifies which time series should be compared with the threshold. * The filter is similar to the one that is specified in the * [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) * (that call is useful to verify the time series that will be retrieved / - * processed) and must specify the metric type and optionally may contain - * restrictions on resource type, resource labels, and metric labels. - * This field may not exceed 2048 Unicode characters in length. + * processed). The filter must specify the metric type and the resource + * type. Optionally, it can specify resource labels and metric labels. + * This field must not exceed 2048 Unicode characters in length. * @type \Google\Cloud\Monitoring\V3\Aggregation[]|\Google\Protobuf\Internal\RepeatedField $aggregations * Specifies the alignment of data points in individual time series as * well as how to combine the retrieved time series together (such as * when aggregating multiple streams on each resource to a single * stream for each resource or when aggregating streams across all - * members of a group of resrouces). Multiple aggregations + * members of a group of resources). Multiple aggregations * are applied in the order specified. * This field is similar to the one in the [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). @@ -98,9 +99,10 @@ class MetricAbsence extends \Google\Protobuf\Internal\Message * field. * @type \Google\Protobuf\Duration $duration * The amount of time that a time series must fail to report new - * data to be considered failing. Currently, only values that - * are a multiple of a minute--e.g. 60, 120, or 300 - * seconds--are supported. If an invalid value is given, an + * data to be considered failing. The minimum value of this field + * is 120 seconds. Larger values that are a multiple of a + * minute--for example, 240 or 300 seconds--are supported. + * If an invalid value is given, an * error will be returned. The `Duration.nanos` field is * ignored. * @type \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger $trigger @@ -116,17 +118,17 @@ public function __construct($data = NULL) { } /** - * A [filter](https://cloud.google.com/monitoring/api/v3/filters) that + * Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that * identifies which time series should be compared with the threshold. * The filter is similar to the one that is specified in the * [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) * (that call is useful to verify the time series that will be retrieved / - * processed) and must specify the metric type and optionally may contain - * restrictions on resource type, resource labels, and metric labels. - * This field may not exceed 2048 Unicode characters in length. + * processed). The filter must specify the metric type and the resource + * type. Optionally, it can specify resource labels and metric labels. + * This field must not exceed 2048 Unicode characters in length. * - * Generated from protobuf field string filter = 1; + * Generated from protobuf field string filter = 1 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getFilter() @@ -135,17 +137,17 @@ public function getFilter() } /** - * A [filter](https://cloud.google.com/monitoring/api/v3/filters) that + * Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that * identifies which time series should be compared with the threshold. * The filter is similar to the one that is specified in the * [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) * (that call is useful to verify the time series that will be retrieved / - * processed) and must specify the metric type and optionally may contain - * restrictions on resource type, resource labels, and metric labels. - * This field may not exceed 2048 Unicode characters in length. + * processed). The filter must specify the metric type and the resource + * type. Optionally, it can specify resource labels and metric labels. + * This field must not exceed 2048 Unicode characters in length. * - * Generated from protobuf field string filter = 1; + * Generated from protobuf field string filter = 1 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -162,7 +164,7 @@ public function setFilter($var) * well as how to combine the retrieved time series together (such as * when aggregating multiple streams on each resource to a single * stream for each resource or when aggregating streams across all - * members of a group of resrouces). Multiple aggregations + * members of a group of resources). Multiple aggregations * are applied in the order specified. * This field is similar to the one in the [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). @@ -182,7 +184,7 @@ public function getAggregations() * well as how to combine the retrieved time series together (such as * when aggregating multiple streams on each resource to a single * stream for each resource or when aggregating streams across all - * members of a group of resrouces). Multiple aggregations + * members of a group of resources). Multiple aggregations * are applied in the order specified. * This field is similar to the one in the [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). @@ -203,25 +205,37 @@ public function setAggregations($var) /** * The amount of time that a time series must fail to report new - * data to be considered failing. Currently, only values that - * are a multiple of a minute--e.g. 60, 120, or 300 - * seconds--are supported. If an invalid value is given, an + * data to be considered failing. The minimum value of this field + * is 120 seconds. Larger values that are a multiple of a + * minute--for example, 240 or 300 seconds--are supported. + * If an invalid value is given, an * error will be returned. The `Duration.nanos` field is * ignored. * * Generated from protobuf field .google.protobuf.Duration duration = 2; - * @return \Google\Protobuf\Duration + * @return \Google\Protobuf\Duration|null */ public function getDuration() { return $this->duration; } + public function hasDuration() + { + return isset($this->duration); + } + + public function clearDuration() + { + unset($this->duration); + } + /** * The amount of time that a time series must fail to report new - * data to be considered failing. Currently, only values that - * are a multiple of a minute--e.g. 60, 120, or 300 - * seconds--are supported. If an invalid value is given, an + * data to be considered failing. The minimum value of this field + * is 120 seconds. Larger values that are a multiple of a + * minute--for example, 240 or 300 seconds--are supported. + * If an invalid value is given, an * error will be returned. The `Duration.nanos` field is * ignored. * @@ -244,13 +258,23 @@ public function setDuration($var) * time series that have been identified by `filter` and `aggregations`. * * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.Trigger trigger = 3; - * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger|null */ public function getTrigger() { return $this->trigger; } + public function hasTrigger() + { + return isset($this->trigger); + } + + public function clearTrigger() + { + unset($this->trigger); + } + /** * The number/percent of time series for which the comparison must hold * in order for the condition to trigger. If unspecified, then the @@ -263,7 +287,7 @@ public function getTrigger() */ public function setTrigger($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_Trigger::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger::class); $this->trigger = $var; return $this; diff --git a/Monitoring/src/V3/AlertPolicy/Condition/MetricThreshold.php b/Monitoring/src/V3/AlertPolicy/Condition/MetricThreshold.php index cecfbac36fe..0cd2af84df2 100644 --- a/Monitoring/src/V3/AlertPolicy/Condition/MetricThreshold.php +++ b/Monitoring/src/V3/AlertPolicy/Condition/MetricThreshold.php @@ -17,17 +17,17 @@ class MetricThreshold extends \Google\Protobuf\Internal\Message { /** - * A [filter](https://cloud.google.com/monitoring/api/v3/filters) that + * Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that * identifies which time series should be compared with the threshold. * The filter is similar to the one that is specified in the * [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) * (that call is useful to verify the time series that will be retrieved / - * processed) and must specify the metric type and optionally may contain - * restrictions on resource type, resource labels, and metric labels. - * This field may not exceed 2048 Unicode characters in length. + * processed). The filter must specify the metric type and the resource + * type. Optionally, it can specify resource labels and metric labels. + * This field must not exceed 2048 Unicode characters in length. * - * Generated from protobuf field string filter = 2; + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = REQUIRED]; */ private $filter = ''; /** @@ -35,7 +35,7 @@ class MetricThreshold extends \Google\Protobuf\Internal\Message * well as how to combine the retrieved time series together (such as * when aggregating multiple streams on each resource to a single * stream for each resource or when aggregating streams across all - * members of a group of resrouces). Multiple aggregations + * members of a group of resources). Multiple aggregations * are applied in the order specified. * This field is similar to the one in the [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). @@ -122,21 +122,21 @@ class MetricThreshold extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $filter - * A [filter](https://cloud.google.com/monitoring/api/v3/filters) that + * Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that * identifies which time series should be compared with the threshold. * The filter is similar to the one that is specified in the * [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) * (that call is useful to verify the time series that will be retrieved / - * processed) and must specify the metric type and optionally may contain - * restrictions on resource type, resource labels, and metric labels. - * This field may not exceed 2048 Unicode characters in length. + * processed). The filter must specify the metric type and the resource + * type. Optionally, it can specify resource labels and metric labels. + * This field must not exceed 2048 Unicode characters in length. * @type \Google\Cloud\Monitoring\V3\Aggregation[]|\Google\Protobuf\Internal\RepeatedField $aggregations * Specifies the alignment of data points in individual time series as * well as how to combine the retrieved time series together (such as * when aggregating multiple streams on each resource to a single * stream for each resource or when aggregating streams across all - * members of a group of resrouces). Multiple aggregations + * members of a group of resources). Multiple aggregations * are applied in the order specified. * This field is similar to the one in the [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). @@ -195,17 +195,17 @@ public function __construct($data = NULL) { } /** - * A [filter](https://cloud.google.com/monitoring/api/v3/filters) that + * Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that * identifies which time series should be compared with the threshold. * The filter is similar to the one that is specified in the * [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) * (that call is useful to verify the time series that will be retrieved / - * processed) and must specify the metric type and optionally may contain - * restrictions on resource type, resource labels, and metric labels. - * This field may not exceed 2048 Unicode characters in length. + * processed). The filter must specify the metric type and the resource + * type. Optionally, it can specify resource labels and metric labels. + * This field must not exceed 2048 Unicode characters in length. * - * Generated from protobuf field string filter = 2; + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getFilter() @@ -214,17 +214,17 @@ public function getFilter() } /** - * A [filter](https://cloud.google.com/monitoring/api/v3/filters) that + * Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that * identifies which time series should be compared with the threshold. * The filter is similar to the one that is specified in the * [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list) * (that call is useful to verify the time series that will be retrieved / - * processed) and must specify the metric type and optionally may contain - * restrictions on resource type, resource labels, and metric labels. - * This field may not exceed 2048 Unicode characters in length. + * processed). The filter must specify the metric type and the resource + * type. Optionally, it can specify resource labels and metric labels. + * This field must not exceed 2048 Unicode characters in length. * - * Generated from protobuf field string filter = 2; + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -241,7 +241,7 @@ public function setFilter($var) * well as how to combine the retrieved time series together (such as * when aggregating multiple streams on each resource to a single * stream for each resource or when aggregating streams across all - * members of a group of resrouces). Multiple aggregations + * members of a group of resources). Multiple aggregations * are applied in the order specified. * This field is similar to the one in the [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). @@ -261,7 +261,7 @@ public function getAggregations() * well as how to combine the retrieved time series together (such as * when aggregating multiple streams on each resource to a single * stream for each resource or when aggregating streams across all - * members of a group of resrouces). Multiple aggregations + * members of a group of resources). Multiple aggregations * are applied in the order specified. * This field is similar to the one in the [`ListTimeSeries` * request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). @@ -435,13 +435,23 @@ public function setThresholdValue($var) * unhealthy states are detected and alerted on quickly. * * Generated from protobuf field .google.protobuf.Duration duration = 6; - * @return \Google\Protobuf\Duration + * @return \Google\Protobuf\Duration|null */ public function getDuration() { return $this->duration; } + public function hasDuration() + { + return isset($this->duration); + } + + public function clearDuration() + { + unset($this->duration); + } + /** * The amount of time that a time series must violate the * threshold to be considered failing. Currently, only values @@ -475,13 +485,23 @@ public function setDuration($var) * are specified. * * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.Trigger trigger = 7; - * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger|null */ public function getTrigger() { return $this->trigger; } + public function hasTrigger() + { + return isset($this->trigger); + } + + public function clearTrigger() + { + unset($this->trigger); + } + /** * The number/percent of time series for which the comparison must hold * in order for the condition to trigger. If unspecified, then the @@ -496,7 +516,7 @@ public function getTrigger() */ public function setTrigger($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_Trigger::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger::class); $this->trigger = $var; return $this; diff --git a/Monitoring/src/V3/AlertPolicy/Condition/MonitoringQueryLanguageCondition.php b/Monitoring/src/V3/AlertPolicy/Condition/MonitoringQueryLanguageCondition.php new file mode 100644 index 00000000000..0bbd1dd0729 --- /dev/null +++ b/Monitoring/src/V3/AlertPolicy/Condition/MonitoringQueryLanguageCondition.php @@ -0,0 +1,219 @@ +google.monitoring.v3.AlertPolicy.Condition.MonitoringQueryLanguageCondition + */ +class MonitoringQueryLanguageCondition extends \Google\Protobuf\Internal\Message +{ + /** + * [Monitoring Query Language](https://cloud.google.com/monitoring/mql) + * query that outputs a boolean stream. + * + * Generated from protobuf field string query = 1; + */ + private $query = ''; + /** + * The amount of time that a time series must violate the + * threshold to be considered failing. Currently, only values + * that are a multiple of a minute--e.g., 0, 60, 120, or 300 + * seconds--are supported. If an invalid value is given, an + * error will be returned. When choosing a duration, it is useful to + * keep in mind the frequency of the underlying time series data + * (which may also be affected by any alignments specified in the + * `aggregations` field); a good duration is long enough so that a single + * outlier does not generate spurious alerts, but short enough that + * unhealthy states are detected and alerted on quickly. + * + * Generated from protobuf field .google.protobuf.Duration duration = 2; + */ + private $duration = null; + /** + * The number/percent of time series for which the comparison must hold + * in order for the condition to trigger. If unspecified, then the + * condition will trigger if the comparison is true for any of the + * time series that have been identified by `filter` and `aggregations`, + * or by the ratio, if `denominator_filter` and `denominator_aggregations` + * are specified. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.Trigger trigger = 3; + */ + private $trigger = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $query + * [Monitoring Query Language](https://cloud.google.com/monitoring/mql) + * query that outputs a boolean stream. + * @type \Google\Protobuf\Duration $duration + * The amount of time that a time series must violate the + * threshold to be considered failing. Currently, only values + * that are a multiple of a minute--e.g., 0, 60, 120, or 300 + * seconds--are supported. If an invalid value is given, an + * error will be returned. When choosing a duration, it is useful to + * keep in mind the frequency of the underlying time series data + * (which may also be affected by any alignments specified in the + * `aggregations` field); a good duration is long enough so that a single + * outlier does not generate spurious alerts, but short enough that + * unhealthy states are detected and alerted on quickly. + * @type \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger $trigger + * The number/percent of time series for which the comparison must hold + * in order for the condition to trigger. If unspecified, then the + * condition will trigger if the comparison is true for any of the + * time series that have been identified by `filter` and `aggregations`, + * or by the ratio, if `denominator_filter` and `denominator_aggregations` + * are specified. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Monitoring\V3\Alert::initOnce(); + parent::__construct($data); + } + + /** + * [Monitoring Query Language](https://cloud.google.com/monitoring/mql) + * query that outputs a boolean stream. + * + * Generated from protobuf field string query = 1; + * @return string + */ + public function getQuery() + { + return $this->query; + } + + /** + * [Monitoring Query Language](https://cloud.google.com/monitoring/mql) + * query that outputs a boolean stream. + * + * Generated from protobuf field string query = 1; + * @param string $var + * @return $this + */ + public function setQuery($var) + { + GPBUtil::checkString($var, True); + $this->query = $var; + + return $this; + } + + /** + * The amount of time that a time series must violate the + * threshold to be considered failing. Currently, only values + * that are a multiple of a minute--e.g., 0, 60, 120, or 300 + * seconds--are supported. If an invalid value is given, an + * error will be returned. When choosing a duration, it is useful to + * keep in mind the frequency of the underlying time series data + * (which may also be affected by any alignments specified in the + * `aggregations` field); a good duration is long enough so that a single + * outlier does not generate spurious alerts, but short enough that + * unhealthy states are detected and alerted on quickly. + * + * Generated from protobuf field .google.protobuf.Duration duration = 2; + * @return \Google\Protobuf\Duration|null + */ + public function getDuration() + { + return $this->duration; + } + + public function hasDuration() + { + return isset($this->duration); + } + + public function clearDuration() + { + unset($this->duration); + } + + /** + * The amount of time that a time series must violate the + * threshold to be considered failing. Currently, only values + * that are a multiple of a minute--e.g., 0, 60, 120, or 300 + * seconds--are supported. If an invalid value is given, an + * error will be returned. When choosing a duration, it is useful to + * keep in mind the frequency of the underlying time series data + * (which may also be affected by any alignments specified in the + * `aggregations` field); a good duration is long enough so that a single + * outlier does not generate spurious alerts, but short enough that + * unhealthy states are detected and alerted on quickly. + * + * Generated from protobuf field .google.protobuf.Duration duration = 2; + * @param \Google\Protobuf\Duration $var + * @return $this + */ + public function setDuration($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class); + $this->duration = $var; + + return $this; + } + + /** + * The number/percent of time series for which the comparison must hold + * in order for the condition to trigger. If unspecified, then the + * condition will trigger if the comparison is true for any of the + * time series that have been identified by `filter` and `aggregations`, + * or by the ratio, if `denominator_filter` and `denominator_aggregations` + * are specified. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.Trigger trigger = 3; + * @return \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger|null + */ + public function getTrigger() + { + return $this->trigger; + } + + public function hasTrigger() + { + return isset($this->trigger); + } + + public function clearTrigger() + { + unset($this->trigger); + } + + /** + * The number/percent of time series for which the comparison must hold + * in order for the condition to trigger. If unspecified, then the + * condition will trigger if the comparison is true for any of the + * time series that have been identified by `filter` and `aggregations`, + * or by the ratio, if `denominator_filter` and `denominator_aggregations` + * are specified. + * + * Generated from protobuf field .google.monitoring.v3.AlertPolicy.Condition.Trigger trigger = 3; + * @param \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger $var + * @return $this + */ + public function setTrigger($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\AlertPolicy\Condition\Trigger::class); + $this->trigger = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(MonitoringQueryLanguageCondition::class, \Google\Cloud\Monitoring\V3\AlertPolicy_Condition_MonitoringQueryLanguageCondition::class); + diff --git a/Monitoring/src/V3/AlertPolicy/Condition/Trigger.php b/Monitoring/src/V3/AlertPolicy/Condition/Trigger.php index 2658eec42c7..8daaca29380 100644 --- a/Monitoring/src/V3/AlertPolicy/Condition/Trigger.php +++ b/Monitoring/src/V3/AlertPolicy/Condition/Trigger.php @@ -49,6 +49,11 @@ public function getCount() return $this->readOneof(1); } + public function hasCount() + { + return $this->hasOneof(1); + } + /** * The absolute number of time series that must fail * the predicate for the condition to be triggered. @@ -77,6 +82,11 @@ public function getPercent() return $this->readOneof(2); } + public function hasPercent() + { + return $this->hasOneof(2); + } + /** * The percentage of time series that must fail the * predicate for the condition to be triggered. diff --git a/Monitoring/src/V3/AlertPolicyServiceGrpcClient.php b/Monitoring/src/V3/AlertPolicyServiceGrpcClient.php index e6d90224c63..8b6aa892549 100644 --- a/Monitoring/src/V3/AlertPolicyServiceGrpcClient.php +++ b/Monitoring/src/V3/AlertPolicyServiceGrpcClient.php @@ -41,10 +41,11 @@ public function __construct($hostname, $opts, $channel = null) { } /** - * Lists the existing alerting policies for the project. + * Lists the existing alerting policies for the workspace. * @param \Google\Cloud\Monitoring\V3\ListAlertPoliciesRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListAlertPolicies(\Google\Cloud\Monitoring\V3\ListAlertPoliciesRequest $argument, $metadata = [], $options = []) { @@ -59,6 +60,7 @@ public function ListAlertPolicies(\Google\Cloud\Monitoring\V3\ListAlertPoliciesR * @param \Google\Cloud\Monitoring\V3\GetAlertPolicyRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetAlertPolicy(\Google\Cloud\Monitoring\V3\GetAlertPolicyRequest $argument, $metadata = [], $options = []) { @@ -73,6 +75,7 @@ public function GetAlertPolicy(\Google\Cloud\Monitoring\V3\GetAlertPolicyRequest * @param \Google\Cloud\Monitoring\V3\CreateAlertPolicyRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateAlertPolicy(\Google\Cloud\Monitoring\V3\CreateAlertPolicyRequest $argument, $metadata = [], $options = []) { @@ -87,6 +90,7 @@ public function CreateAlertPolicy(\Google\Cloud\Monitoring\V3\CreateAlertPolicyR * @param \Google\Cloud\Monitoring\V3\DeleteAlertPolicyRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteAlertPolicy(\Google\Cloud\Monitoring\V3\DeleteAlertPolicyRequest $argument, $metadata = [], $options = []) { @@ -104,6 +108,7 @@ public function DeleteAlertPolicy(\Google\Cloud\Monitoring\V3\DeleteAlertPolicyR * @param \Google\Cloud\Monitoring\V3\UpdateAlertPolicyRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function UpdateAlertPolicy(\Google\Cloud\Monitoring\V3\UpdateAlertPolicyRequest $argument, $metadata = [], $options = []) { diff --git a/Monitoring/src/V3/AlertPolicy_AlertStrategy.php b/Monitoring/src/V3/AlertPolicy_AlertStrategy.php new file mode 100644 index 00000000000..91a1654533a --- /dev/null +++ b/Monitoring/src/V3/AlertPolicy_AlertStrategy.php @@ -0,0 +1,16 @@ +.google.monitoring.v3.BasicSli.AvailabilityCriteria availability = 2; - * @return \Google\Cloud\Monitoring\V3\BasicSli\AvailabilityCriteria + * @return \Google\Cloud\Monitoring\V3\BasicSli\AvailabilityCriteria|null */ public function getAvailability() { return $this->readOneof(2); } + public function hasAvailability() + { + return $this->hasOneof(2); + } + /** * Good service is defined to be the count of requests made to this service * that return successfully. @@ -213,7 +218,7 @@ public function getAvailability() */ public function setAvailability($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\BasicSli_AvailabilityCriteria::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\BasicSli\AvailabilityCriteria::class); $this->writeOneof(2, $var); return $this; @@ -224,13 +229,18 @@ public function setAvailability($var) * that are fast enough with respect to `latency.threshold`. * * Generated from protobuf field .google.monitoring.v3.BasicSli.LatencyCriteria latency = 3; - * @return \Google\Cloud\Monitoring\V3\BasicSli\LatencyCriteria + * @return \Google\Cloud\Monitoring\V3\BasicSli\LatencyCriteria|null */ public function getLatency() { return $this->readOneof(3); } + public function hasLatency() + { + return $this->hasOneof(3); + } + /** * Good service is defined to be the count of requests made to this service * that are fast enough with respect to `latency.threshold`. @@ -241,7 +251,7 @@ public function getLatency() */ public function setLatency($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\BasicSli_LatencyCriteria::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\BasicSli\LatencyCriteria::class); $this->writeOneof(3, $var); return $this; diff --git a/Monitoring/src/V3/BasicSli/LatencyCriteria.php b/Monitoring/src/V3/BasicSli/LatencyCriteria.php index 77208c807d7..9839567a343 100644 --- a/Monitoring/src/V3/BasicSli/LatencyCriteria.php +++ b/Monitoring/src/V3/BasicSli/LatencyCriteria.php @@ -44,13 +44,23 @@ public function __construct($data = NULL) { * that return in no more than `threshold`. * * Generated from protobuf field .google.protobuf.Duration threshold = 3; - * @return \Google\Protobuf\Duration + * @return \Google\Protobuf\Duration|null */ public function getThreshold() { return $this->threshold; } + public function hasThreshold() + { + return isset($this->threshold); + } + + public function clearThreshold() + { + unset($this->threshold); + } + /** * Good service is defined to be the count of requests made to this service * that return in no more than `threshold`. diff --git a/Monitoring/src/V3/CreateAlertPolicyRequest.php b/Monitoring/src/V3/CreateAlertPolicyRequest.php index 7b3bd8e80ed..27ab390813d 100644 --- a/Monitoring/src/V3/CreateAlertPolicyRequest.php +++ b/Monitoring/src/V3/CreateAlertPolicyRequest.php @@ -16,13 +16,15 @@ class CreateAlertPolicyRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project in which to create the alerting policy. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the alerting policy. The format is: * projects/[PROJECT_ID_OR_NUMBER] * Note that this field names the parent container in which the alerting - * policy will be written, not the name of the created policy. The alerting - * policy that is returned will have a name that contains a normalized - * representation of this name as a prefix but adds a suffix of the form - * `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the + * policy will be written, not the name of the created policy. |name| must be + * a host project of a workspace, otherwise INVALID_ARGUMENT error will + * return. The alerting policy that is returned will have a name that contains + * a normalized representation of this name as a prefix but adds a suffix of + * the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the * container. * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -44,13 +46,15 @@ class CreateAlertPolicyRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project in which to create the alerting policy. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the alerting policy. The format is: * projects/[PROJECT_ID_OR_NUMBER] * Note that this field names the parent container in which the alerting - * policy will be written, not the name of the created policy. The alerting - * policy that is returned will have a name that contains a normalized - * representation of this name as a prefix but adds a suffix of the form - * `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the + * policy will be written, not the name of the created policy. |name| must be + * a host project of a workspace, otherwise INVALID_ARGUMENT error will + * return. The alerting policy that is returned will have a name that contains + * a normalized representation of this name as a prefix but adds a suffix of + * the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the * container. * @type \Google\Cloud\Monitoring\V3\AlertPolicy $alert_policy * Required. The requested alerting policy. You should omit the `name` field in this @@ -64,13 +68,15 @@ public function __construct($data = NULL) { } /** - * Required. The project in which to create the alerting policy. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the alerting policy. The format is: * projects/[PROJECT_ID_OR_NUMBER] * Note that this field names the parent container in which the alerting - * policy will be written, not the name of the created policy. The alerting - * policy that is returned will have a name that contains a normalized - * representation of this name as a prefix but adds a suffix of the form - * `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the + * policy will be written, not the name of the created policy. |name| must be + * a host project of a workspace, otherwise INVALID_ARGUMENT error will + * return. The alerting policy that is returned will have a name that contains + * a normalized representation of this name as a prefix but adds a suffix of + * the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the * container. * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -82,13 +88,15 @@ public function getName() } /** - * Required. The project in which to create the alerting policy. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the alerting policy. The format is: * projects/[PROJECT_ID_OR_NUMBER] * Note that this field names the parent container in which the alerting - * policy will be written, not the name of the created policy. The alerting - * policy that is returned will have a name that contains a normalized - * representation of this name as a prefix but adds a suffix of the form - * `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the + * policy will be written, not the name of the created policy. |name| must be + * a host project of a workspace, otherwise INVALID_ARGUMENT error will + * return. The alerting policy that is returned will have a name that contains + * a normalized representation of this name as a prefix but adds a suffix of + * the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the * container. * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -109,13 +117,23 @@ public function setName($var) * a new `[ALERT_POLICY_ID]` value. * * Generated from protobuf field .google.monitoring.v3.AlertPolicy alert_policy = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\AlertPolicy + * @return \Google\Cloud\Monitoring\V3\AlertPolicy|null */ public function getAlertPolicy() { return $this->alert_policy; } + public function hasAlertPolicy() + { + return isset($this->alert_policy); + } + + public function clearAlertPolicy() + { + unset($this->alert_policy); + } + /** * Required. The requested alerting policy. You should omit the `name` field in this * policy. The name will be returned in the new policy, including diff --git a/Monitoring/src/V3/CreateGroupRequest.php b/Monitoring/src/V3/CreateGroupRequest.php index bb54d6e237f..91e79f540cb 100644 --- a/Monitoring/src/V3/CreateGroupRequest.php +++ b/Monitoring/src/V3/CreateGroupRequest.php @@ -16,7 +16,8 @@ class CreateGroupRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project in which to create the group. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the group. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -43,7 +44,8 @@ class CreateGroupRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project in which to create the group. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the group. The format is: * projects/[PROJECT_ID_OR_NUMBER] * @type \Google\Cloud\Monitoring\V3\Group $group * Required. A group definition. It is an error to define the `name` field because @@ -58,7 +60,8 @@ public function __construct($data = NULL) { } /** - * Required. The project in which to create the group. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the group. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -70,7 +73,8 @@ public function getName() } /** - * Required. The project in which to create the group. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the group. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -90,13 +94,23 @@ public function setName($var) * the system assigns the name. * * Generated from protobuf field .google.monitoring.v3.Group group = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\Group + * @return \Google\Cloud\Monitoring\V3\Group|null */ public function getGroup() { return $this->group; } + public function hasGroup() + { + return isset($this->group); + } + + public function clearGroup() + { + unset($this->group); + } + /** * Required. A group definition. It is an error to define the `name` field because * the system assigns the name. diff --git a/Monitoring/src/V3/CreateMetricDescriptorRequest.php b/Monitoring/src/V3/CreateMetricDescriptorRequest.php index 883543d1812..62c0ff860c3 100644 --- a/Monitoring/src/V3/CreateMetricDescriptorRequest.php +++ b/Monitoring/src/V3/CreateMetricDescriptorRequest.php @@ -16,7 +16,9 @@ class CreateMetricDescriptorRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: + * 4 * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -37,7 +39,9 @@ class CreateMetricDescriptorRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: + * 4 * projects/[PROJECT_ID_OR_NUMBER] * @type \Google\Api\MetricDescriptor $metric_descriptor * Required. The new [custom metric](https://cloud.google.com/monitoring/custom-metrics) @@ -50,7 +54,9 @@ public function __construct($data = NULL) { } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: + * 4 * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -62,7 +68,9 @@ public function getName() } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: + * 4 * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -82,13 +90,23 @@ public function setName($var) * descriptor. * * Generated from protobuf field .google.api.MetricDescriptor metric_descriptor = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Api\MetricDescriptor + * @return \Google\Api\MetricDescriptor|null */ public function getMetricDescriptor() { return $this->metric_descriptor; } + public function hasMetricDescriptor() + { + return isset($this->metric_descriptor); + } + + public function clearMetricDescriptor() + { + unset($this->metric_descriptor); + } + /** * Required. The new [custom metric](https://cloud.google.com/monitoring/custom-metrics) * descriptor. diff --git a/Monitoring/src/V3/CreateNotificationChannelRequest.php b/Monitoring/src/V3/CreateNotificationChannelRequest.php index c782956b315..7b8210a133a 100644 --- a/Monitoring/src/V3/CreateNotificationChannelRequest.php +++ b/Monitoring/src/V3/CreateNotificationChannelRequest.php @@ -16,7 +16,8 @@ class CreateNotificationChannelRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * This names the container into which the channel will be * written, this does not name the newly created channel. The resulting @@ -40,7 +41,8 @@ class CreateNotificationChannelRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * This names the container into which the channel will be * written, this does not name the newly created channel. The resulting @@ -56,7 +58,8 @@ public function __construct($data = NULL) { } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * This names the container into which the channel will be * written, this does not name the newly created channel. The resulting @@ -72,7 +75,8 @@ public function getName() } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * This names the container into which the channel will be * written, this does not name the newly created channel. The resulting @@ -95,13 +99,23 @@ public function setName($var) * Required. The definition of the `NotificationChannel` to create. * * Generated from protobuf field .google.monitoring.v3.NotificationChannel notification_channel = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\NotificationChannel + * @return \Google\Cloud\Monitoring\V3\NotificationChannel|null */ public function getNotificationChannel() { return $this->notification_channel; } + public function hasNotificationChannel() + { + return isset($this->notification_channel); + } + + public function clearNotificationChannel() + { + unset($this->notification_channel); + } + /** * Required. The definition of the `NotificationChannel` to create. * diff --git a/Monitoring/src/V3/CreateServiceLevelObjectiveRequest.php b/Monitoring/src/V3/CreateServiceLevelObjectiveRequest.php index 17e232e77fb..54576771c14 100644 --- a/Monitoring/src/V3/CreateServiceLevelObjectiveRequest.php +++ b/Monitoring/src/V3/CreateServiceLevelObjectiveRequest.php @@ -127,13 +127,23 @@ public function setServiceLevelObjectiveId($var) * with this name. * * Generated from protobuf field .google.monitoring.v3.ServiceLevelObjective service_level_objective = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\ServiceLevelObjective + * @return \Google\Cloud\Monitoring\V3\ServiceLevelObjective|null */ public function getServiceLevelObjective() { return $this->service_level_objective; } + public function hasServiceLevelObjective() + { + return isset($this->service_level_objective); + } + + public function clearServiceLevelObjective() + { + unset($this->service_level_objective); + } + /** * Required. The `ServiceLevelObjective` to create. * The provided `name` will be respected if no `ServiceLevelObjective` exists diff --git a/Monitoring/src/V3/CreateServiceRequest.php b/Monitoring/src/V3/CreateServiceRequest.php index a5d8a28564a..64941c442af 100644 --- a/Monitoring/src/V3/CreateServiceRequest.php +++ b/Monitoring/src/V3/CreateServiceRequest.php @@ -16,7 +16,8 @@ class CreateServiceRequest extends \Google\Protobuf\Internal\Message { /** - * Required. Resource name of the parent workspace. The format is: + * Required. Resource [name](https://cloud.google.com/monitoring/api/v3#project_name) of + * the parent workspace. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -43,7 +44,8 @@ class CreateServiceRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $parent - * Required. Resource name of the parent workspace. The format is: + * Required. Resource [name](https://cloud.google.com/monitoring/api/v3#project_name) of + * the parent workspace. The format is: * projects/[PROJECT_ID_OR_NUMBER] * @type string $service_id * Optional. The Service id to use for this Service. If omitted, an id will be @@ -58,7 +60,8 @@ public function __construct($data = NULL) { } /** - * Required. Resource name of the parent workspace. The format is: + * Required. Resource [name](https://cloud.google.com/monitoring/api/v3#project_name) of + * the parent workspace. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -70,7 +73,8 @@ public function getParent() } /** - * Required. Resource name of the parent workspace. The format is: + * Required. Resource [name](https://cloud.google.com/monitoring/api/v3#project_name) of + * the parent workspace. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -117,13 +121,23 @@ public function setServiceId($var) * Required. The `Service` to create. * * Generated from protobuf field .google.monitoring.v3.Service service = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\Service + * @return \Google\Cloud\Monitoring\V3\Service|null */ public function getService() { return $this->service; } + public function hasService() + { + return isset($this->service); + } + + public function clearService() + { + unset($this->service); + } + /** * Required. The `Service` to create. * diff --git a/Monitoring/src/V3/CreateTimeSeriesError.php b/Monitoring/src/V3/CreateTimeSeriesError.php index 2eb3a2ebab2..556d57d6608 100644 --- a/Monitoring/src/V3/CreateTimeSeriesError.php +++ b/Monitoring/src/V3/CreateTimeSeriesError.php @@ -19,14 +19,16 @@ class CreateTimeSeriesError extends \Google\Protobuf\Internal\Message * DEPRECATED. Time series ID that resulted in the `status` error. * * Generated from protobuf field .google.monitoring.v3.TimeSeries time_series = 1 [deprecated = true]; + * @deprecated */ - private $time_series = null; + protected $time_series = null; /** * DEPRECATED. The status of the requested write operation for `time_series`. * * Generated from protobuf field .google.rpc.Status status = 2 [deprecated = true]; + * @deprecated */ - private $status = null; + protected $status = null; /** * Constructor. @@ -49,22 +51,38 @@ public function __construct($data = NULL) { * DEPRECATED. Time series ID that resulted in the `status` error. * * Generated from protobuf field .google.monitoring.v3.TimeSeries time_series = 1 [deprecated = true]; - * @return \Google\Cloud\Monitoring\V3\TimeSeries + * @return \Google\Cloud\Monitoring\V3\TimeSeries|null + * @deprecated */ public function getTimeSeries() { + @trigger_error('time_series is deprecated.', E_USER_DEPRECATED); return $this->time_series; } + public function hasTimeSeries() + { + @trigger_error('time_series is deprecated.', E_USER_DEPRECATED); + return isset($this->time_series); + } + + public function clearTimeSeries() + { + @trigger_error('time_series is deprecated.', E_USER_DEPRECATED); + unset($this->time_series); + } + /** * DEPRECATED. Time series ID that resulted in the `status` error. * * Generated from protobuf field .google.monitoring.v3.TimeSeries time_series = 1 [deprecated = true]; * @param \Google\Cloud\Monitoring\V3\TimeSeries $var * @return $this + * @deprecated */ public function setTimeSeries($var) { + @trigger_error('time_series is deprecated.', E_USER_DEPRECATED); GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\TimeSeries::class); $this->time_series = $var; @@ -75,22 +93,38 @@ public function setTimeSeries($var) * DEPRECATED. The status of the requested write operation for `time_series`. * * Generated from protobuf field .google.rpc.Status status = 2 [deprecated = true]; - * @return \Google\Rpc\Status + * @return \Google\Rpc\Status|null + * @deprecated */ public function getStatus() { + @trigger_error('status is deprecated.', E_USER_DEPRECATED); return $this->status; } + public function hasStatus() + { + @trigger_error('status is deprecated.', E_USER_DEPRECATED); + return isset($this->status); + } + + public function clearStatus() + { + @trigger_error('status is deprecated.', E_USER_DEPRECATED); + unset($this->status); + } + /** * DEPRECATED. The status of the requested write operation for `time_series`. * * Generated from protobuf field .google.rpc.Status status = 2 [deprecated = true]; * @param \Google\Rpc\Status $var * @return $this + * @deprecated */ public function setStatus($var) { + @trigger_error('status is deprecated.', E_USER_DEPRECATED); GPBUtil::checkMessage($var, \Google\Rpc\Status::class); $this->status = $var; diff --git a/Monitoring/src/V3/CreateTimeSeriesRequest.php b/Monitoring/src/V3/CreateTimeSeriesRequest.php index e0fcc158991..21f57467a90 100644 --- a/Monitoring/src/V3/CreateTimeSeriesRequest.php +++ b/Monitoring/src/V3/CreateTimeSeriesRequest.php @@ -16,7 +16,8 @@ class CreateTimeSeriesRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -41,7 +42,8 @@ class CreateTimeSeriesRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * @type \Google\Cloud\Monitoring\V3\TimeSeries[]|\Google\Protobuf\Internal\RepeatedField $time_series * Required. The new data to be added to a list of time series. @@ -58,7 +60,8 @@ public function __construct($data = NULL) { } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -70,7 +73,8 @@ public function getName() } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { diff --git a/Monitoring/src/V3/CreateTimeSeriesSummary/Error.php b/Monitoring/src/V3/CreateTimeSeriesSummary/Error.php index 4e8e43650e0..e0a196e5d67 100644 --- a/Monitoring/src/V3/CreateTimeSeriesSummary/Error.php +++ b/Monitoring/src/V3/CreateTimeSeriesSummary/Error.php @@ -49,13 +49,23 @@ public function __construct($data = NULL) { * The status of the requested write operation. * * Generated from protobuf field .google.rpc.Status status = 1; - * @return \Google\Rpc\Status + * @return \Google\Rpc\Status|null */ public function getStatus() { return $this->status; } + public function hasStatus() + { + return isset($this->status); + } + + public function clearStatus() + { + unset($this->status); + } + /** * The status of the requested write operation. * diff --git a/Monitoring/src/V3/CreateUptimeCheckConfigRequest.php b/Monitoring/src/V3/CreateUptimeCheckConfigRequest.php index 4e379935aac..eb4b513fe88 100644 --- a/Monitoring/src/V3/CreateUptimeCheckConfigRequest.php +++ b/Monitoring/src/V3/CreateUptimeCheckConfigRequest.php @@ -16,7 +16,8 @@ class CreateUptimeCheckConfigRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project in which to create the Uptime check. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the Uptime check. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -36,7 +37,8 @@ class CreateUptimeCheckConfigRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $parent - * Required. The project in which to create the Uptime check. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the Uptime check. The format is: * projects/[PROJECT_ID_OR_NUMBER] * @type \Google\Cloud\Monitoring\V3\UptimeCheckConfig $uptime_check_config * Required. The new Uptime check configuration. @@ -48,7 +50,8 @@ public function __construct($data = NULL) { } /** - * Required. The project in which to create the Uptime check. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the Uptime check. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -60,7 +63,8 @@ public function getParent() } /** - * Required. The project in which to create the Uptime check. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the Uptime check. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -79,13 +83,23 @@ public function setParent($var) * Required. The new Uptime check configuration. * * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig uptime_check_config = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig|null */ public function getUptimeCheckConfig() { return $this->uptime_check_config; } + public function hasUptimeCheckConfig() + { + return isset($this->uptime_check_config); + } + + public function clearUptimeCheckConfig() + { + unset($this->uptime_check_config); + } + /** * Required. The new Uptime check configuration. * diff --git a/Monitoring/src/V3/DistributionCut.php b/Monitoring/src/V3/DistributionCut.php index f5cc9ad5c8b..422f173d600 100644 --- a/Monitoring/src/V3/DistributionCut.php +++ b/Monitoring/src/V3/DistributionCut.php @@ -12,8 +12,8 @@ * A `DistributionCut` defines a `TimeSeries` and thresholds used for measuring * good service and total service. The `TimeSeries` must have `ValueType = * DISTRIBUTION` and `MetricKind = DELTA` or `MetricKind = CUMULATIVE`. The - * computed `good_service` will be the count of values x in the `Distribution` - * such that `range.min <= x < range.max`. + * computed `good_service` will be the estimated count of values in the + * `Distribution` that fall within the specified `min` and `max`. * * Generated from protobuf message google.monitoring.v3.DistributionCut */ @@ -90,13 +90,23 @@ public function setDistributionFilter($var) * an infinite value. * * Generated from protobuf field .google.monitoring.v3.Range range = 5; - * @return \Google\Cloud\Monitoring\V3\Range + * @return \Google\Cloud\Monitoring\V3\Range|null */ public function getRange() { return $this->range; } + public function hasRange() + { + return isset($this->range); + } + + public function clearRange() + { + unset($this->range); + } + /** * Range of values considered "good." For a one-sided range, set one bound to * an infinite value. diff --git a/Monitoring/src/V3/DroppedLabels.php b/Monitoring/src/V3/DroppedLabels.php index cd7f1740d22..4fb73d3bdd7 100644 --- a/Monitoring/src/V3/DroppedLabels.php +++ b/Monitoring/src/V3/DroppedLabels.php @@ -9,15 +9,16 @@ use Google\Protobuf\Internal\GPBUtil; /** - * A set of (label, value) pairs which were dropped during aggregation, attached - * to google.api.Distribution.Exemplars in google.api.Distribution values during - * aggregation. - * These values are used in combination with the label values that remain on the - * aggregated Distribution timeseries to construct the full label set for the - * exemplar values. The resulting full label set may be used to identify the - * specific task/job/instance (for example) which may be contributing to a - * long-tail, while allowing the storage savings of only storing aggregated - * distribution values for a large group. + * A set of (label, value) pairs that were removed from a Distribution + * time series during aggregation and then added as an attachment to a + * Distribution.Exemplar. + * The full label set for the exemplars is constructed by using the dropped + * pairs in combination with the label values that remain on the aggregated + * Distribution time series. The constructed full label set can be used to + * identify the specific entity, such as the instance or job, which might be + * contributing to a long-tail. However, with dropped labels, the storage + * requirements are reduced because only the aggregated distribution values for + * a large group of time series are stored. * Note that there are no guarantees on ordering of the labels from * exemplar-to-exemplar and from distribution-to-distribution in the same * stream, and there may be duplicates. It is up to clients to resolve any diff --git a/Monitoring/src/V3/Gapic/AlertPolicyServiceGapicClient.php b/Monitoring/src/V3/Gapic/AlertPolicyServiceGapicClient.php index db5367d1a8a..4151cbae42b 100644 --- a/Monitoring/src/V3/Gapic/AlertPolicyServiceGapicClient.php +++ b/Monitoring/src/V3/Gapic/AlertPolicyServiceGapicClient.php @@ -17,9 +17,9 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/alert_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/alert_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3\Gapic; @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; + use Google\ApiCore\PathTemplate; use Google\ApiCore\RequestParamsHeaderDescriptor; use Google\ApiCore\RetrySettings; @@ -60,32 +61,18 @@ * ``` * $alertPolicyServiceClient = new Google\Cloud\Monitoring\V3\AlertPolicyServiceClient(); * try { - * $formattedName = $alertPolicyServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $alertPolicyServiceClient->listAlertPolicies($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $alertPolicyServiceClient->listAlertPolicies($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $name = 'name'; + * $alertPolicy = new Google\Cloud\Monitoring\V3\AlertPolicy(); + * $response = $alertPolicyServiceClient->createAlertPolicy($name, $alertPolicy); * } finally { * $alertPolicyServiceClient->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. + * 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. */ class AlertPolicyServiceGapicClient { @@ -118,27 +105,32 @@ class AlertPolicyServiceGapicClient 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/monitoring', 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', ]; + private static $alertPolicyNameTemplate; - private static $alertPolicyConditionNameTemplate; - private static $projectNameTemplate; + + private static $folderAlertPolicyNameTemplate; + + private static $organizationAlertPolicyNameTemplate; + + private static $projectAlertPolicyNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() { return [ 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__.'/../resources/alert_policy_service_client_config.json', - 'descriptorsConfigPath' => __DIR__.'/../resources/alert_policy_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__.'/../resources/alert_policy_service_grpc_config.json', + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/alert_policy_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/alert_policy_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/alert_policy_service_grpc_config.json', 'credentialsConfig' => [ - 'scopes' => self::$serviceScopes, + 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__.'/../resources/alert_policy_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/alert_policy_service_rest_client_config.php', ], ], ]; @@ -146,38 +138,48 @@ private static function getClientDefaults() private static function getAlertPolicyNameTemplate() { - if (null == self::$alertPolicyNameTemplate) { + if (self::$alertPolicyNameTemplate == null) { self::$alertPolicyNameTemplate = new PathTemplate('projects/{project}/alertPolicies/{alert_policy}'); } return self::$alertPolicyNameTemplate; } - private static function getAlertPolicyConditionNameTemplate() + private static function getFolderAlertPolicyNameTemplate() { - if (null == self::$alertPolicyConditionNameTemplate) { - self::$alertPolicyConditionNameTemplate = new PathTemplate('projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}'); + if (self::$folderAlertPolicyNameTemplate == null) { + self::$folderAlertPolicyNameTemplate = new PathTemplate('folders/{folder}/alertPolicies/{alert_policy}'); } - return self::$alertPolicyConditionNameTemplate; + return self::$folderAlertPolicyNameTemplate; } - private static function getProjectNameTemplate() + private static function getOrganizationAlertPolicyNameTemplate() { - if (null == self::$projectNameTemplate) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); + if (self::$organizationAlertPolicyNameTemplate == null) { + self::$organizationAlertPolicyNameTemplate = new PathTemplate('organizations/{organization}/alertPolicies/{alert_policy}'); } - return self::$projectNameTemplate; + return self::$organizationAlertPolicyNameTemplate; + } + + private static function getProjectAlertPolicyNameTemplate() + { + if (self::$projectAlertPolicyNameTemplate == null) { + self::$projectAlertPolicyNameTemplate = new PathTemplate('projects/{project}/alertPolicies/{alert_policy}'); + } + + return self::$projectAlertPolicyNameTemplate; } private static function getPathTemplateMap() { - if (null == self::$pathTemplateMap) { + if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ 'alertPolicy' => self::getAlertPolicyNameTemplate(), - 'alertPolicyCondition' => self::getAlertPolicyConditionNameTemplate(), - 'project' => self::getProjectNameTemplate(), + 'folderAlertPolicy' => self::getFolderAlertPolicyNameTemplate(), + 'organizationAlertPolicy' => self::getOrganizationAlertPolicyNameTemplate(), + 'projectAlertPolicy' => self::getProjectAlertPolicyNameTemplate(), ]; } @@ -185,8 +187,8 @@ private static function getPathTemplateMap() } /** - * Formats a string containing the fully-qualified path to represent - * a alert_policy resource. + * Formats a string containing the fully-qualified path to represent a alert_policy + * resource. * * @param string $project * @param string $alertPolicy @@ -202,36 +204,53 @@ public static function alertPolicyName($project, $alertPolicy) } /** - * Formats a string containing the fully-qualified path to represent - * a alert_policy_condition resource. + * Formats a string containing the fully-qualified path to represent a + * folder_alert_policy resource. * - * @param string $project + * @param string $folder * @param string $alertPolicy - * @param string $condition * - * @return string The formatted alert_policy_condition resource. + * @return string The formatted folder_alert_policy resource. */ - public static function alertPolicyConditionName($project, $alertPolicy, $condition) + public static function folderAlertPolicyName($folder, $alertPolicy) { - return self::getAlertPolicyConditionNameTemplate()->render([ - 'project' => $project, + return self::getFolderAlertPolicyNameTemplate()->render([ + 'folder' => $folder, + 'alert_policy' => $alertPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_alert_policy resource. + * + * @param string $organization + * @param string $alertPolicy + * + * @return string The formatted organization_alert_policy resource. + */ + public static function organizationAlertPolicyName($organization, $alertPolicy) + { + return self::getOrganizationAlertPolicyNameTemplate()->render([ + 'organization' => $organization, 'alert_policy' => $alertPolicy, - 'condition' => $condition, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a project resource. + * Formats a string containing the fully-qualified path to represent a + * project_alert_policy resource. * * @param string $project + * @param string $alertPolicy * - * @return string The formatted project resource. + * @return string The formatted project_alert_policy resource. */ - public static function projectName($project) + public static function projectAlertPolicyName($project, $alertPolicy) { - return self::getProjectNameTemplate()->render([ + return self::getProjectAlertPolicyNameTemplate()->render([ 'project' => $project, + 'alert_policy' => $alertPolicy, ]); } @@ -240,13 +259,15 @@ public static function projectName($project) * The following name formats are supported: * Template: Pattern * - alertPolicy: projects/{project}/alertPolicies/{alert_policy} - * - alertPolicyCondition: projects/{project}/alertPolicies/{alert_policy}/conditions/{condition} - * - project: projects/{project}. + * - folderAlertPolicy: folders/{folder}/alertPolicies/{alert_policy} + * - organizationAlertPolicy: organizations/{organization}/alertPolicies/{alert_policy} + * - projectAlertPolicy: projects/{project}/alertPolicies/{alert_policy} * - * 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. + * 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 @@ -258,7 +279,6 @@ public static function projectName($project) 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"); @@ -274,6 +294,7 @@ public static function parseName($formattedName, $template = null) // Swallow the exception to continue trying other path templates } } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); } @@ -281,7 +302,7 @@ public static function parseName($formattedName, $template = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress * **Deprecated**. This option will be removed in a future major release. Please @@ -298,35 +319,38 @@ public static function parseName($formattedName, $template = null) * {@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()}. + * 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. + * 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. + * 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 + * $serviceAddress 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' => [...] + * '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 @@ -338,274 +362,242 @@ public function __construct(array $options = []) } /** - * Lists the existing alerting policies for the project. + * Creates a new alerting policy. * * Sample code: * ``` * $alertPolicyServiceClient = new Google\Cloud\Monitoring\V3\AlertPolicyServiceClient(); * try { - * $formattedName = $alertPolicyServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $alertPolicyServiceClient->listAlertPolicies($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $alertPolicyServiceClient->listAlertPolicies($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $name = 'name'; + * $alertPolicy = new Google\Cloud\Monitoring\V3\AlertPolicy(); + * $response = $alertPolicyServiceClient->createAlertPolicy($name, $alertPolicy); * } finally { * $alertPolicyServiceClient->close(); * } * ``` * - * @param string $name Required. The project whose alert policies are to be listed. The format is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the alerting policy. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] + * projects/[PROJECT_ID_OR_NUMBER] * - * Note that this field names the parent container in which the alerting - * policies to be listed are stored. To retrieve a single alerting policy - * by name, use the - * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy] - * operation, instead. - * @param array $optionalArgs { - * Optional. - * - * @type string $filter - * If provided, this field specifies the criteria that must be met by - * alert policies to be included in the response. - * - * For more details, see [sorting and - * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). - * @type string $orderBy - * A comma-separated list of fields by which to sort the result. Supports - * the same set of field references as the `filter` field. Entries can be - * prefixed with a minus sign to sort by the field in descending order. + * Note that this field names the parent container in which the alerting + * policy will be written, not the name of the created policy. |name| must be + * a host project of a workspace, otherwise INVALID_ARGUMENT error will + * return. The alerting policy that is returned will have a name that contains + * a normalized representation of this name as a prefix but adds a suffix of + * the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the + * container. + * @param AlertPolicy $alertPolicy Required. The requested alerting policy. You should omit the `name` field in this + * policy. The name will be returned in the new policy, including + * a new `[ALERT_POLICY_ID]` value. + * @param array $optionalArgs { + * Optional. * - * For more details, see [sorting and - * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). - * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse + * @return \Google\Cloud\Monitoring\V3\AlertPolicy * * @throws ApiException if the remote call fails */ - public function listAlertPolicies($name, array $optionalArgs = []) + public function createAlertPolicy($name, $alertPolicy, array $optionalArgs = []) { - $request = new ListAlertPoliciesRequest(); + $request = new CreateAlertPolicyRequest(); + $requestParamHeaders = []; $request->setName($name); - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListAlertPolicies', - $optionalArgs, - ListAlertPoliciesResponse::class, - $request - ); + $request->setAlertPolicy($alertPolicy); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateAlertPolicy', AlertPolicy::class, $optionalArgs, $request)->wait(); } /** - * Gets a single alerting policy. + * Deletes an alerting policy. * * Sample code: * ``` * $alertPolicyServiceClient = new Google\Cloud\Monitoring\V3\AlertPolicyServiceClient(); * try { * $formattedName = $alertPolicyServiceClient->alertPolicyName('[PROJECT]', '[ALERT_POLICY]'); - * $response = $alertPolicyServiceClient->getAlertPolicy($formattedName); + * $alertPolicyServiceClient->deleteAlertPolicy($formattedName); * } finally { * $alertPolicyServiceClient->close(); * } * ``` * - * @param string $name Required. The alerting policy to retrieve. The format is: + * @param string $name Required. The alerting policy to delete. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] * - * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] - * @param array $optionalArgs { - * Optional. + * For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\AlertPolicy - * * @throws ApiException if the remote call fails */ - public function getAlertPolicy($name, array $optionalArgs = []) + public function deleteAlertPolicy($name, array $optionalArgs = []) { - $request = new GetAlertPolicyRequest(); + $request = new DeleteAlertPolicyRequest(); + $requestParamHeaders = []; $request->setName($name); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetAlertPolicy', - AlertPolicy::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteAlertPolicy', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * Creates a new alerting policy. + * Gets a single alerting policy. * * Sample code: * ``` * $alertPolicyServiceClient = new Google\Cloud\Monitoring\V3\AlertPolicyServiceClient(); * try { - * $formattedName = $alertPolicyServiceClient->projectName('[PROJECT]'); - * $alertPolicy = new Google\Cloud\Monitoring\V3\AlertPolicy(); - * $response = $alertPolicyServiceClient->createAlertPolicy($formattedName, $alertPolicy); + * $formattedName = $alertPolicyServiceClient->alertPolicyName('[PROJECT]', '[ALERT_POLICY]'); + * $response = $alertPolicyServiceClient->getAlertPolicy($formattedName); * } finally { * $alertPolicyServiceClient->close(); * } * ``` * - * @param string $name Required. The project in which to create the alerting policy. The format is: - * - * projects/[PROJECT_ID_OR_NUMBER] + * @param string $name Required. The alerting policy to retrieve. The format is: * - * Note that this field names the parent container in which the alerting - * policy will be written, not the name of the created policy. The alerting - * policy that is returned will have a name that contains a normalized - * representation of this name as a prefix but adds a suffix of the form - * `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the - * container. - * @param AlertPolicy $alertPolicy Required. The requested alerting policy. You should omit the `name` field in this - * policy. The name will be returned in the new policy, including - * a new `[ALERT_POLICY_ID]` value. - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Cloud\Monitoring\V3\AlertPolicy * * @throws ApiException if the remote call fails */ - public function createAlertPolicy($name, $alertPolicy, array $optionalArgs = []) + public function getAlertPolicy($name, array $optionalArgs = []) { - $request = new CreateAlertPolicyRequest(); + $request = new GetAlertPolicyRequest(); + $requestParamHeaders = []; $request->setName($name); - $request->setAlertPolicy($alertPolicy); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'CreateAlertPolicy', - AlertPolicy::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetAlertPolicy', AlertPolicy::class, $optionalArgs, $request)->wait(); } /** - * Deletes an alerting policy. + * Lists the existing alerting policies for the workspace. * * Sample code: * ``` * $alertPolicyServiceClient = new Google\Cloud\Monitoring\V3\AlertPolicyServiceClient(); * try { - * $formattedName = $alertPolicyServiceClient->alertPolicyName('[PROJECT]', '[ALERT_POLICY]'); - * $alertPolicyServiceClient->deleteAlertPolicy($formattedName); + * $name = 'name'; + * // Iterate over pages of elements + * $pagedResponse = $alertPolicyServiceClient->listAlertPolicies($name); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $alertPolicyServiceClient->listAlertPolicies($name); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $alertPolicyServiceClient->close(); * } * ``` * - * @param string $name Required. The alerting policy to delete. The format is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose alert policies are to be listed. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] + * projects/[PROJECT_ID_OR_NUMBER] * - * For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. - * @param array $optionalArgs { - * Optional. + * Note that this field names the parent container in which the alerting + * policies to be listed are stored. To retrieve a single alerting policy + * by name, use the + * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy] + * operation, instead. + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * If provided, this field specifies the criteria that must be met by + * alert policies to be included in the response. * + * For more details, see [sorting and + * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). + * @type string $orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of field references as the `filter` field. Entries can be + * prefixed with a minus sign to sort by the field in descending order. + * + * For more details, see [sorting and + * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). + * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * + * @return \Google\ApiCore\PagedListResponse + * * @throws ApiException if the remote call fails */ - public function deleteAlertPolicy($name, array $optionalArgs = []) + public function listAlertPolicies($name, array $optionalArgs = []) { - $request = new DeleteAlertPolicyRequest(); + $request = new ListAlertPoliciesRequest(); + $requestParamHeaders = []; $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'DeleteAlertPolicy', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + if (isset($optionalArgs['orderBy'])) { + $request->setOrderBy($optionalArgs['orderBy']); + } + + 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('ListAlertPolicies', $optionalArgs, ListAlertPoliciesResponse::class, $request); } /** @@ -630,35 +622,35 @@ public function deleteAlertPolicy($name, array $optionalArgs = []) * If `update_mask` is not empty, any fields in this policy that are * not in `update_mask` are ignored. * @param array $optionalArgs { - * Optional. + * Optional. * * @type FieldMask $updateMask - * Optional. A list of alerting policy field names. If this field is not - * empty, each listed field in the existing alerting policy is set to the - * value of the corresponding field in the supplied policy (`alert_policy`), - * or to the field's default value if the field is not in the supplied - * alerting policy. Fields not listed retain their previous value. - * - * Examples of valid field masks include `display_name`, `documentation`, - * `documentation.content`, `documentation.mime_type`, `user_labels`, - * `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc. - * - * If this field is empty, then the supplied alerting policy replaces the - * existing policy. It is the same as deleting the existing policy and - * adding the supplied policy, except for the following: - * - * + The new policy will have the same `[ALERT_POLICY_ID]` as the former - * policy. This gives you continuity with the former policy in your - * notifications and incidents. - * + Conditions in the new policy will keep their former `[CONDITION_ID]` if - * the supplied condition includes the `name` field with that - * `[CONDITION_ID]`. If the supplied condition omits the `name` field, - * then a new `[CONDITION_ID]` is created. + * Optional. A list of alerting policy field names. If this field is not + * empty, each listed field in the existing alerting policy is set to the + * value of the corresponding field in the supplied policy (`alert_policy`), + * or to the field's default value if the field is not in the supplied + * alerting policy. Fields not listed retain their previous value. + * + * Examples of valid field masks include `display_name`, `documentation`, + * `documentation.content`, `documentation.mime_type`, `user_labels`, + * `user_label.nameofkey`, `enabled`, `conditions`, `combiner`, etc. + * + * If this field is empty, then the supplied alerting policy replaces the + * existing policy. It is the same as deleting the existing policy and + * adding the supplied policy, except for the following: + * + * + The new policy will have the same `[ALERT_POLICY_ID]` as the former + * policy. This gives you continuity with the former policy in your + * notifications and incidents. + * + Conditions in the new policy will keep their former `[CONDITION_ID]` if + * the supplied condition includes the `name` field with that + * `[CONDITION_ID]`. If the supplied condition omits the `name` field, + * then a new `[CONDITION_ID]` is created. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Cloud\Monitoring\V3\AlertPolicy @@ -668,23 +660,15 @@ public function deleteAlertPolicy($name, array $optionalArgs = []) public function updateAlertPolicy($alertPolicy, array $optionalArgs = []) { $request = new UpdateAlertPolicyRequest(); + $requestParamHeaders = []; $request->setAlertPolicy($alertPolicy); + $requestParamHeaders['alert_policy.name'] = $alertPolicy->getName(); if (isset($optionalArgs['updateMask'])) { $request->setUpdateMask($optionalArgs['updateMask']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'alert_policy.name' => $request->getAlertPolicy()->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'UpdateAlertPolicy', - AlertPolicy::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateAlertPolicy', AlertPolicy::class, $optionalArgs, $request)->wait(); } } diff --git a/Monitoring/src/V3/Gapic/GroupServiceGapicClient.php b/Monitoring/src/V3/Gapic/GroupServiceGapicClient.php index aefe83a01b2..833d05df9d7 100644 --- a/Monitoring/src/V3/Gapic/GroupServiceGapicClient.php +++ b/Monitoring/src/V3/Gapic/GroupServiceGapicClient.php @@ -17,9 +17,9 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/group_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/group_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3\Gapic; @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; + use Google\ApiCore\PathTemplate; use Google\ApiCore\RequestParamsHeaderDescriptor; use Google\ApiCore\RetrySettings; @@ -47,7 +48,7 @@ /** * Service Description: The Group API lets you inspect and manage your - * [groups](https://cloud.google.com#google.monitoring.v3.Group). + * [groups](#google.monitoring.v3.Group). * * A group is a named filter that is used to identify * a collection of monitored resources. Groups are typically used to @@ -65,32 +66,18 @@ * ``` * $groupServiceClient = new Google\Cloud\Monitoring\V3\GroupServiceClient(); * try { - * $formattedName = $groupServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $groupServiceClient->listGroups($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $groupServiceClient->listGroups($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $name = 'name'; + * $group = new Google\Cloud\Monitoring\V3\Group(); + * $response = $groupServiceClient->createGroup($name, $group); * } finally { * $groupServiceClient->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. + * 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. */ class GroupServiceGapicClient { @@ -123,55 +110,81 @@ class GroupServiceGapicClient 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/monitoring', 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', ]; + + private static $folderGroupNameTemplate; + private static $groupNameTemplate; - private static $projectNameTemplate; + + private static $organizationGroupNameTemplate; + + private static $projectGroupNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() { return [ 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__.'/../resources/group_service_client_config.json', - 'descriptorsConfigPath' => __DIR__.'/../resources/group_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__.'/../resources/group_service_grpc_config.json', + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/group_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/group_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/group_service_grpc_config.json', 'credentialsConfig' => [ - 'scopes' => self::$serviceScopes, + 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__.'/../resources/group_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/group_service_rest_client_config.php', ], ], ]; } + private static function getFolderGroupNameTemplate() + { + if (self::$folderGroupNameTemplate == null) { + self::$folderGroupNameTemplate = new PathTemplate('folders/{folder}/groups/{group}'); + } + + return self::$folderGroupNameTemplate; + } + private static function getGroupNameTemplate() { - if (null == self::$groupNameTemplate) { + if (self::$groupNameTemplate == null) { self::$groupNameTemplate = new PathTemplate('projects/{project}/groups/{group}'); } return self::$groupNameTemplate; } - private static function getProjectNameTemplate() + private static function getOrganizationGroupNameTemplate() + { + if (self::$organizationGroupNameTemplate == null) { + self::$organizationGroupNameTemplate = new PathTemplate('organizations/{organization}/groups/{group}'); + } + + return self::$organizationGroupNameTemplate; + } + + private static function getProjectGroupNameTemplate() { - if (null == self::$projectNameTemplate) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); + if (self::$projectGroupNameTemplate == null) { + self::$projectGroupNameTemplate = new PathTemplate('projects/{project}/groups/{group}'); } - return self::$projectNameTemplate; + return self::$projectGroupNameTemplate; } private static function getPathTemplateMap() { - if (null == self::$pathTemplateMap) { + if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ + 'folderGroup' => self::getFolderGroupNameTemplate(), 'group' => self::getGroupNameTemplate(), - 'project' => self::getProjectNameTemplate(), + 'organizationGroup' => self::getOrganizationGroupNameTemplate(), + 'projectGroup' => self::getProjectGroupNameTemplate(), ]; } @@ -179,8 +192,25 @@ private static function getPathTemplateMap() } /** - * Formats a string containing the fully-qualified path to represent - * a group resource. + * Formats a string containing the fully-qualified path to represent a folder_group + * resource. + * + * @param string $folder + * @param string $group + * + * @return string The formatted folder_group resource. + */ + public static function folderGroupName($folder, $group) + { + return self::getFolderGroupNameTemplate()->render([ + 'folder' => $folder, + 'group' => $group, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a group + * resource. * * @param string $project * @param string $group @@ -196,17 +226,36 @@ public static function groupName($project, $group) } /** - * Formats a string containing the fully-qualified path to represent - * a project resource. + * Formats a string containing the fully-qualified path to represent a + * organization_group resource. + * + * @param string $organization + * @param string $group + * + * @return string The formatted organization_group resource. + */ + public static function organizationGroupName($organization, $group) + { + return self::getOrganizationGroupNameTemplate()->render([ + 'organization' => $organization, + 'group' => $group, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_group resource. * * @param string $project + * @param string $group * - * @return string The formatted project resource. + * @return string The formatted project_group resource. */ - public static function projectName($project) + public static function projectGroupName($project, $group) { - return self::getProjectNameTemplate()->render([ + return self::getProjectGroupNameTemplate()->render([ 'project' => $project, + 'group' => $group, ]); } @@ -214,13 +263,16 @@ public static function projectName($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 + * - folderGroup: folders/{folder}/groups/{group} * - group: projects/{project}/groups/{group} - * - project: projects/{project}. + * - organizationGroup: organizations/{organization}/groups/{group} + * - projectGroup: projects/{project}/groups/{group} * - * 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. + * 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 @@ -232,7 +284,6 @@ public static function projectName($project) 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"); @@ -248,6 +299,7 @@ public static function parseName($formattedName, $template = null) // Swallow the exception to continue trying other path templates } } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); } @@ -255,7 +307,7 @@ public static function parseName($formattedName, $template = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress * **Deprecated**. This option will be removed in a future major release. Please @@ -272,35 +324,38 @@ public static function parseName($formattedName, $template = null) * {@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()}. + * 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. + * 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. + * 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 + * $serviceAddress 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' => [...] + * '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 @@ -312,363 +367,259 @@ public function __construct(array $options = []) } /** - * Lists the existing groups. + * Creates a new group. * * Sample code: * ``` * $groupServiceClient = new Google\Cloud\Monitoring\V3\GroupServiceClient(); * try { - * $formattedName = $groupServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $groupServiceClient->listGroups($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $groupServiceClient->listGroups($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $name = 'name'; + * $group = new Google\Cloud\Monitoring\V3\Group(); + * $response = $groupServiceClient->createGroup($name, $group); * } finally { * $groupServiceClient->close(); * } * ``` * - * @param string $name Required. The project whose groups are to be listed. The format is: - * - * projects/[PROJECT_ID_OR_NUMBER] - * @param array $optionalArgs { - * Optional. - * - * @type string $childrenOfGroup - * A group name. The format is: - * - * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] - * - * Returns groups whose `parent_name` field contains the group - * name. If no groups have this parent, the results are empty. - * @type string $ancestorsOfGroup - * A group name. The format is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the group. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] - * - * Returns groups that are ancestors of the specified group. - * The groups are returned in order, starting with the immediate parent and - * ending with the most distant ancestor. If the specified group has no - * immediate parent, the results are empty. - * @type string $descendantsOfGroup - * A group name. The format is: + * projects/[PROJECT_ID_OR_NUMBER] + * @param Group $group Required. A group definition. It is an error to define the `name` field because + * the system assigns the name. + * @param array $optionalArgs { + * Optional. * - * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] - * - * Returns the descendants of the specified group. This is a superset of - * the results returned by the `children_of_group` filter, and includes - * children-of-children, and so forth. - * @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 bool $validateOnly + * If true, validate this request but do not create the group. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse + * @return \Google\Cloud\Monitoring\V3\Group * * @throws ApiException if the remote call fails */ - public function listGroups($name, array $optionalArgs = []) + public function createGroup($name, $group, array $optionalArgs = []) { - $request = new ListGroupsRequest(); + $request = new CreateGroupRequest(); + $requestParamHeaders = []; $request->setName($name); - if (isset($optionalArgs['childrenOfGroup'])) { - $request->setChildrenOfGroup($optionalArgs['childrenOfGroup']); - } - if (isset($optionalArgs['ancestorsOfGroup'])) { - $request->setAncestorsOfGroup($optionalArgs['ancestorsOfGroup']); - } - if (isset($optionalArgs['descendantsOfGroup'])) { - $request->setDescendantsOfGroup($optionalArgs['descendantsOfGroup']); - } - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); + $request->setGroup($group); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['validateOnly'])) { + $request->setValidateOnly($optionalArgs['validateOnly']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListGroups', - $optionalArgs, - ListGroupsResponse::class, - $request - ); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateGroup', Group::class, $optionalArgs, $request)->wait(); } /** - * Gets a single group. + * Deletes an existing group. * * Sample code: * ``` * $groupServiceClient = new Google\Cloud\Monitoring\V3\GroupServiceClient(); * try { * $formattedName = $groupServiceClient->groupName('[PROJECT]', '[GROUP]'); - * $response = $groupServiceClient->getGroup($formattedName); + * $groupServiceClient->deleteGroup($formattedName); * } finally { * $groupServiceClient->close(); * } * ``` * - * @param string $name Required. The group to retrieve. The format is: + * @param string $name Required. The group to delete. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] + * @param array $optionalArgs { + * Optional. * + * @type bool $recursive + * If this field is true, then the request means to delete a group with all + * its descendants. Otherwise, the request means to delete a group only when + * it has no descendants. The default value is false. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\Group - * * @throws ApiException if the remote call fails */ - public function getGroup($name, array $optionalArgs = []) + public function deleteGroup($name, array $optionalArgs = []) { - $request = new GetGroupRequest(); + $request = new DeleteGroupRequest(); + $requestParamHeaders = []; $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['recursive'])) { + $request->setRecursive($optionalArgs['recursive']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetGroup', - Group::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteGroup', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * Creates a new group. + * Gets a single group. * * Sample code: * ``` * $groupServiceClient = new Google\Cloud\Monitoring\V3\GroupServiceClient(); * try { - * $formattedName = $groupServiceClient->projectName('[PROJECT]'); - * $group = new Google\Cloud\Monitoring\V3\Group(); - * $response = $groupServiceClient->createGroup($formattedName, $group); + * $formattedName = $groupServiceClient->groupName('[PROJECT]', '[GROUP]'); + * $response = $groupServiceClient->getGroup($formattedName); * } finally { * $groupServiceClient->close(); * } * ``` * - * @param string $name Required. The project in which to create the group. The format is: + * @param string $name Required. The group to retrieve. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] - * @param Group $group Required. A group definition. It is an error to define the `name` field because - * the system assigns the name. - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] + * @param array $optionalArgs { + * Optional. * - * @type bool $validateOnly - * If true, validate this request but do not create the group. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Cloud\Monitoring\V3\Group * * @throws ApiException if the remote call fails */ - public function createGroup($name, $group, array $optionalArgs = []) + public function getGroup($name, array $optionalArgs = []) { - $request = new CreateGroupRequest(); + $request = new GetGroupRequest(); + $requestParamHeaders = []; $request->setName($name); - $request->setGroup($group); - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'CreateGroup', - Group::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetGroup', Group::class, $optionalArgs, $request)->wait(); } /** - * Updates an existing group. - * You can change any group attributes except `name`. + * Lists the monitored resources that are members of a group. * * Sample code: * ``` * $groupServiceClient = new Google\Cloud\Monitoring\V3\GroupServiceClient(); * try { - * $group = new Google\Cloud\Monitoring\V3\Group(); - * $response = $groupServiceClient->updateGroup($group); + * $formattedName = $groupServiceClient->groupName('[PROJECT]', '[GROUP]'); + * // Iterate over pages of elements + * $pagedResponse = $groupServiceClient->listGroupMembers($formattedName); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $groupServiceClient->listGroupMembers($formattedName); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $groupServiceClient->close(); * } * ``` * - * @param Group $group Required. The new definition of the group. All fields of the existing group, - * excepting `name`, are replaced with the corresponding fields of this group. - * @param array $optionalArgs { - * Optional. + * @param string $name Required. The group whose members are listed. The format is: * - * @type bool $validateOnly - * If true, validate this request but do not update the existing group. + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_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 string $filter + * An optional [list + * filter](https://cloud.google.com/monitoring/api/learn_more#filtering) + * describing the members to be returned. The filter may reference the type, + * labels, and metadata of monitored resources that comprise the group. For + * example, to return only resources representing Compute Engine VM instances, + * use this filter: + * + * `resource.type = "gce_instance"` + * @type TimeInterval $interval + * An optional time interval for which results should be returned. Only + * members that were part of the group during the specified interval are + * included in the response. If no interval is provided then the group + * membership over the last minute is returned. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\Group + * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails */ - public function updateGroup($group, array $optionalArgs = []) + public function listGroupMembers($name, array $optionalArgs = []) { - $request = new UpdateGroupRequest(); - $request->setGroup($group); - if (isset($optionalArgs['validateOnly'])) { - $request->setValidateOnly($optionalArgs['validateOnly']); + $request = new ListGroupMembersRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'group.name' => $request->getGroup()->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'UpdateGroup', - Group::class, - $optionalArgs, - $request - )->wait(); - } + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } - /** - * Deletes an existing group. - * - * Sample code: - * ``` - * $groupServiceClient = new Google\Cloud\Monitoring\V3\GroupServiceClient(); - * try { - * $formattedName = $groupServiceClient->groupName('[PROJECT]', '[GROUP]'); - * $groupServiceClient->deleteGroup($formattedName); - * } finally { - * $groupServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The group to delete. The format is: - * - * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] - * @param array $optionalArgs { - * Optional. - * - * @type bool $recursive - * If this field is true, then the request means to delete a group with all - * its descendants. Otherwise, the request means to delete a group only when - * it has no descendants. The default value is false. - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. - * } - * - * @throws ApiException if the remote call fails - */ - public function deleteGroup($name, array $optionalArgs = []) - { - $request = new DeleteGroupRequest(); - $request->setName($name); - if (isset($optionalArgs['recursive'])) { - $request->setRecursive($optionalArgs['recursive']); + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'DeleteGroup', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + if (isset($optionalArgs['interval'])) { + $request->setInterval($optionalArgs['interval']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListGroupMembers', $optionalArgs, ListGroupMembersResponse::class, $request); } /** - * Lists the monitored resources that are members of a group. + * Lists the existing groups. * * Sample code: * ``` * $groupServiceClient = new Google\Cloud\Monitoring\V3\GroupServiceClient(); * try { - * $formattedName = $groupServiceClient->groupName('[PROJECT]', '[GROUP]'); + * $name = 'name'; * // Iterate over pages of elements - * $pagedResponse = $groupServiceClient->listGroupMembers($formattedName); + * $pagedResponse = $groupServiceClient->listGroups($name); * foreach ($pagedResponse->iteratePages() as $page) { * foreach ($page as $element) { * // doSomethingWith($element); * } * } - * - * * // Alternatively: - * * // Iterate through all elements - * $pagedResponse = $groupServiceClient->listGroupMembers($formattedName); + * $pagedResponse = $groupServiceClient->listGroups($name); * foreach ($pagedResponse->iterateAllElements() as $element) { * // doSomethingWith($element); * } @@ -677,75 +628,133 @@ public function deleteGroup($name, array $optionalArgs = []) * } * ``` * - * @param string $name Required. The group whose members are listed. The format is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose groups are to be listed. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER] + * @param array $optionalArgs { + * Optional. + * + * @type string $childrenOfGroup + * A group name. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] + * + * Returns groups whose `parent_name` field contains the group + * name. If no groups have this parent, the results are empty. + * @type string $ancestorsOfGroup + * A group name. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] + * + * Returns groups that are ancestors of the specified group. + * The groups are returned in order, starting with the immediate parent and + * ending with the most distant ancestor. If the specified group has no + * immediate parent, the results are empty. + * @type string $descendantsOfGroup + * A group name. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] * + * Returns the descendants of the specified group. This is a superset of + * the results returned by the `children_of_group` filter, and includes + * children-of-children, and so forth. * @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. + * 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 string $filter - * An optional [list - * filter](https://cloud.google.com/monitoring/api/learn_more#filtering) - * describing the members to be returned. The filter may reference the type, - * labels, and metadata of monitored resources that comprise the group. For - * example, to return only resources representing Compute Engine VM instances, - * use this filter: - * - * `resource.type = "gce_instance"` - * @type TimeInterval $interval - * An optional time interval for which results should be returned. Only - * members that were part of the group during the specified interval are - * included in the response. If no interval is provided then the group - * membership over the last minute is returned. + * 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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails */ - public function listGroupMembers($name, array $optionalArgs = []) + public function listGroups($name, array $optionalArgs = []) { - $request = new ListGroupMembersRequest(); + $request = new ListGroupsRequest(); + $requestParamHeaders = []; $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['childrenOfGroup'])) { + $request->setChildrenOfGroup($optionalArgs['childrenOfGroup']); + } + + if (isset($optionalArgs['ancestorsOfGroup'])) { + $request->setAncestorsOfGroup($optionalArgs['ancestorsOfGroup']); + } + + if (isset($optionalArgs['descendantsOfGroup'])) { + $request->setDescendantsOfGroup($optionalArgs['descendantsOfGroup']); + } + if (isset($optionalArgs['pageSize'])) { $request->setPageSize($optionalArgs['pageSize']); } + if (isset($optionalArgs['pageToken'])) { $request->setPageToken($optionalArgs['pageToken']); } - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - if (isset($optionalArgs['interval'])) { - $request->setInterval($optionalArgs['interval']); + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListGroups', $optionalArgs, ListGroupsResponse::class, $request); + } + + /** + * Updates an existing group. + * You can change any group attributes except `name`. + * + * Sample code: + * ``` + * $groupServiceClient = new Google\Cloud\Monitoring\V3\GroupServiceClient(); + * try { + * $group = new Google\Cloud\Monitoring\V3\Group(); + * $response = $groupServiceClient->updateGroup($group); + * } finally { + * $groupServiceClient->close(); + * } + * ``` + * + * @param Group $group Required. The new definition of the group. All fields of the existing group, + * excepting `name`, are replaced with the corresponding fields of this group. + * @param array $optionalArgs { + * Optional. + * + * @type bool $validateOnly + * If true, validate this request but do not update the existing group. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Monitoring\V3\Group + * + * @throws ApiException if the remote call fails + */ + public function updateGroup($group, array $optionalArgs = []) + { + $request = new UpdateGroupRequest(); + $requestParamHeaders = []; + $request->setGroup($group); + $requestParamHeaders['group.name'] = $group->getName(); + if (isset($optionalArgs['validateOnly'])) { + $request->setValidateOnly($optionalArgs['validateOnly']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListGroupMembers', - $optionalArgs, - ListGroupMembersResponse::class, - $request - ); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateGroup', Group::class, $optionalArgs, $request)->wait(); } } diff --git a/Monitoring/src/V3/Gapic/MetricServiceGapicClient.php b/Monitoring/src/V3/Gapic/MetricServiceGapicClient.php index a70b8f9434c..222eac37a17 100644 --- a/Monitoring/src/V3/Gapic/MetricServiceGapicClient.php +++ b/Monitoring/src/V3/Gapic/MetricServiceGapicClient.php @@ -17,14 +17,17 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/metric_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/metric_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3\Gapic; use Google\ApiCore\ApiException; +use Google\Api\MetricDescriptor; +use Google\Api\MonitoredResourceDescriptor; + use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\PathTemplate; @@ -32,8 +35,6 @@ use Google\ApiCore\RetrySettings; use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; -use Google\Api\MetricDescriptor; -use Google\Api\MonitoredResourceDescriptor; use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\Monitoring\V3\Aggregation; use Google\Cloud\Monitoring\V3\CreateMetricDescriptorRequest; @@ -62,32 +63,18 @@ * ``` * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); * try { - * $formattedName = $metricServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $metricServiceClient->listMonitoredResourceDescriptors($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $metricServiceClient->listMonitoredResourceDescriptors($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $name = 'name'; + * $metricDescriptor = new Google\Cloud\Monitoring\V3\MetricDescriptor(); + * $response = $metricServiceClient->createMetricDescriptor($name, $metricDescriptor); * } finally { * $metricServiceClient->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. + * 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. */ class MetricServiceGapicClient { @@ -122,33 +109,82 @@ class MetricServiceGapicClient 'https://www.googleapis.com/auth/monitoring.read', 'https://www.googleapis.com/auth/monitoring.write', ]; + + private static $folderNameTemplate; + + private static $folderMetricDescriptorNameTemplate; + + private static $folderMonitoredResourceDescriptorNameTemplate; + private static $metricDescriptorNameTemplate; + private static $monitoredResourceDescriptorNameTemplate; + + private static $organizationNameTemplate; + + private static $organizationMetricDescriptorNameTemplate; + + private static $organizationMonitoredResourceDescriptorNameTemplate; + private static $projectNameTemplate; + + private static $projectMetricDescriptorNameTemplate; + + private static $projectMonitoredResourceDescriptorNameTemplate; + + private static $workspaceNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() { return [ 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__.'/../resources/metric_service_client_config.json', - 'descriptorsConfigPath' => __DIR__.'/../resources/metric_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__.'/../resources/metric_service_grpc_config.json', + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/metric_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/metric_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/metric_service_grpc_config.json', 'credentialsConfig' => [ - 'scopes' => self::$serviceScopes, + 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__.'/../resources/metric_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/metric_service_rest_client_config.php', ], ], ]; } + private static function getFolderNameTemplate() + { + if (self::$folderNameTemplate == null) { + self::$folderNameTemplate = new PathTemplate('folders/{folder}'); + } + + return self::$folderNameTemplate; + } + + private static function getFolderMetricDescriptorNameTemplate() + { + if (self::$folderMetricDescriptorNameTemplate == null) { + self::$folderMetricDescriptorNameTemplate = new PathTemplate('folders/{folder}/metricDescriptors/{metric_descriptor=**}'); + } + + return self::$folderMetricDescriptorNameTemplate; + } + + private static function getFolderMonitoredResourceDescriptorNameTemplate() + { + if (self::$folderMonitoredResourceDescriptorNameTemplate == null) { + self::$folderMonitoredResourceDescriptorNameTemplate = new PathTemplate('folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor}'); + } + + return self::$folderMonitoredResourceDescriptorNameTemplate; + } + private static function getMetricDescriptorNameTemplate() { - if (null == self::$metricDescriptorNameTemplate) { + if (self::$metricDescriptorNameTemplate == null) { self::$metricDescriptorNameTemplate = new PathTemplate('projects/{project}/metricDescriptors/{metric_descriptor=**}'); } @@ -157,29 +193,92 @@ private static function getMetricDescriptorNameTemplate() private static function getMonitoredResourceDescriptorNameTemplate() { - if (null == self::$monitoredResourceDescriptorNameTemplate) { + if (self::$monitoredResourceDescriptorNameTemplate == null) { self::$monitoredResourceDescriptorNameTemplate = new PathTemplate('projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}'); } return self::$monitoredResourceDescriptorNameTemplate; } + private static function getOrganizationNameTemplate() + { + if (self::$organizationNameTemplate == null) { + self::$organizationNameTemplate = new PathTemplate('organizations/{organization}'); + } + + return self::$organizationNameTemplate; + } + + private static function getOrganizationMetricDescriptorNameTemplate() + { + if (self::$organizationMetricDescriptorNameTemplate == null) { + self::$organizationMetricDescriptorNameTemplate = new PathTemplate('organizations/{organization}/metricDescriptors/{metric_descriptor=**}'); + } + + return self::$organizationMetricDescriptorNameTemplate; + } + + private static function getOrganizationMonitoredResourceDescriptorNameTemplate() + { + if (self::$organizationMonitoredResourceDescriptorNameTemplate == null) { + self::$organizationMonitoredResourceDescriptorNameTemplate = new PathTemplate('organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor}'); + } + + return self::$organizationMonitoredResourceDescriptorNameTemplate; + } + private static function getProjectNameTemplate() { - if (null == self::$projectNameTemplate) { + if (self::$projectNameTemplate == null) { self::$projectNameTemplate = new PathTemplate('projects/{project}'); } return self::$projectNameTemplate; } + private static function getProjectMetricDescriptorNameTemplate() + { + if (self::$projectMetricDescriptorNameTemplate == null) { + self::$projectMetricDescriptorNameTemplate = new PathTemplate('projects/{project}/metricDescriptors/{metric_descriptor=**}'); + } + + return self::$projectMetricDescriptorNameTemplate; + } + + private static function getProjectMonitoredResourceDescriptorNameTemplate() + { + if (self::$projectMonitoredResourceDescriptorNameTemplate == null) { + self::$projectMonitoredResourceDescriptorNameTemplate = new PathTemplate('projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}'); + } + + return self::$projectMonitoredResourceDescriptorNameTemplate; + } + + private static function getWorkspaceNameTemplate() + { + if (self::$workspaceNameTemplate == null) { + self::$workspaceNameTemplate = new PathTemplate('projects/{project}'); + } + + return self::$workspaceNameTemplate; + } + private static function getPathTemplateMap() { - if (null == self::$pathTemplateMap) { + if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ + 'folder' => self::getFolderNameTemplate(), + 'folderMetricDescriptor' => self::getFolderMetricDescriptorNameTemplate(), + 'folderMonitoredResourceDescriptor' => self::getFolderMonitoredResourceDescriptorNameTemplate(), 'metricDescriptor' => self::getMetricDescriptorNameTemplate(), 'monitoredResourceDescriptor' => self::getMonitoredResourceDescriptorNameTemplate(), + 'organization' => self::getOrganizationNameTemplate(), + 'organizationMetricDescriptor' => self::getOrganizationMetricDescriptorNameTemplate(), + 'organizationMonitoredResourceDescriptor' => self::getOrganizationMonitoredResourceDescriptorNameTemplate(), 'project' => self::getProjectNameTemplate(), + 'projectMetricDescriptor' => self::getProjectMetricDescriptorNameTemplate(), + 'projectMonitoredResourceDescriptor' => self::getProjectMonitoredResourceDescriptorNameTemplate(), + 'workspace' => self::getWorkspaceNameTemplate(), ]; } @@ -187,8 +286,57 @@ private static function getPathTemplateMap() } /** - * Formats a string containing the fully-qualified path to represent - * a metric_descriptor resource. + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName($folder) + { + return self::getFolderNameTemplate()->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_metric_descriptor resource. + * + * @param string $folder + * @param string $metricDescriptor + * + * @return string The formatted folder_metric_descriptor resource. + */ + public static function folderMetricDescriptorName($folder, $metricDescriptor) + { + return self::getFolderMetricDescriptorNameTemplate()->render([ + 'folder' => $folder, + 'metric_descriptor' => $metricDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_monitored_resource_descriptor resource. + * + * @param string $folder + * @param string $monitoredResourceDescriptor + * + * @return string The formatted folder_monitored_resource_descriptor resource. + */ + public static function folderMonitoredResourceDescriptorName($folder, $monitoredResourceDescriptor) + { + return self::getFolderMonitoredResourceDescriptorNameTemplate()->render([ + 'folder' => $folder, + 'monitored_resource_descriptor' => $monitoredResourceDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * metric_descriptor resource. * * @param string $project * @param string $metricDescriptor @@ -204,8 +352,8 @@ public static function metricDescriptorName($project, $metricDescriptor) } /** - * Formats a string containing the fully-qualified path to represent - * a monitored_resource_descriptor resource. + * Formats a string containing the fully-qualified path to represent a + * monitored_resource_descriptor resource. * * @param string $project * @param string $monitoredResourceDescriptor @@ -221,8 +369,57 @@ public static function monitoredResourceDescriptorName($project, $monitoredResou } /** - * Formats a string containing the fully-qualified path to represent - * a project resource. + * Formats a string containing the fully-qualified path to represent a organization + * resource. + * + * @param string $organization + * + * @return string The formatted organization resource. + */ + public static function organizationName($organization) + { + return self::getOrganizationNameTemplate()->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_metric_descriptor resource. + * + * @param string $organization + * @param string $metricDescriptor + * + * @return string The formatted organization_metric_descriptor resource. + */ + public static function organizationMetricDescriptorName($organization, $metricDescriptor) + { + return self::getOrganizationMetricDescriptorNameTemplate()->render([ + 'organization' => $organization, + 'metric_descriptor' => $metricDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_monitored_resource_descriptor resource. + * + * @param string $organization + * @param string $monitoredResourceDescriptor + * + * @return string The formatted organization_monitored_resource_descriptor resource. + */ + public static function organizationMonitoredResourceDescriptorName($organization, $monitoredResourceDescriptor) + { + return self::getOrganizationMonitoredResourceDescriptorNameTemplate()->render([ + 'organization' => $organization, + 'monitored_resource_descriptor' => $monitoredResourceDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project + * resource. * * @param string $project * @@ -235,18 +432,77 @@ public static function projectName($project) ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * project_metric_descriptor resource. + * + * @param string $project + * @param string $metricDescriptor + * + * @return string The formatted project_metric_descriptor resource. + */ + public static function projectMetricDescriptorName($project, $metricDescriptor) + { + return self::getProjectMetricDescriptorNameTemplate()->render([ + 'project' => $project, + 'metric_descriptor' => $metricDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_monitored_resource_descriptor resource. + * + * @param string $project + * @param string $monitoredResourceDescriptor + * + * @return string The formatted project_monitored_resource_descriptor resource. + */ + public static function projectMonitoredResourceDescriptorName($project, $monitoredResourceDescriptor) + { + return self::getProjectMonitoredResourceDescriptorNameTemplate()->render([ + 'project' => $project, + 'monitored_resource_descriptor' => $monitoredResourceDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a workspace + * resource. + * + * @param string $project + * + * @return string The formatted workspace resource. + */ + public static function workspaceName($project) + { + return self::getWorkspaceNameTemplate()->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 + * - folder: folders/{folder} + * - folderMetricDescriptor: folders/{folder}/metricDescriptors/{metric_descriptor=**} + * - folderMonitoredResourceDescriptor: folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor} * - metricDescriptor: projects/{project}/metricDescriptors/{metric_descriptor=**} * - monitoredResourceDescriptor: projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor} - * - 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. + * - organization: organizations/{organization} + * - organizationMetricDescriptor: organizations/{organization}/metricDescriptors/{metric_descriptor=**} + * - organizationMonitoredResourceDescriptor: organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor} + * - project: projects/{project} + * - projectMetricDescriptor: projects/{project}/metricDescriptors/{metric_descriptor=**} + * - projectMonitoredResourceDescriptor: projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor} + * - workspace: 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 @@ -258,7 +514,6 @@ public static function projectName($project) 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"); @@ -274,6 +529,7 @@ public static function parseName($formattedName, $template = null) // Swallow the exception to continue trying other path templates } } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); } @@ -281,7 +537,7 @@ public static function parseName($formattedName, $template = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress * **Deprecated**. This option will be removed in a future major release. Please @@ -298,35 +554,38 @@ public static function parseName($formattedName, $template = null) * {@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()}. + * 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. + * 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. + * 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 + * $serviceAddress 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' => [...] + * '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 @@ -338,241 +597,210 @@ public function __construct(array $options = []) } /** - * Lists monitored resource descriptors that match a filter. This method does not require a Workspace. + * Creates a new metric descriptor. + * The creation is executed asynchronously and callers may check the returned + * operation to track its progress. + * User-created metric descriptors define + * [custom metrics](https://cloud.google.com/monitoring/custom-metrics). * * Sample code: * ``` * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); * try { - * $formattedName = $metricServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $metricServiceClient->listMonitoredResourceDescriptors($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $metricServiceClient->listMonitoredResourceDescriptors($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $name = 'name'; + * $metricDescriptor = new Google\Cloud\Monitoring\V3\MetricDescriptor(); + * $response = $metricServiceClient->createMetricDescriptor($name, $metricDescriptor); * } finally { * $metricServiceClient->close(); * } * ``` * - * @param string $name Required. The project on which to execute the request. The format is: - * - * projects/[PROJECT_ID_OR_NUMBER] - * @param array $optionalArgs { - * Optional. - * - * @type string $filter - * An optional [filter](https://cloud.google.com/monitoring/api/v3/filters) - * describing the descriptors to be returned. The filter can reference the - * descriptor's type and labels. For example, the following filter returns - * only Google Compute Engine descriptors that have an `id` label: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: + * 4 + * projects/[PROJECT_ID_OR_NUMBER] + * @param MetricDescriptor $metricDescriptor Required. The new [custom metric](https://cloud.google.com/monitoring/custom-metrics) + * descriptor. + * @param array $optionalArgs { + * Optional. * - * resource.type = starts_with("gce_") AND resource.label:id - * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse + * @return \Google\Api\MetricDescriptor * * @throws ApiException if the remote call fails */ - public function listMonitoredResourceDescriptors($name, array $optionalArgs = []) + public function createMetricDescriptor($name, $metricDescriptor, array $optionalArgs = []) { - $request = new ListMonitoredResourceDescriptorsRequest(); + $request = new CreateMetricDescriptorRequest(); + $requestParamHeaders = []; $request->setName($name); - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListMonitoredResourceDescriptors', - $optionalArgs, - ListMonitoredResourceDescriptorsResponse::class, - $request - ); + $request->setMetricDescriptor($metricDescriptor); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateMetricDescriptor', MetricDescriptor::class, $optionalArgs, $request)->wait(); } /** - * Gets a single monitored resource descriptor. This method does not require a Workspace. + * Creates or adds data to one or more service time series. A service time + * series is a time series for a metric from a Google Cloud service. The + * response is empty if all time series in the request were written. If any + * time series could not be written, a corresponding failure message is + * included in the error response. This endpoint rejects writes to + * user-defined metrics. + * This method is only for use by Google Cloud services. Use + * [projects.timeSeries.create][google.monitoring.v3.MetricService.CreateTimeSeries] + * instead. * * Sample code: * ``` * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); * try { - * $formattedName = $metricServiceClient->monitoredResourceDescriptorName('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]'); - * $response = $metricServiceClient->getMonitoredResourceDescriptor($formattedName); + * $formattedName = $metricServiceClient->projectName('[PROJECT]'); + * $timeSeries = []; + * $metricServiceClient->createServiceTimeSeries($formattedName, $timeSeries); * } finally { * $metricServiceClient->close(); * } * ``` * - * @param string $name Required. The monitored resource descriptor to get. The format is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/monitoredResourceDescriptors/[RESOURCE_TYPE] + * projects/[PROJECT_ID_OR_NUMBER] + * @param TimeSeries[] $timeSeries Required. The new data to be added to a list of time series. + * Adds at most one data point to each of several time series. The new data + * point must be more recent than any other point in its time series. Each + * `TimeSeries` value must fully specify a unique time series by supplying + * all label values for the metric and the monitored resource. * - * The `[RESOURCE_TYPE]` is a predefined type, such as - * `cloudsql_database`. - * @param array $optionalArgs { - * Optional. + * The maximum number of `TimeSeries` objects per `Create` request is 200. + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Api\MonitoredResourceDescriptor - * * @throws ApiException if the remote call fails */ - public function getMonitoredResourceDescriptor($name, array $optionalArgs = []) + public function createServiceTimeSeries($name, $timeSeries, array $optionalArgs = []) { - $request = new GetMonitoredResourceDescriptorRequest(); + $request = new CreateTimeSeriesRequest(); + $requestParamHeaders = []; $request->setName($name); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetMonitoredResourceDescriptor', - MonitoredResourceDescriptor::class, - $optionalArgs, - $request - )->wait(); + $request->setTimeSeries($timeSeries); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateServiceTimeSeries', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * Lists metric descriptors that match a filter. This method does not require a Workspace. + * Creates or adds data to one or more time series. + * The response is empty if all time series in the request were written. + * If any time series could not be written, a corresponding failure message is + * included in the error response. * * Sample code: * ``` * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); * try { * $formattedName = $metricServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $metricServiceClient->listMetricDescriptors($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } + * $timeSeries = []; + * $metricServiceClient->createTimeSeries($formattedName, $timeSeries); + * } finally { + * $metricServiceClient->close(); + * } + * ``` * + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * - * // Alternatively: + * projects/[PROJECT_ID_OR_NUMBER] + * @param TimeSeries[] $timeSeries Required. The new data to be added to a list of time series. + * Adds at most one data point to each of several time series. The new data + * point must be more recent than any other point in its time series. Each + * `TimeSeries` value must fully specify a unique time series by supplying + * all label values for the metric and the monitored resource. * - * // Iterate through all elements - * $pagedResponse = $metricServiceClient->listMetricDescriptors($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * The maximum number of `TimeSeries` objects per `Create` request is 200. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @throws ApiException if the remote call fails + */ + public function createTimeSeries($name, $timeSeries, array $optionalArgs = []) + { + $request = new CreateTimeSeriesRequest(); + $requestParamHeaders = []; + $request->setName($name); + $request->setTimeSeries($timeSeries); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateTimeSeries', GPBEmpty::class, $optionalArgs, $request)->wait(); + } + + /** + * Deletes a metric descriptor. Only user-created + * [custom metrics](https://cloud.google.com/monitoring/custom-metrics) can be + * deleted. + * + * Sample code: + * ``` + * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); + * try { + * $formattedName = $metricServiceClient->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); + * $metricServiceClient->deleteMetricDescriptor($formattedName); * } finally { * $metricServiceClient->close(); * } * ``` * - * @param string $name Required. The project on which to execute the request. The format is: + * @param string $name Required. The metric descriptor on which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] + * + * An example of `[METRIC_ID]` is: + * `"custom.googleapis.com/my_test_metric"`. + * @param array $optionalArgs { + * Optional. * - * @type string $filter - * If this field is empty, all custom and - * system-defined metric descriptors are returned. - * Otherwise, the [filter](https://cloud.google.com/monitoring/api/v3/filters) - * specifies which metric descriptors are to be - * returned. For example, the following filter matches all - * [custom metrics](https://cloud.google.com/monitoring/custom-metrics): - * - * metric.type = starts_with("custom.googleapis.com/") - * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse - * * @throws ApiException if the remote call fails */ - public function listMetricDescriptors($name, array $optionalArgs = []) + public function deleteMetricDescriptor($name, array $optionalArgs = []) { - $request = new ListMetricDescriptorsRequest(); + $request = new DeleteMetricDescriptorRequest(); + $requestParamHeaders = []; $request->setName($name); - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListMetricDescriptors', - $optionalArgs, - ListMetricDescriptorsResponse::class, - $request - ); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteMetricDescriptor', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** @@ -589,20 +817,20 @@ public function listMetricDescriptors($name, array $optionalArgs = []) * } * ``` * - * @param string $name Required. The metric descriptor on which to execute the request. The format is: + * @param string $name Required. The metric descriptor on which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] + * projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] * - * An example value of `[METRIC_ID]` is - * `"compute.googleapis.com/instance/disk/read_bytes_count"`. - * @param array $optionalArgs { - * Optional. + * An example value of `[METRIC_ID]` is + * `"compute.googleapis.com/instance/disk/read_bytes_count"`. + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Api\MetricDescriptor @@ -612,132 +840,225 @@ public function listMetricDescriptors($name, array $optionalArgs = []) public function getMetricDescriptor($name, array $optionalArgs = []) { $request = new GetMetricDescriptorRequest(); + $requestParamHeaders = []; $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetMetricDescriptor', MetricDescriptor::class, $optionalArgs, $request)->wait(); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetMetricDescriptor', - MetricDescriptor::class, - $optionalArgs, - $request - )->wait(); + /** + * Gets a single monitored resource descriptor. This method does not require a Workspace. + * + * Sample code: + * ``` + * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); + * try { + * $formattedName = $metricServiceClient->monitoredResourceDescriptorName('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]'); + * $response = $metricServiceClient->getMonitoredResourceDescriptor($formattedName); + * } finally { + * $metricServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The monitored resource descriptor to get. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/monitoredResourceDescriptors/[RESOURCE_TYPE] + * + * The `[RESOURCE_TYPE]` is a predefined type, such as + * `cloudsql_database`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Api\MonitoredResourceDescriptor + * + * @throws ApiException if the remote call fails + */ + public function getMonitoredResourceDescriptor($name, array $optionalArgs = []) + { + $request = new GetMonitoredResourceDescriptorRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetMonitoredResourceDescriptor', MonitoredResourceDescriptor::class, $optionalArgs, $request)->wait(); } /** - * Creates a new metric descriptor. - * User-created metric descriptors define - * [custom metrics](https://cloud.google.com/monitoring/custom-metrics). + * Lists metric descriptors that match a filter. This method does not require a Workspace. * * Sample code: * ``` * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); * try { - * $formattedName = $metricServiceClient->projectName('[PROJECT]'); - * $metricDescriptor = new Google\Cloud\Monitoring\V3\MetricDescriptor(); - * $response = $metricServiceClient->createMetricDescriptor($formattedName, $metricDescriptor); + * $name = 'name'; + * // Iterate over pages of elements + * $pagedResponse = $metricServiceClient->listMetricDescriptors($name); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $metricServiceClient->listMetricDescriptors($name); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $metricServiceClient->close(); * } * ``` * - * @param string $name Required. The project on which to execute the request. The format is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] - * @param MetricDescriptor $metricDescriptor Required. The new [custom metric](https://cloud.google.com/monitoring/custom-metrics) - * descriptor. - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER] + * @param array $optionalArgs { + * Optional. * + * @type string $filter + * If this field is empty, all custom and + * system-defined metric descriptors are returned. + * Otherwise, the [filter](https://cloud.google.com/monitoring/api/v3/filters) + * specifies which metric descriptors are to be + * returned. For example, the following filter matches all + * [custom metrics](https://cloud.google.com/monitoring/custom-metrics): + * + * metric.type = starts_with("custom.googleapis.com/") + * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Api\MetricDescriptor + * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails */ - public function createMetricDescriptor($name, $metricDescriptor, array $optionalArgs = []) + public function listMetricDescriptors($name, array $optionalArgs = []) { - $request = new CreateMetricDescriptorRequest(); + $request = new ListMetricDescriptorsRequest(); + $requestParamHeaders = []; $request->setName($name); - $request->setMetricDescriptor($metricDescriptor); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } - return $this->startCall( - 'CreateMetricDescriptor', - MetricDescriptor::class, - $optionalArgs, - $request - )->wait(); + 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('ListMetricDescriptors', $optionalArgs, ListMetricDescriptorsResponse::class, $request); } /** - * Deletes a metric descriptor. Only user-created - * [custom metrics](https://cloud.google.com/monitoring/custom-metrics) can be - * deleted. + * Lists monitored resource descriptors that match a filter. This method does not require a Workspace. * * Sample code: * ``` * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); * try { - * $formattedName = $metricServiceClient->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); - * $metricServiceClient->deleteMetricDescriptor($formattedName); + * $name = 'name'; + * // Iterate over pages of elements + * $pagedResponse = $metricServiceClient->listMonitoredResourceDescriptors($name); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $metricServiceClient->listMonitoredResourceDescriptors($name); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $metricServiceClient->close(); * } * ``` * - * @param string $name Required. The metric descriptor on which to execute the request. The format is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID] + * projects/[PROJECT_ID_OR_NUMBER] + * @param array $optionalArgs { + * Optional. * - * An example of `[METRIC_ID]` is: - * `"custom.googleapis.com/my_test_metric"`. - * @param array $optionalArgs { - * Optional. + * @type string $filter + * An optional [filter](https://cloud.google.com/monitoring/api/v3/filters) + * describing the descriptors to be returned. The filter can reference the + * descriptor's type and labels. For example, the following filter returns + * only Google Compute Engine descriptors that have an `id` label: * + * resource.type = starts_with("gce_") AND resource.label:id + * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * + * @return \Google\ApiCore\PagedListResponse + * * @throws ApiException if the remote call fails */ - public function deleteMetricDescriptor($name, array $optionalArgs = []) + public function listMonitoredResourceDescriptors($name, array $optionalArgs = []) { - $request = new DeleteMetricDescriptorRequest(); + $request = new ListMonitoredResourceDescriptorsRequest(); + $requestParamHeaders = []; $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } - return $this->startCall( - 'DeleteMetricDescriptor', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListMonitoredResourceDescriptors', $optionalArgs, ListMonitoredResourceDescriptorsResponse::class, $request); } /** @@ -747,8 +1068,8 @@ public function deleteMetricDescriptor($name, array $optionalArgs = []) * ``` * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); * try { - * $formattedName = $metricServiceClient->projectName('[PROJECT]'); - * $filter = ''; + * $formattedName = $metricServiceClient->workspaceName('[PROJECT]'); + * $filter = 'filter'; * $interval = new Google\Cloud\Monitoring\V3\TimeInterval(); * $view = Google\Cloud\Monitoring\V3\ListTimeSeriesRequest\TimeSeriesView::FULL; * // Iterate over pages of elements @@ -758,10 +1079,7 @@ public function deleteMetricDescriptor($name, array $optionalArgs = []) * // doSomethingWith($element); * } * } - * - * * // Alternatively: - * * // Iterate through all elements * $pagedResponse = $metricServiceClient->listTimeSeries($formattedName, $filter, $interval, $view); * foreach ($pagedResponse->iterateAllElements() as $element) { @@ -772,47 +1090,53 @@ public function deleteMetricDescriptor($name, array $optionalArgs = []) * } * ``` * - * @param string $name Required. The project on which to execute the request. The format is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name), + * organization or folder on which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] - * @param string $filter Required. A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) - * that specifies which time series should be returned. The filter must - * specify a single metric type, and can additionally specify metric labels - * and other information. For example: + * projects/[PROJECT_ID_OR_NUMBER] + * organizations/[ORGANIZATION_ID] + * folders/[FOLDER_ID] + * @param string $filter Required. A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + * that specifies which time series should be returned. The filter must + * specify a single metric type, and can additionally specify metric labels + * and other information. For example: * - * metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND - * metric.labels.instance_name = "my-instance-name" + * metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND + * metric.labels.instance_name = "my-instance-name" * @param TimeInterval $interval Required. The time interval for which results should be returned. Only time series * that contain data points in the specified interval are included * in the response. * @param int $view Required. Specifies which information is returned about the time series. * For allowed values, use constants defined on {@see \Google\Cloud\Monitoring\V3\ListTimeSeriesRequest\TimeSeriesView} * @param array $optionalArgs { - * Optional. + * Optional. * * @type Aggregation $aggregation - * Specifies the alignment of data points in individual time series as - * well as how to combine the retrieved time series across specified labels. - * - * By default (if no `aggregation` is explicitly specified), the raw time - * series data is returned. + * Specifies the alignment of data points in individual time series as + * well as how to combine the retrieved time series across specified labels. + * + * By default (if no `aggregation` is explicitly specified), the raw time + * series data is returned. + * @type Aggregation $secondaryAggregation + * Apply a second aggregation after `aggregation` is applied. May only be + * specified if `aggregation` is specified. * @type string $orderBy - * Unsupported: must be left blank. The points in each time series are - * currently returned in reverse time order (most recent to oldest). + * Unsupported: must be left blank. The points in each time series are + * currently returned in reverse time order (most recent to oldest). * @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. + * 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. + * 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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\ApiCore\PagedListResponse @@ -822,96 +1146,34 @@ public function deleteMetricDescriptor($name, array $optionalArgs = []) public function listTimeSeries($name, $filter, $interval, $view, array $optionalArgs = []) { $request = new ListTimeSeriesRequest(); + $requestParamHeaders = []; $request->setName($name); $request->setFilter($filter); $request->setInterval($interval); $request->setView($view); + $requestParamHeaders['name'] = $name; if (isset($optionalArgs['aggregation'])) { $request->setAggregation($optionalArgs['aggregation']); } + + if (isset($optionalArgs['secondaryAggregation'])) { + $request->setSecondaryAggregation($optionalArgs['secondaryAggregation']); + } + if (isset($optionalArgs['orderBy'])) { $request->setOrderBy($optionalArgs['orderBy']); } + if (isset($optionalArgs['pageSize'])) { $request->setPageSize($optionalArgs['pageSize']); } + if (isset($optionalArgs['pageToken'])) { $request->setPageToken($optionalArgs['pageToken']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListTimeSeries', - $optionalArgs, - ListTimeSeriesResponse::class, - $request - ); - } - - /** - * Creates or adds data to one or more time series. - * The response is empty if all time series in the request were written. - * If any time series could not be written, a corresponding failure message is - * included in the error response. - * - * Sample code: - * ``` - * $metricServiceClient = new Google\Cloud\Monitoring\V3\MetricServiceClient(); - * try { - * $formattedName = $metricServiceClient->projectName('[PROJECT]'); - * $timeSeries = []; - * $metricServiceClient->createTimeSeries($formattedName, $timeSeries); - * } finally { - * $metricServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The project on which to execute the request. The format is: - * - * projects/[PROJECT_ID_OR_NUMBER] - * @param TimeSeries[] $timeSeries Required. The new data to be added to a list of time series. - * Adds at most one data point to each of several time series. The new data - * point must be more recent than any other point in its time series. Each - * `TimeSeries` value must fully specify a unique time series by supplying - * all label values for the metric and the monitored resource. - * - * The maximum number of `TimeSeries` objects per `Create` request is 200. - * @param array $optionalArgs { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. - * } - * - * @throws ApiException if the remote call fails - */ - public function createTimeSeries($name, $timeSeries, array $optionalArgs = []) - { - $request = new CreateTimeSeriesRequest(); - $request->setName($name); - $request->setTimeSeries($timeSeries); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'CreateTimeSeries', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListTimeSeries', $optionalArgs, ListTimeSeriesResponse::class, $request); } } diff --git a/Monitoring/src/V3/Gapic/NotificationChannelServiceGapicClient.php b/Monitoring/src/V3/Gapic/NotificationChannelServiceGapicClient.php index 9af453c66f1..3e97ff949f8 100644 --- a/Monitoring/src/V3/Gapic/NotificationChannelServiceGapicClient.php +++ b/Monitoring/src/V3/Gapic/NotificationChannelServiceGapicClient.php @@ -17,9 +17,9 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/notification_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/notification_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3\Gapic; @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; + use Google\ApiCore\PathTemplate; use Google\ApiCore\RequestParamsHeaderDescriptor; use Google\ApiCore\RetrySettings; @@ -62,32 +63,18 @@ * ``` * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { - * $formattedName = $notificationChannelServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $notificationChannelServiceClient->listNotificationChannelDescriptors($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $notificationChannelServiceClient->listNotificationChannelDescriptors($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $name = 'name'; + * $notificationChannel = new Google\Cloud\Monitoring\V3\NotificationChannel(); + * $response = $notificationChannelServiceClient->createNotificationChannel($name, $notificationChannel); * } finally { * $notificationChannelServiceClient->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. + * 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. */ class NotificationChannelServiceGapicClient { @@ -120,35 +107,66 @@ class NotificationChannelServiceGapicClient 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/monitoring', 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', ]; + + private static $folderChannelDescriptorNameTemplate; + + private static $folderNotificationChannelNameTemplate; + private static $notificationChannelNameTemplate; + private static $notificationChannelDescriptorNameTemplate; - private static $projectNameTemplate; + + private static $organizationChannelDescriptorNameTemplate; + + private static $organizationNotificationChannelNameTemplate; + + private static $projectChannelDescriptorNameTemplate; + + private static $projectNotificationChannelNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() { return [ 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__.'/../resources/notification_channel_service_client_config.json', - 'descriptorsConfigPath' => __DIR__.'/../resources/notification_channel_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__.'/../resources/notification_channel_service_grpc_config.json', + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/notification_channel_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/notification_channel_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/notification_channel_service_grpc_config.json', 'credentialsConfig' => [ - 'scopes' => self::$serviceScopes, + 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__.'/../resources/notification_channel_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/notification_channel_service_rest_client_config.php', ], ], ]; } + private static function getFolderChannelDescriptorNameTemplate() + { + if (self::$folderChannelDescriptorNameTemplate == null) { + self::$folderChannelDescriptorNameTemplate = new PathTemplate('folders/{folder}/notificationChannelDescriptors/{channel_descriptor}'); + } + + return self::$folderChannelDescriptorNameTemplate; + } + + private static function getFolderNotificationChannelNameTemplate() + { + if (self::$folderNotificationChannelNameTemplate == null) { + self::$folderNotificationChannelNameTemplate = new PathTemplate('folders/{folder}/notificationChannels/{notification_channel}'); + } + + return self::$folderNotificationChannelNameTemplate; + } + private static function getNotificationChannelNameTemplate() { - if (null == self::$notificationChannelNameTemplate) { + if (self::$notificationChannelNameTemplate == null) { self::$notificationChannelNameTemplate = new PathTemplate('projects/{project}/notificationChannels/{notification_channel}'); } @@ -157,29 +175,61 @@ private static function getNotificationChannelNameTemplate() private static function getNotificationChannelDescriptorNameTemplate() { - if (null == self::$notificationChannelDescriptorNameTemplate) { + if (self::$notificationChannelDescriptorNameTemplate == null) { self::$notificationChannelDescriptorNameTemplate = new PathTemplate('projects/{project}/notificationChannelDescriptors/{channel_descriptor}'); } return self::$notificationChannelDescriptorNameTemplate; } - private static function getProjectNameTemplate() + private static function getOrganizationChannelDescriptorNameTemplate() + { + if (self::$organizationChannelDescriptorNameTemplate == null) { + self::$organizationChannelDescriptorNameTemplate = new PathTemplate('organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}'); + } + + return self::$organizationChannelDescriptorNameTemplate; + } + + private static function getOrganizationNotificationChannelNameTemplate() + { + if (self::$organizationNotificationChannelNameTemplate == null) { + self::$organizationNotificationChannelNameTemplate = new PathTemplate('organizations/{organization}/notificationChannels/{notification_channel}'); + } + + return self::$organizationNotificationChannelNameTemplate; + } + + private static function getProjectChannelDescriptorNameTemplate() { - if (null == self::$projectNameTemplate) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); + if (self::$projectChannelDescriptorNameTemplate == null) { + self::$projectChannelDescriptorNameTemplate = new PathTemplate('projects/{project}/notificationChannelDescriptors/{channel_descriptor}'); } - return self::$projectNameTemplate; + return self::$projectChannelDescriptorNameTemplate; + } + + private static function getProjectNotificationChannelNameTemplate() + { + if (self::$projectNotificationChannelNameTemplate == null) { + self::$projectNotificationChannelNameTemplate = new PathTemplate('projects/{project}/notificationChannels/{notification_channel}'); + } + + return self::$projectNotificationChannelNameTemplate; } private static function getPathTemplateMap() { - if (null == self::$pathTemplateMap) { + if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ + 'folderChannelDescriptor' => self::getFolderChannelDescriptorNameTemplate(), + 'folderNotificationChannel' => self::getFolderNotificationChannelNameTemplate(), 'notificationChannel' => self::getNotificationChannelNameTemplate(), 'notificationChannelDescriptor' => self::getNotificationChannelDescriptorNameTemplate(), - 'project' => self::getProjectNameTemplate(), + 'organizationChannelDescriptor' => self::getOrganizationChannelDescriptorNameTemplate(), + 'organizationNotificationChannel' => self::getOrganizationNotificationChannelNameTemplate(), + 'projectChannelDescriptor' => self::getProjectChannelDescriptorNameTemplate(), + 'projectNotificationChannel' => self::getProjectNotificationChannelNameTemplate(), ]; } @@ -187,8 +237,42 @@ private static function getPathTemplateMap() } /** - * Formats a string containing the fully-qualified path to represent - * a notification_channel resource. + * Formats a string containing the fully-qualified path to represent a + * folder_channel_descriptor resource. + * + * @param string $folder + * @param string $channelDescriptor + * + * @return string The formatted folder_channel_descriptor resource. + */ + public static function folderChannelDescriptorName($folder, $channelDescriptor) + { + return self::getFolderChannelDescriptorNameTemplate()->render([ + 'folder' => $folder, + 'channel_descriptor' => $channelDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_notification_channel resource. + * + * @param string $folder + * @param string $notificationChannel + * + * @return string The formatted folder_notification_channel resource. + */ + public static function folderNotificationChannelName($folder, $notificationChannel) + { + return self::getFolderNotificationChannelNameTemplate()->render([ + 'folder' => $folder, + 'notification_channel' => $notificationChannel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * notification_channel resource. * * @param string $project * @param string $notificationChannel @@ -204,8 +288,8 @@ public static function notificationChannelName($project, $notificationChannel) } /** - * Formats a string containing the fully-qualified path to represent - * a notification_channel_descriptor resource. + * Formats a string containing the fully-qualified path to represent a + * notification_channel_descriptor resource. * * @param string $project * @param string $channelDescriptor @@ -221,17 +305,70 @@ public static function notificationChannelDescriptorName($project, $channelDescr } /** - * Formats a string containing the fully-qualified path to represent - * a project resource. + * Formats a string containing the fully-qualified path to represent a + * organization_channel_descriptor resource. + * + * @param string $organization + * @param string $channelDescriptor + * + * @return string The formatted organization_channel_descriptor resource. + */ + public static function organizationChannelDescriptorName($organization, $channelDescriptor) + { + return self::getOrganizationChannelDescriptorNameTemplate()->render([ + 'organization' => $organization, + 'channel_descriptor' => $channelDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_notification_channel resource. + * + * @param string $organization + * @param string $notificationChannel + * + * @return string The formatted organization_notification_channel resource. + */ + public static function organizationNotificationChannelName($organization, $notificationChannel) + { + return self::getOrganizationNotificationChannelNameTemplate()->render([ + 'organization' => $organization, + 'notification_channel' => $notificationChannel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_channel_descriptor resource. + * + * @param string $project + * @param string $channelDescriptor + * + * @return string The formatted project_channel_descriptor resource. + */ + public static function projectChannelDescriptorName($project, $channelDescriptor) + { + return self::getProjectChannelDescriptorNameTemplate()->render([ + 'project' => $project, + 'channel_descriptor' => $channelDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_notification_channel resource. * * @param string $project + * @param string $notificationChannel * - * @return string The formatted project resource. + * @return string The formatted project_notification_channel resource. */ - public static function projectName($project) + public static function projectNotificationChannelName($project, $notificationChannel) { - return self::getProjectNameTemplate()->render([ + return self::getProjectNotificationChannelNameTemplate()->render([ 'project' => $project, + 'notification_channel' => $notificationChannel, ]); } @@ -239,14 +376,20 @@ public static function projectName($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 + * - folderChannelDescriptor: folders/{folder}/notificationChannelDescriptors/{channel_descriptor} + * - folderNotificationChannel: folders/{folder}/notificationChannels/{notification_channel} * - notificationChannel: projects/{project}/notificationChannels/{notification_channel} * - notificationChannelDescriptor: projects/{project}/notificationChannelDescriptors/{channel_descriptor} - * - project: projects/{project}. + * - organizationChannelDescriptor: organizations/{organization}/notificationChannelDescriptors/{channel_descriptor} + * - organizationNotificationChannel: organizations/{organization}/notificationChannels/{notification_channel} + * - projectChannelDescriptor: projects/{project}/notificationChannelDescriptors/{channel_descriptor} + * - projectNotificationChannel: projects/{project}/notificationChannels/{notification_channel} * - * 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. + * 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 @@ -258,7 +401,6 @@ public static function projectName($project) 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"); @@ -274,6 +416,7 @@ public static function parseName($formattedName, $template = null) // Swallow the exception to continue trying other path templates } } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); } @@ -281,7 +424,7 @@ public static function parseName($formattedName, $template = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress * **Deprecated**. This option will be removed in a future major release. Please @@ -298,35 +441,38 @@ public static function parseName($formattedName, $template = null) * {@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()}. + * 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. + * 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. + * 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 + * $serviceAddress 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' => [...] + * '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 @@ -338,480 +484,449 @@ public function __construct(array $options = []) } /** - * Lists the descriptors for supported channel types. The use of descriptors - * makes it possible for new channel types to be dynamically added. + * Creates a new notification channel, representing a single notification + * endpoint such as an email address, SMS number, or PagerDuty service. * * Sample code: * ``` * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { - * $formattedName = $notificationChannelServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $notificationChannelServiceClient->listNotificationChannelDescriptors($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $notificationChannelServiceClient->listNotificationChannelDescriptors($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $name = 'name'; + * $notificationChannel = new Google\Cloud\Monitoring\V3\NotificationChannel(); + * $response = $notificationChannelServiceClient->createNotificationChannel($name, $notificationChannel); * } finally { * $notificationChannelServiceClient->close(); * } * ``` * - * @param string $name Required. The REST resource name of the parent from which to retrieve - * the notification channel descriptors. The expected syntax is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] + * projects/[PROJECT_ID_OR_NUMBER] * - * Note that this names the parent container in which to look for the - * descriptors; to retrieve a single descriptor by name, use the - * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] - * operation, instead. - * @param array $optionalArgs { - * Optional. + * This names the container into which the channel will be + * written, this does not name the newly created channel. The resulting + * channel's name will have a normalized version of this field as a prefix, + * but will add `/notificationChannels/[CHANNEL_ID]` to identify the channel. + * @param NotificationChannel $notificationChannel Required. The definition of the `NotificationChannel` to create. + * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse + * @return \Google\Cloud\Monitoring\V3\NotificationChannel * * @throws ApiException if the remote call fails */ - public function listNotificationChannelDescriptors($name, array $optionalArgs = []) + public function createNotificationChannel($name, $notificationChannel, array $optionalArgs = []) { - $request = new ListNotificationChannelDescriptorsRequest(); + $request = new CreateNotificationChannelRequest(); + $requestParamHeaders = []; $request->setName($name); - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListNotificationChannelDescriptors', - $optionalArgs, - ListNotificationChannelDescriptorsResponse::class, - $request - ); + $request->setNotificationChannel($notificationChannel); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateNotificationChannel', NotificationChannel::class, $optionalArgs, $request)->wait(); } /** - * Gets a single channel descriptor. The descriptor indicates which fields - * are expected / permitted for a notification channel of the given type. + * Deletes a notification channel. * * Sample code: * ``` * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { - * $formattedName = $notificationChannelServiceClient->notificationChannelDescriptorName('[PROJECT]', '[CHANNEL_DESCRIPTOR]'); - * $response = $notificationChannelServiceClient->getNotificationChannelDescriptor($formattedName); + * $formattedName = $notificationChannelServiceClient->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); + * $notificationChannelServiceClient->deleteNotificationChannel($formattedName); * } finally { * $notificationChannelServiceClient->close(); * } * ``` * - * @param string $name Required. The channel type for which to execute the request. The format is: + * @param string $name Required. The channel for which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/notificationChannelDescriptors/[CHANNEL_TYPE] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] + * @param array $optionalArgs { + * Optional. * + * @type bool $force + * If true, the notification channel will be deleted regardless of its + * use in alert policies (the policies will be updated to remove the + * channel). If false, channels that are still referenced by an existing + * alerting policy will fail to be deleted in a delete operation. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\NotificationChannelDescriptor - * * @throws ApiException if the remote call fails */ - public function getNotificationChannelDescriptor($name, array $optionalArgs = []) + public function deleteNotificationChannel($name, array $optionalArgs = []) { - $request = new GetNotificationChannelDescriptorRequest(); + $request = new DeleteNotificationChannelRequest(); + $requestParamHeaders = []; $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['force'])) { + $request->setForce($optionalArgs['force']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetNotificationChannelDescriptor', - NotificationChannelDescriptor::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteNotificationChannel', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * Lists the notification channels that have been created for the project. + * Gets a single notification channel. The channel includes the relevant + * configuration details with which the channel was created. However, the + * response may truncate or omit passwords, API keys, or other private key + * matter and thus the response may not be 100% identical to the information + * that was supplied in the call to the create method. * * Sample code: * ``` * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { - * $formattedName = $notificationChannelServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $notificationChannelServiceClient->listNotificationChannels($formattedName); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $notificationChannelServiceClient->listNotificationChannels($formattedName); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $formattedName = $notificationChannelServiceClient->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); + * $response = $notificationChannelServiceClient->getNotificationChannel($formattedName); * } finally { * $notificationChannelServiceClient->close(); * } * ``` * - * @param string $name Required. The project on which to execute the request. The format is: + * @param string $name Required. The channel for which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] - * - * This names the container - * in which to look for the notification channels; it does not name a - * specific channel. To query a specific channel by REST resource name, use - * the - * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] - * operation. - * @param array $optionalArgs { - * Optional. - * - * @type string $filter - * If provided, this field specifies the criteria that must be met by - * notification channels to be included in the response. - * - * For more details, see [sorting and - * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). - * @type string $orderBy - * A comma-separated list of fields by which to sort the result. Supports - * the same set of fields as in `filter`. Entries can be prefixed with - * a minus sign to sort in descending rather than ascending order. + * projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] + * @param array $optionalArgs { + * Optional. * - * For more details, see [sorting and - * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). - * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse + * @return \Google\Cloud\Monitoring\V3\NotificationChannel * * @throws ApiException if the remote call fails */ - public function listNotificationChannels($name, array $optionalArgs = []) + public function getNotificationChannel($name, array $optionalArgs = []) { - $request = new ListNotificationChannelsRequest(); + $request = new GetNotificationChannelRequest(); + $requestParamHeaders = []; $request->setName($name); - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListNotificationChannels', - $optionalArgs, - ListNotificationChannelsResponse::class, - $request - ); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetNotificationChannel', NotificationChannel::class, $optionalArgs, $request)->wait(); } /** - * Gets a single notification channel. The channel includes the relevant - * configuration details with which the channel was created. However, the - * response may truncate or omit passwords, API keys, or other private key - * matter and thus the response may not be 100% identical to the information - * that was supplied in the call to the create method. + * Gets a single channel descriptor. The descriptor indicates which fields + * are expected / permitted for a notification channel of the given type. * * Sample code: * ``` * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { - * $formattedName = $notificationChannelServiceClient->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - * $response = $notificationChannelServiceClient->getNotificationChannel($formattedName); + * $formattedName = $notificationChannelServiceClient->notificationChannelDescriptorName('[PROJECT]', '[CHANNEL_DESCRIPTOR]'); + * $response = $notificationChannelServiceClient->getNotificationChannelDescriptor($formattedName); * } finally { * $notificationChannelServiceClient->close(); * } * ``` * - * @param string $name Required. The channel for which to execute the request. The format is: + * @param string $name Required. The channel type for which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/notificationChannelDescriptors/[CHANNEL_TYPE] + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\NotificationChannel + * @return \Google\Cloud\Monitoring\V3\NotificationChannelDescriptor * * @throws ApiException if the remote call fails */ - public function getNotificationChannel($name, array $optionalArgs = []) + public function getNotificationChannelDescriptor($name, array $optionalArgs = []) { - $request = new GetNotificationChannelRequest(); + $request = new GetNotificationChannelDescriptorRequest(); + $requestParamHeaders = []; $request->setName($name); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetNotificationChannel', - NotificationChannel::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetNotificationChannelDescriptor', NotificationChannelDescriptor::class, $optionalArgs, $request)->wait(); } /** - * Creates a new notification channel, representing a single notification - * endpoint such as an email address, SMS number, or PagerDuty service. + * Requests a verification code for an already verified channel that can then + * be used in a call to VerifyNotificationChannel() on a different channel + * with an equivalent identity in the same or in a different project. This + * makes it possible to copy a channel between projects without requiring + * manual reverification of the channel. If the channel is not in the + * verified state, this method will fail (in other words, this may only be + * used if the SendNotificationChannelVerificationCode and + * VerifyNotificationChannel paths have already been used to put the given + * channel into the verified state). + * + * There is no guarantee that the verification codes returned by this method + * will be of a similar structure or form as the ones that are delivered + * to the channel via SendNotificationChannelVerificationCode; while + * VerifyNotificationChannel() will recognize both the codes delivered via + * SendNotificationChannelVerificationCode() and returned from + * GetNotificationChannelVerificationCode(), it is typically the case that + * the verification codes delivered via + * SendNotificationChannelVerificationCode() will be shorter and also + * have a shorter expiration (e.g. codes such as "G-123456") whereas + * GetVerificationCode() will typically return a much longer, websafe base + * 64 encoded string that has a longer expiration time. * * Sample code: * ``` * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { - * $formattedName = $notificationChannelServiceClient->projectName('[PROJECT]'); - * $notificationChannel = new Google\Cloud\Monitoring\V3\NotificationChannel(); - * $response = $notificationChannelServiceClient->createNotificationChannel($formattedName, $notificationChannel); + * $formattedName = $notificationChannelServiceClient->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); + * $response = $notificationChannelServiceClient->getNotificationChannelVerificationCode($formattedName); * } finally { * $notificationChannelServiceClient->close(); * } * ``` * - * @param string $name Required. The project on which to execute the request. The format is: - * - * projects/[PROJECT_ID_OR_NUMBER] - * - * This names the container into which the channel will be - * written, this does not name the newly created channel. The resulting - * channel's name will have a normalized version of this field as a prefix, - * but will add `/notificationChannels/[CHANNEL_ID]` to identify the channel. - * @param NotificationChannel $notificationChannel Required. The definition of the `NotificationChannel` to create. - * @param array $optionalArgs { - * Optional. + * @param string $name Required. The notification channel for which a verification code is to be generated + * and retrieved. This must name a channel that is already verified; if + * the specified channel is not verified, the request will fail. + * @param array $optionalArgs { + * Optional. * + * @type Timestamp $expireTime + * The desired expiration time. If specified, the API will guarantee that + * the returned code will not be valid after the specified timestamp; + * however, the API cannot guarantee that the returned code will be + * valid for at least as long as the requested time (the API puts an upper + * bound on the amount of time for which a code may be valid). If omitted, + * a default expiration will be used, which may be less than the max + * permissible expiration (so specifying an expiration may extend the + * code's lifetime over omitting an expiration, even though the API does + * impose an upper limit on the maximum expiration that is permitted). * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\NotificationChannel + * @return \Google\Cloud\Monitoring\V3\GetNotificationChannelVerificationCodeResponse * * @throws ApiException if the remote call fails */ - public function createNotificationChannel($name, $notificationChannel, array $optionalArgs = []) + public function getNotificationChannelVerificationCode($name, array $optionalArgs = []) { - $request = new CreateNotificationChannelRequest(); + $request = new GetNotificationChannelVerificationCodeRequest(); + $requestParamHeaders = []; $request->setName($name); - $request->setNotificationChannel($notificationChannel); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['expireTime'])) { + $request->setExpireTime($optionalArgs['expireTime']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'CreateNotificationChannel', - NotificationChannel::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetNotificationChannelVerificationCode', GetNotificationChannelVerificationCodeResponse::class, $optionalArgs, $request)->wait(); } /** - * Updates a notification channel. Fields not specified in the field mask - * remain unchanged. + * Lists the descriptors for supported channel types. The use of descriptors + * makes it possible for new channel types to be dynamically added. * * Sample code: * ``` * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { - * $notificationChannel = new Google\Cloud\Monitoring\V3\NotificationChannel(); - * $response = $notificationChannelServiceClient->updateNotificationChannel($notificationChannel); + * $name = 'name'; + * // Iterate over pages of elements + * $pagedResponse = $notificationChannelServiceClient->listNotificationChannelDescriptors($name); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $notificationChannelServiceClient->listNotificationChannelDescriptors($name); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $notificationChannelServiceClient->close(); * } * ``` * - * @param NotificationChannel $notificationChannel Required. A description of the changes to be applied to the specified - * notification channel. The description must provide a definition for - * fields to be updated; the names of these fields should also be - * included in the `update_mask`. - * @param array $optionalArgs { - * Optional. + * @param string $name Required. The REST resource name of the parent from which to retrieve + * the notification channel descriptors. The expected syntax is: * - * @type FieldMask $updateMask - * The fields to update. + * projects/[PROJECT_ID_OR_NUMBER] + * + * Note that this + * [names](https://cloud.google.com/monitoring/api/v3#project_name) the parent + * container in which to look for the descriptors; to retrieve a single + * descriptor by name, use the + * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] + * operation, instead. + * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\NotificationChannel + * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails */ - public function updateNotificationChannel($notificationChannel, array $optionalArgs = []) + public function listNotificationChannelDescriptors($name, array $optionalArgs = []) { - $request = new UpdateNotificationChannelRequest(); - $request->setNotificationChannel($notificationChannel); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); + $request = new ListNotificationChannelDescriptorsRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'notification_channel.name' => $request->getNotificationChannel()->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'UpdateNotificationChannel', - NotificationChannel::class, - $optionalArgs, - $request - )->wait(); + 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('ListNotificationChannelDescriptors', $optionalArgs, ListNotificationChannelDescriptorsResponse::class, $request); } /** - * Deletes a notification channel. + * Lists the notification channels that have been created for the project. * * Sample code: * ``` * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { - * $formattedName = $notificationChannelServiceClient->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - * $notificationChannelServiceClient->deleteNotificationChannel($formattedName); + * $name = 'name'; + * // Iterate over pages of elements + * $pagedResponse = $notificationChannelServiceClient->listNotificationChannels($name); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $notificationChannelServiceClient->listNotificationChannels($name); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $notificationChannelServiceClient->close(); * } * ``` * - * @param string $name Required. The channel for which to execute the request. The format is: + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER] * - * @type bool $force - * If true, the notification channel will be deleted regardless of its - * use in alert policies (the policies will be updated to remove the - * channel). If false, channels that are still referenced by an existing - * alerting policy will fail to be deleted in a delete operation. + * This names the container + * in which to look for the notification channels; it does not name a + * specific channel. To query a specific channel by REST resource name, use + * the + * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] + * operation. + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * If provided, this field specifies the criteria that must be met by + * notification channels to be included in the response. + * + * For more details, see [sorting and + * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). + * @type string $orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of fields as in `filter`. Entries can be prefixed with + * a minus sign to sort in descending rather than ascending order. + * + * For more details, see [sorting and + * filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering). + * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * + * @return \Google\ApiCore\PagedListResponse + * * @throws ApiException if the remote call fails */ - public function deleteNotificationChannel($name, array $optionalArgs = []) + public function listNotificationChannels($name, array $optionalArgs = []) { - $request = new DeleteNotificationChannelRequest(); + $request = new ListNotificationChannelsRequest(); + $requestParamHeaders = []; $request->setName($name); - if (isset($optionalArgs['force'])) { - $request->setForce($optionalArgs['force']); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'DeleteNotificationChannel', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + if (isset($optionalArgs['orderBy'])) { + $request->setOrderBy($optionalArgs['orderBy']); + } + + 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('ListNotificationChannels', $optionalArgs, ListNotificationChannelsResponse::class, $request); } /** @@ -831,13 +946,13 @@ public function deleteNotificationChannel($name, array $optionalArgs = []) * * @param string $name Required. The notification channel to which to send a verification code. * @param array $optionalArgs { - * Optional. + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @throws ApiException if the remote call fails @@ -845,105 +960,62 @@ public function deleteNotificationChannel($name, array $optionalArgs = []) public function sendNotificationChannelVerificationCode($name, array $optionalArgs = []) { $request = new SendNotificationChannelVerificationCodeRequest(); + $requestParamHeaders = []; $request->setName($name); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'SendNotificationChannelVerificationCode', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('SendNotificationChannelVerificationCode', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * Requests a verification code for an already verified channel that can then - * be used in a call to VerifyNotificationChannel() on a different channel - * with an equivalent identity in the same or in a different project. This - * makes it possible to copy a channel between projects without requiring - * manual reverification of the channel. If the channel is not in the - * verified state, this method will fail (in other words, this may only be - * used if the SendNotificationChannelVerificationCode and - * VerifyNotificationChannel paths have already been used to put the given - * channel into the verified state). - * - * There is no guarantee that the verification codes returned by this method - * will be of a similar structure or form as the ones that are delivered - * to the channel via SendNotificationChannelVerificationCode; while - * VerifyNotificationChannel() will recognize both the codes delivered via - * SendNotificationChannelVerificationCode() and returned from - * GetNotificationChannelVerificationCode(), it is typically the case that - * the verification codes delivered via - * SendNotificationChannelVerificationCode() will be shorter and also - * have a shorter expiration (e.g. codes such as "G-123456") whereas - * GetVerificationCode() will typically return a much longer, websafe base - * 64 encoded string that has a longer expiration time. + * Updates a notification channel. Fields not specified in the field mask + * remain unchanged. * * Sample code: * ``` * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { - * $formattedName = $notificationChannelServiceClient->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - * $response = $notificationChannelServiceClient->getNotificationChannelVerificationCode($formattedName); + * $notificationChannel = new Google\Cloud\Monitoring\V3\NotificationChannel(); + * $response = $notificationChannelServiceClient->updateNotificationChannel($notificationChannel); * } finally { * $notificationChannelServiceClient->close(); * } * ``` * - * @param string $name Required. The notification channel for which a verification code is to be generated - * and retrieved. This must name a channel that is already verified; if - * the specified channel is not verified, the request will fail. - * @param array $optionalArgs { - * Optional. + * @param NotificationChannel $notificationChannel Required. A description of the changes to be applied to the specified + * notification channel. The description must provide a definition for + * fields to be updated; the names of these fields should also be + * included in the `update_mask`. + * @param array $optionalArgs { + * Optional. * - * @type Timestamp $expireTime - * The desired expiration time. If specified, the API will guarantee that - * the returned code will not be valid after the specified timestamp; - * however, the API cannot guarantee that the returned code will be - * valid for at least as long as the requested time (the API puts an upper - * bound on the amount of time for which a code may be valid). If omitted, - * a default expiration will be used, which may be less than the max - * permissible expiration (so specifying an expiration may extend the - * code's lifetime over omitting an expiration, even though the API does - * impose an upper limit on the maximum expiration that is permitted). + * @type FieldMask $updateMask + * The fields to update. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\GetNotificationChannelVerificationCodeResponse + * @return \Google\Cloud\Monitoring\V3\NotificationChannel * * @throws ApiException if the remote call fails */ - public function getNotificationChannelVerificationCode($name, array $optionalArgs = []) + public function updateNotificationChannel($notificationChannel, array $optionalArgs = []) { - $request = new GetNotificationChannelVerificationCodeRequest(); - $request->setName($name); - if (isset($optionalArgs['expireTime'])) { - $request->setExpireTime($optionalArgs['expireTime']); + $request = new UpdateNotificationChannelRequest(); + $requestParamHeaders = []; + $request->setNotificationChannel($notificationChannel); + $requestParamHeaders['notification_channel.name'] = $notificationChannel->getName(); + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetNotificationChannelVerificationCode', - GetNotificationChannelVerificationCodeResponse::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateNotificationChannel', NotificationChannel::class, $optionalArgs, $request)->wait(); } /** @@ -956,7 +1028,7 @@ public function getNotificationChannelVerificationCode($name, array $optionalArg * $notificationChannelServiceClient = new Google\Cloud\Monitoring\V3\NotificationChannelServiceClient(); * try { * $formattedName = $notificationChannelServiceClient->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - * $code = ''; + * $code = 'code'; * $response = $notificationChannelServiceClient->verifyNotificationChannel($formattedName, $code); * } finally { * $notificationChannelServiceClient->close(); @@ -972,13 +1044,13 @@ public function getNotificationChannelVerificationCode($name, array $optionalArg * guaranteed that the code is valid UTF-8; one should not * make any assumptions regarding the structure or format of the code). * @param array $optionalArgs { - * Optional. + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Cloud\Monitoring\V3\NotificationChannel @@ -988,21 +1060,12 @@ public function getNotificationChannelVerificationCode($name, array $optionalArg public function verifyNotificationChannel($name, $code, array $optionalArgs = []) { $request = new VerifyNotificationChannelRequest(); + $requestParamHeaders = []; $request->setName($name); $request->setCode($code); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'VerifyNotificationChannel', - NotificationChannel::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('VerifyNotificationChannel', NotificationChannel::class, $optionalArgs, $request)->wait(); } } diff --git a/Monitoring/src/V3/Gapic/QueryServiceGapicClient.php b/Monitoring/src/V3/Gapic/QueryServiceGapicClient.php new file mode 100644 index 00000000000..acd0e3ef1f7 --- /dev/null +++ b/Monitoring/src/V3/Gapic/QueryServiceGapicClient.php @@ -0,0 +1,261 @@ +queryTimeSeries($name, $query); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $queryServiceClient->queryTimeSeries($name, $query); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $queryServiceClient->close(); + * } + * ``` + */ +class QueryServiceGapicClient +{ + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.monitoring.v3.QueryService'; + + /** + * The default address of the service. + */ + const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** + * 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.read', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/query_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/query_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/query_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/query_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $serviceAddress + * **Deprecated**. This option will be removed in a future major release. Please + * utilize the `$apiEndpoint` option instead. + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'monitoring.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 + * $serviceAddress 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); + } + + /** + * Queries time series using Monitoring Query Language. This method does not require a Workspace. + * + * Sample code: + * ``` + * $queryServiceClient = new QueryServiceClient(); + * try { + * $name = 'name'; + * $query = 'query'; + * // Iterate over pages of elements + * $pagedResponse = $queryServiceClient->queryTimeSeries($name, $query); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $queryServiceClient->queryTimeSeries($name, $query); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $queryServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER] + * @param string $query Required. The query in the [Monitoring Query + * Language](https://cloud.google.com/monitoring/mql/reference) format. + * The default time zone is in UTC. + * @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 Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function queryTimeSeries($name, $query, array $optionalArgs = []) + { + $request = new QueryTimeSeriesRequest(); + $requestParamHeaders = []; + $request->setName($name); + $request->setQuery($query); + $requestParamHeaders['name'] = $name; + 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('QueryTimeSeries', $optionalArgs, QueryTimeSeriesResponse::class, $request); + } +} diff --git a/Monitoring/src/V3/Gapic/ServiceMonitoringServiceGapicClient.php b/Monitoring/src/V3/Gapic/ServiceMonitoringServiceGapicClient.php index e781be016cf..c50d0c4cba4 100644 --- a/Monitoring/src/V3/Gapic/ServiceMonitoringServiceGapicClient.php +++ b/Monitoring/src/V3/Gapic/ServiceMonitoringServiceGapicClient.php @@ -17,9 +17,9 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/service_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/service_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3\Gapic; @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; + use Google\ApiCore\PathTemplate; use Google\ApiCore\RequestParamsHeaderDescriptor; use Google\ApiCore\RetrySettings; @@ -63,18 +64,18 @@ * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $formattedParent = $serviceMonitoringServiceClient->projectName('[PROJECT]'); + * $parent = 'parent'; * $service = new Service(); - * $response = $serviceMonitoringServiceClient->createService($formattedParent, $service); + * $response = $serviceMonitoringServiceClient->createService($parent, $service); * } finally { * $serviceMonitoringServiceClient->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. + * 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. */ class ServiceMonitoringServiceGapicClient { @@ -107,44 +108,102 @@ class ServiceMonitoringServiceGapicClient 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/monitoring', 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', ]; - private static $projectNameTemplate; + + private static $folderServiceNameTemplate; + + private static $folderServiceServiceLevelObjectiveNameTemplate; + + private static $organizationServiceNameTemplate; + + private static $organizationServiceServiceLevelObjectiveNameTemplate; + + private static $projectServiceNameTemplate; + + private static $projectServiceServiceLevelObjectiveNameTemplate; + private static $serviceNameTemplate; + private static $serviceLevelObjectiveNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() { return [ 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__.'/../resources/service_monitoring_service_client_config.json', - 'descriptorsConfigPath' => __DIR__.'/../resources/service_monitoring_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__.'/../resources/service_monitoring_service_grpc_config.json', + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/service_monitoring_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/service_monitoring_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/service_monitoring_service_grpc_config.json', 'credentialsConfig' => [ - 'scopes' => self::$serviceScopes, + 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__.'/../resources/service_monitoring_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/service_monitoring_service_rest_client_config.php', ], ], ]; } - private static function getProjectNameTemplate() + private static function getFolderServiceNameTemplate() + { + if (self::$folderServiceNameTemplate == null) { + self::$folderServiceNameTemplate = new PathTemplate('folders/{folder}/services/{service}'); + } + + return self::$folderServiceNameTemplate; + } + + private static function getFolderServiceServiceLevelObjectiveNameTemplate() + { + if (self::$folderServiceServiceLevelObjectiveNameTemplate == null) { + self::$folderServiceServiceLevelObjectiveNameTemplate = new PathTemplate('folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}'); + } + + return self::$folderServiceServiceLevelObjectiveNameTemplate; + } + + private static function getOrganizationServiceNameTemplate() + { + if (self::$organizationServiceNameTemplate == null) { + self::$organizationServiceNameTemplate = new PathTemplate('organizations/{organization}/services/{service}'); + } + + return self::$organizationServiceNameTemplate; + } + + private static function getOrganizationServiceServiceLevelObjectiveNameTemplate() { - if (null == self::$projectNameTemplate) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); + if (self::$organizationServiceServiceLevelObjectiveNameTemplate == null) { + self::$organizationServiceServiceLevelObjectiveNameTemplate = new PathTemplate('organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}'); } - return self::$projectNameTemplate; + return self::$organizationServiceServiceLevelObjectiveNameTemplate; + } + + private static function getProjectServiceNameTemplate() + { + if (self::$projectServiceNameTemplate == null) { + self::$projectServiceNameTemplate = new PathTemplate('projects/{project}/services/{service}'); + } + + return self::$projectServiceNameTemplate; + } + + private static function getProjectServiceServiceLevelObjectiveNameTemplate() + { + if (self::$projectServiceServiceLevelObjectiveNameTemplate == null) { + self::$projectServiceServiceLevelObjectiveNameTemplate = new PathTemplate('projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}'); + } + + return self::$projectServiceServiceLevelObjectiveNameTemplate; } private static function getServiceNameTemplate() { - if (null == self::$serviceNameTemplate) { + if (self::$serviceNameTemplate == null) { self::$serviceNameTemplate = new PathTemplate('projects/{project}/services/{service}'); } @@ -153,7 +212,7 @@ private static function getServiceNameTemplate() private static function getServiceLevelObjectiveNameTemplate() { - if (null == self::$serviceLevelObjectiveNameTemplate) { + if (self::$serviceLevelObjectiveNameTemplate == null) { self::$serviceLevelObjectiveNameTemplate = new PathTemplate('projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}'); } @@ -162,9 +221,14 @@ private static function getServiceLevelObjectiveNameTemplate() private static function getPathTemplateMap() { - if (null == self::$pathTemplateMap) { + if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ - 'project' => self::getProjectNameTemplate(), + 'folderService' => self::getFolderServiceNameTemplate(), + 'folderServiceServiceLevelObjective' => self::getFolderServiceServiceLevelObjectiveNameTemplate(), + 'organizationService' => self::getOrganizationServiceNameTemplate(), + 'organizationServiceServiceLevelObjective' => self::getOrganizationServiceServiceLevelObjectiveNameTemplate(), + 'projectService' => self::getProjectServiceNameTemplate(), + 'projectServiceServiceLevelObjective' => self::getProjectServiceServiceLevelObjectiveNameTemplate(), 'service' => self::getServiceNameTemplate(), 'serviceLevelObjective' => self::getServiceLevelObjectiveNameTemplate(), ]; @@ -174,23 +238,116 @@ private static function getPathTemplateMap() } /** - * Formats a string containing the fully-qualified path to represent - * a project resource. + * Formats a string containing the fully-qualified path to represent a + * folder_service resource. + * + * @param string $folder + * @param string $service + * + * @return string The formatted folder_service resource. + */ + public static function folderServiceName($folder, $service) + { + return self::getFolderServiceNameTemplate()->render([ + 'folder' => $folder, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_service_service_level_objective resource. + * + * @param string $folder + * @param string $service + * @param string $serviceLevelObjective + * + * @return string The formatted folder_service_service_level_objective resource. + */ + public static function folderServiceServiceLevelObjectiveName($folder, $service, $serviceLevelObjective) + { + return self::getFolderServiceServiceLevelObjectiveNameTemplate()->render([ + 'folder' => $folder, + 'service' => $service, + 'service_level_objective' => $serviceLevelObjective, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_service resource. + * + * @param string $organization + * @param string $service + * + * @return string The formatted organization_service resource. + */ + public static function organizationServiceName($organization, $service) + { + return self::getOrganizationServiceNameTemplate()->render([ + 'organization' => $organization, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_service_service_level_objective resource. + * + * @param string $organization + * @param string $service + * @param string $serviceLevelObjective + * + * @return string The formatted organization_service_service_level_objective resource. + */ + public static function organizationServiceServiceLevelObjectiveName($organization, $service, $serviceLevelObjective) + { + return self::getOrganizationServiceServiceLevelObjectiveNameTemplate()->render([ + 'organization' => $organization, + 'service' => $service, + 'service_level_objective' => $serviceLevelObjective, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_service resource. * * @param string $project + * @param string $service * - * @return string The formatted project resource. + * @return string The formatted project_service resource. */ - public static function projectName($project) + public static function projectServiceName($project, $service) { - return self::getProjectNameTemplate()->render([ + return self::getProjectServiceNameTemplate()->render([ 'project' => $project, + 'service' => $service, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a service resource. + * Formats a string containing the fully-qualified path to represent a + * project_service_service_level_objective resource. + * + * @param string $project + * @param string $service + * @param string $serviceLevelObjective + * + * @return string The formatted project_service_service_level_objective resource. + */ + public static function projectServiceServiceLevelObjectiveName($project, $service, $serviceLevelObjective) + { + return self::getProjectServiceServiceLevelObjectiveNameTemplate()->render([ + 'project' => $project, + 'service' => $service, + 'service_level_objective' => $serviceLevelObjective, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. * * @param string $project * @param string $service @@ -206,8 +363,8 @@ public static function serviceName($project, $service) } /** - * Formats a string containing the fully-qualified path to represent - * a service_level_objective resource. + * Formats a string containing the fully-qualified path to represent a + * service_level_objective resource. * * @param string $project * @param string $service @@ -228,14 +385,20 @@ public static function serviceLevelObjectiveName($project, $service, $serviceLev * 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} + * - folderService: folders/{folder}/services/{service} + * - folderServiceServiceLevelObjective: folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective} + * - organizationService: organizations/{organization}/services/{service} + * - organizationServiceServiceLevelObjective: organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective} + * - projectService: projects/{project}/services/{service} + * - projectServiceServiceLevelObjective: projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective} * - service: projects/{project}/services/{service} - * - serviceLevelObjective: projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}. + * - serviceLevelObjective: projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective} * - * 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. + * 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 @@ -247,7 +410,6 @@ public static function serviceLevelObjectiveName($project, $service, $serviceLev 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"); @@ -263,6 +425,7 @@ public static function parseName($formattedName, $template = null) // Swallow the exception to continue trying other path templates } } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); } @@ -270,7 +433,7 @@ public static function parseName($formattedName, $template = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress * **Deprecated**. This option will be removed in a future major release. Please @@ -287,35 +450,38 @@ public static function parseName($formattedName, $template = null) * {@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()}. + * 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. + * 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. + * 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 + * $serviceAddress 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' => [...] + * '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 @@ -333,29 +499,30 @@ public function __construct(array $options = []) * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $formattedParent = $serviceMonitoringServiceClient->projectName('[PROJECT]'); + * $parent = 'parent'; * $service = new Service(); - * $response = $serviceMonitoringServiceClient->createService($formattedParent, $service); + * $response = $serviceMonitoringServiceClient->createService($parent, $service); * } finally { * $serviceMonitoringServiceClient->close(); * } * ``` * - * @param string $parent Required. Resource name of the parent workspace. The format is: + * @param string $parent Required. Resource [name](https://cloud.google.com/monitoring/api/v3#project_name) of + * the parent workspace. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] + * projects/[PROJECT_ID_OR_NUMBER] * @param Service $service Required. The `Service` to create. * @param array $optionalArgs { - * Optional. + * Optional. * * @type string $serviceId - * Optional. The Service id to use for this Service. If omitted, an id will be - * generated instead. Must match the pattern `[a-z0-9\-]+` + * Optional. The Service id to use for this Service. If omitted, an id will be + * generated instead. Must match the pattern `[a-z0-9\-]+` * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Cloud\Monitoring\V3\Service @@ -365,428 +532,355 @@ public function __construct(array $options = []) public function createService($parent, $service, array $optionalArgs = []) { $request = new CreateServiceRequest(); + $requestParamHeaders = []; $request->setParent($parent); $request->setService($service); + $requestParamHeaders['parent'] = $parent; if (isset($optionalArgs['serviceId'])) { $request->setServiceId($optionalArgs['serviceId']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'CreateService', - Service::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateService', Service::class, $optionalArgs, $request)->wait(); } /** - * Get the named `Service`. + * Create a `ServiceLevelObjective` for the given `Service`. * * Sample code: * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $formattedName = $serviceMonitoringServiceClient->serviceName('[PROJECT]', '[SERVICE]'); - * $response = $serviceMonitoringServiceClient->getService($formattedName); + * $formattedParent = $serviceMonitoringServiceClient->serviceName('[PROJECT]', '[SERVICE]'); + * $serviceLevelObjective = new ServiceLevelObjective(); + * $response = $serviceMonitoringServiceClient->createServiceLevelObjective($formattedParent, $serviceLevelObjective); * } finally { * $serviceMonitoringServiceClient->close(); * } * ``` * - * @param string $name Required. Resource name of the `Service`. The format is: + * @param string $parent Required. Resource name of the parent `Service`. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] + * @param ServiceLevelObjective $serviceLevelObjective Required. The `ServiceLevelObjective` to create. + * The provided `name` will be respected if no `ServiceLevelObjective` exists + * with this name. + * @param array $optionalArgs { + * Optional. * + * @type string $serviceLevelObjectiveId + * Optional. The ServiceLevelObjective id to use for this + * ServiceLevelObjective. If omitted, an id will be generated instead. Must + * match the pattern `[a-z0-9\-]+` * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\Service + * @return \Google\Cloud\Monitoring\V3\ServiceLevelObjective * * @throws ApiException if the remote call fails */ - public function getService($name, array $optionalArgs = []) + public function createServiceLevelObjective($parent, $serviceLevelObjective, array $optionalArgs = []) { - $request = new GetServiceRequest(); - $request->setName($name); + $request = new CreateServiceLevelObjectiveRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setServiceLevelObjective($serviceLevelObjective); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['serviceLevelObjectiveId'])) { + $request->setServiceLevelObjectiveId($optionalArgs['serviceLevelObjectiveId']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetService', - Service::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateServiceLevelObjective', ServiceLevelObjective::class, $optionalArgs, $request)->wait(); } /** - * List `Service`s for this workspace. + * Soft delete this `Service`. * * Sample code: * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $formattedParent = $serviceMonitoringServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $serviceMonitoringServiceClient->listServices($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $serviceMonitoringServiceClient->listServices($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $formattedName = $serviceMonitoringServiceClient->serviceName('[PROJECT]', '[SERVICE]'); + * $serviceMonitoringServiceClient->deleteService($formattedName); * } finally { * $serviceMonitoringServiceClient->close(); * } * ``` * - * @param string $parent Required. Resource name of the parent containing the listed services, either a - * project or a Monitoring Workspace. The formats are: + * @param string $name Required. Resource name of the `Service` to delete. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] - * workspaces/[HOST_PROJECT_ID_OR_NUMBER] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] + * @param array $optionalArgs { + * Optional. * - * @type string $filter - * A filter specifying what `Service`s to return. The filter currently - * supports the following fields: - * - * - `identifier_case` - * - `app_engine.module_id` - * - `cloud_endpoints.service` - * - `cluster_istio.location` - * - `cluster_istio.cluster_name` - * - `cluster_istio.service_namespace` - * - `cluster_istio.service_name` - * - * `identifier_case` refers to which option in the identifier oneof is - * populated. For example, the filter `identifier_case = "CUSTOM"` would match - * all services with a value for the `custom` field. Valid options are - * "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO". - * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse - * * @throws ApiException if the remote call fails */ - public function listServices($parent, array $optionalArgs = []) + public function deleteService($name, array $optionalArgs = []) { - $request = new ListServicesRequest(); - $request->setParent($parent); - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListServices', - $optionalArgs, - ListServicesResponse::class, - $request - ); + $request = new DeleteServiceRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteService', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * Update this `Service`. + * Delete the given `ServiceLevelObjective`. * * Sample code: * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $service = new Service(); - * $response = $serviceMonitoringServiceClient->updateService($service); + * $formattedName = $serviceMonitoringServiceClient->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); + * $serviceMonitoringServiceClient->deleteServiceLevelObjective($formattedName); * } finally { * $serviceMonitoringServiceClient->close(); * } * ``` * - * @param Service $service Required. The `Service` to draw updates from. - * The given `name` specifies the resource to update. - * @param array $optionalArgs { - * Optional. + * @param string $name Required. Resource name of the `ServiceLevelObjective` to delete. The format is: + * + * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME] + * @param array $optionalArgs { + * Optional. * - * @type FieldMask $updateMask - * A set of field paths defining which fields to use for the update. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\Service - * * @throws ApiException if the remote call fails */ - public function updateService($service, array $optionalArgs = []) + public function deleteServiceLevelObjective($name, array $optionalArgs = []) { - $request = new UpdateServiceRequest(); - $request->setService($service); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'service.name' => $request->getService()->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'UpdateService', - Service::class, - $optionalArgs, - $request - )->wait(); + $request = new DeleteServiceLevelObjectiveRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteServiceLevelObjective', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * Soft delete this `Service`. + * Get the named `Service`. * * Sample code: * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { * $formattedName = $serviceMonitoringServiceClient->serviceName('[PROJECT]', '[SERVICE]'); - * $serviceMonitoringServiceClient->deleteService($formattedName); + * $response = $serviceMonitoringServiceClient->getService($formattedName); * } finally { * $serviceMonitoringServiceClient->close(); * } * ``` * - * @param string $name Required. Resource name of the `Service` to delete. The format is: + * @param string $name Required. Resource name of the `Service`. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * + * @return \Google\Cloud\Monitoring\V3\Service + * * @throws ApiException if the remote call fails */ - public function deleteService($name, array $optionalArgs = []) + public function getService($name, array $optionalArgs = []) { - $request = new DeleteServiceRequest(); + $request = new GetServiceRequest(); + $requestParamHeaders = []; $request->setName($name); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'DeleteService', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetService', Service::class, $optionalArgs, $request)->wait(); } /** - * Create a `ServiceLevelObjective` for the given `Service`. + * Get a `ServiceLevelObjective` by name. * * Sample code: * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $formattedParent = $serviceMonitoringServiceClient->serviceName('[PROJECT]', '[SERVICE]'); - * $serviceLevelObjective = new ServiceLevelObjective(); - * $response = $serviceMonitoringServiceClient->createServiceLevelObjective($formattedParent, $serviceLevelObjective); + * $formattedName = $serviceMonitoringServiceClient->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); + * $response = $serviceMonitoringServiceClient->getServiceLevelObjective($formattedName); * } finally { * $serviceMonitoringServiceClient->close(); * } * ``` * - * @param string $parent Required. Resource name of the parent `Service`. The format is: + * @param string $name Required. Resource name of the `ServiceLevelObjective` to get. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] - * @param ServiceLevelObjective $serviceLevelObjective Required. The `ServiceLevelObjective` to create. - * The provided `name` will be respected if no `ServiceLevelObjective` exists - * with this name. - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME] + * @param array $optionalArgs { + * Optional. * - * @type string $serviceLevelObjectiveId - * Optional. The ServiceLevelObjective id to use for this - * ServiceLevelObjective. If omitted, an id will be generated instead. Must - * match the pattern `[a-z0-9\-]+` + * @type int $view + * View of the `ServiceLevelObjective` to return. If `DEFAULT`, return the + * `ServiceLevelObjective` as originally defined. If `EXPLICIT` and the + * `ServiceLevelObjective` is defined in terms of a `BasicSli`, replace the + * `BasicSli` with a `RequestBasedSli` spelling out how the SLI is computed. + * For allowed values, use constants defined on {@see \Google\Cloud\Monitoring\V3\ServiceLevelObjective\View} * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Cloud\Monitoring\V3\ServiceLevelObjective * * @throws ApiException if the remote call fails */ - public function createServiceLevelObjective($parent, $serviceLevelObjective, array $optionalArgs = []) + public function getServiceLevelObjective($name, array $optionalArgs = []) { - $request = new CreateServiceLevelObjectiveRequest(); - $request->setParent($parent); - $request->setServiceLevelObjective($serviceLevelObjective); - if (isset($optionalArgs['serviceLevelObjectiveId'])) { - $request->setServiceLevelObjectiveId($optionalArgs['serviceLevelObjectiveId']); + $request = new GetServiceLevelObjectiveRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['view'])) { + $request->setView($optionalArgs['view']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'CreateServiceLevelObjective', - ServiceLevelObjective::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetServiceLevelObjective', ServiceLevelObjective::class, $optionalArgs, $request)->wait(); } /** - * Get a `ServiceLevelObjective` by name. + * List the `ServiceLevelObjective`s for the given `Service`. * * Sample code: * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $formattedName = $serviceMonitoringServiceClient->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); - * $response = $serviceMonitoringServiceClient->getServiceLevelObjective($formattedName); + * $formattedParent = $serviceMonitoringServiceClient->serviceName('[PROJECT]', '[SERVICE]'); + * // Iterate over pages of elements + * $pagedResponse = $serviceMonitoringServiceClient->listServiceLevelObjectives($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $serviceMonitoringServiceClient->listServiceLevelObjectives($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $serviceMonitoringServiceClient->close(); * } * ``` * - * @param string $name Required. Resource name of the `ServiceLevelObjective` to get. The format is: + * @param string $parent Required. Resource name of the parent containing the listed SLOs, either a + * project or a Monitoring Workspace. The formats are: * - * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] + * workspaces/[HOST_PROJECT_ID_OR_NUMBER]/services/- + * @param array $optionalArgs { + * Optional. * + * @type string $filter + * A filter specifying what `ServiceLevelObjective`s to return. + * @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 int $view - * View of the `ServiceLevelObjective` to return. If `DEFAULT`, return the - * `ServiceLevelObjective` as originally defined. If `EXPLICIT` and the - * `ServiceLevelObjective` is defined in terms of a `BasicSli`, replace the - * `BasicSli` with a `RequestBasedSli` spelling out how the SLI is computed. - * For allowed values, use constants defined on {@see \Google\Cloud\Monitoring\V3\ServiceLevelObjective\View} + * View of the `ServiceLevelObjective`s to return. If `DEFAULT`, return each + * `ServiceLevelObjective` as originally defined. If `EXPLICIT` and the + * `ServiceLevelObjective` is defined in terms of a `BasicSli`, replace the + * `BasicSli` with a `RequestBasedSli` spelling out how the SLI is computed. + * For allowed values, use constants defined on {@see \Google\Cloud\Monitoring\V3\ServiceLevelObjective\View} * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\ServiceLevelObjective + * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails */ - public function getServiceLevelObjective($name, array $optionalArgs = []) + public function listServiceLevelObjectives($parent, array $optionalArgs = []) { - $request = new GetServiceLevelObjectiveRequest(); - $request->setName($name); + $request = new ListServiceLevelObjectivesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + if (isset($optionalArgs['view'])) { $request->setView($optionalArgs['view']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetServiceLevelObjective', - ServiceLevelObjective::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListServiceLevelObjectives', $optionalArgs, ListServiceLevelObjectivesResponse::class, $request); } /** - * List the `ServiceLevelObjective`s for the given `Service`. + * List `Service`s for this workspace. * * Sample code: * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $formattedParent = $serviceMonitoringServiceClient->serviceName('[PROJECT]', '[SERVICE]'); + * $parent = 'parent'; * // Iterate over pages of elements - * $pagedResponse = $serviceMonitoringServiceClient->listServiceLevelObjectives($formattedParent); + * $pagedResponse = $serviceMonitoringServiceClient->listServices($parent); * foreach ($pagedResponse->iteratePages() as $page) { * foreach ($page as $element) { * // doSomethingWith($element); * } * } - * - * * // Alternatively: - * * // Iterate through all elements - * $pagedResponse = $serviceMonitoringServiceClient->listServiceLevelObjectives($formattedParent); + * $pagedResponse = $serviceMonitoringServiceClient->listServices($parent); * foreach ($pagedResponse->iterateAllElements() as $element) { * // doSomethingWith($element); * } @@ -795,175 +889,169 @@ public function getServiceLevelObjective($name, array $optionalArgs = []) * } * ``` * - * @param string $parent Required. Resource name of the parent containing the listed SLOs, either a - * project or a Monitoring Workspace. The formats are: + * @param string $parent Required. Resource name of the parent containing the listed services, either a + * [project](https://cloud.google.com/monitoring/api/v3#project_name) or a + * Monitoring Workspace. The formats are: * - * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] - * workspaces/[HOST_PROJECT_ID_OR_NUMBER]/services/- - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER] + * workspaces/[HOST_PROJECT_ID_OR_NUMBER] + * @param array $optionalArgs { + * Optional. * * @type string $filter - * A filter specifying what `ServiceLevelObjective`s to return. + * A filter specifying what `Service`s to return. The filter currently + * supports the following fields: + * + * - `identifier_case` + * - `app_engine.module_id` + * - `cloud_endpoints.service` (reserved for future use) + * - `mesh_istio.mesh_uid` + * - `mesh_istio.service_namespace` + * - `mesh_istio.service_name` + * - `cluster_istio.location` (deprecated) + * - `cluster_istio.cluster_name` (deprecated) + * - `cluster_istio.service_namespace` (deprecated) + * - `cluster_istio.service_name` (deprecated) + * + * `identifier_case` refers to which option in the identifier oneof is + * populated. For example, the filter `identifier_case = "CUSTOM"` would match + * all services with a value for the `custom` field. Valid options are + * "CUSTOM", "APP_ENGINE", "MESH_ISTIO", plus "CLUSTER_ISTIO" (deprecated) + * and "CLOUD_ENDPOINTS" (reserved for future use). * @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. + * 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 int $view - * View of the `ServiceLevelObjective`s to return. If `DEFAULT`, return each - * `ServiceLevelObjective` as originally defined. If `EXPLICIT` and the - * `ServiceLevelObjective` is defined in terms of a `BasicSli`, replace the - * `BasicSli` with a `RequestBasedSli` spelling out how the SLI is computed. - * For allowed values, use constants defined on {@see \Google\Cloud\Monitoring\V3\ServiceLevelObjective\View} + * 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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails */ - public function listServiceLevelObjectives($parent, array $optionalArgs = []) + public function listServices($parent, array $optionalArgs = []) { - $request = new ListServiceLevelObjectivesRequest(); + $request = new ListServicesRequest(); + $requestParamHeaders = []; $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; if (isset($optionalArgs['filter'])) { $request->setFilter($optionalArgs['filter']); } + if (isset($optionalArgs['pageSize'])) { $request->setPageSize($optionalArgs['pageSize']); } + if (isset($optionalArgs['pageToken'])) { $request->setPageToken($optionalArgs['pageToken']); } - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListServiceLevelObjectives', - $optionalArgs, - ListServiceLevelObjectivesResponse::class, - $request - ); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListServices', $optionalArgs, ListServicesResponse::class, $request); } /** - * Update the given `ServiceLevelObjective`. + * Update this `Service`. * * Sample code: * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $serviceLevelObjective = new ServiceLevelObjective(); - * $response = $serviceMonitoringServiceClient->updateServiceLevelObjective($serviceLevelObjective); + * $service = new Service(); + * $response = $serviceMonitoringServiceClient->updateService($service); * } finally { * $serviceMonitoringServiceClient->close(); * } * ``` * - * @param ServiceLevelObjective $serviceLevelObjective Required. The `ServiceLevelObjective` to draw updates from. - * The given `name` specifies the resource to update. - * @param array $optionalArgs { - * Optional. + * @param Service $service Required. The `Service` to draw updates from. + * The given `name` specifies the resource to update. + * @param array $optionalArgs { + * Optional. * * @type FieldMask $updateMask - * A set of field paths defining which fields to use for the update. + * A set of field paths defining which fields to use for the update. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\ServiceLevelObjective + * @return \Google\Cloud\Monitoring\V3\Service * * @throws ApiException if the remote call fails */ - public function updateServiceLevelObjective($serviceLevelObjective, array $optionalArgs = []) + public function updateService($service, array $optionalArgs = []) { - $request = new UpdateServiceLevelObjectiveRequest(); - $request->setServiceLevelObjective($serviceLevelObjective); + $request = new UpdateServiceRequest(); + $requestParamHeaders = []; + $request->setService($service); + $requestParamHeaders['service.name'] = $service->getName(); if (isset($optionalArgs['updateMask'])) { $request->setUpdateMask($optionalArgs['updateMask']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'service_level_objective.name' => $request->getServiceLevelObjective()->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'UpdateServiceLevelObjective', - ServiceLevelObjective::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateService', Service::class, $optionalArgs, $request)->wait(); } /** - * Delete the given `ServiceLevelObjective`. + * Update the given `ServiceLevelObjective`. * * Sample code: * ``` * $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient(); * try { - * $formattedName = $serviceMonitoringServiceClient->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); - * $serviceMonitoringServiceClient->deleteServiceLevelObjective($formattedName); + * $serviceLevelObjective = new ServiceLevelObjective(); + * $response = $serviceMonitoringServiceClient->updateServiceLevelObjective($serviceLevelObjective); * } finally { * $serviceMonitoringServiceClient->close(); * } * ``` * - * @param string $name Required. Resource name of the `ServiceLevelObjective` to delete. The format is: - * - * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME] - * @param array $optionalArgs { - * Optional. + * @param ServiceLevelObjective $serviceLevelObjective Required. The `ServiceLevelObjective` to draw updates from. + * The given `name` specifies the resource to update. + * @param array $optionalArgs { + * Optional. * + * @type FieldMask $updateMask + * A set of field paths defining which fields to use for the update. * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * + * @return \Google\Cloud\Monitoring\V3\ServiceLevelObjective + * * @throws ApiException if the remote call fails */ - public function deleteServiceLevelObjective($name, array $optionalArgs = []) + public function updateServiceLevelObjective($serviceLevelObjective, array $optionalArgs = []) { - $request = new DeleteServiceLevelObjectiveRequest(); - $request->setName($name); + $request = new UpdateServiceLevelObjectiveRequest(); + $requestParamHeaders = []; + $request->setServiceLevelObjective($serviceLevelObjective); + $requestParamHeaders['service_level_objective.name'] = $serviceLevelObjective->getName(); + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'DeleteServiceLevelObjective', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('UpdateServiceLevelObjective', ServiceLevelObjective::class, $optionalArgs, $request)->wait(); } } diff --git a/Monitoring/src/V3/Gapic/UptimeCheckServiceGapicClient.php b/Monitoring/src/V3/Gapic/UptimeCheckServiceGapicClient.php index c9fb5a27ecd..02f2dacce18 100644 --- a/Monitoring/src/V3/Gapic/UptimeCheckServiceGapicClient.php +++ b/Monitoring/src/V3/Gapic/UptimeCheckServiceGapicClient.php @@ -17,9 +17,9 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/uptime_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/uptime_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3\Gapic; @@ -27,6 +27,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; + use Google\ApiCore\PathTemplate; use Google\ApiCore\RequestParamsHeaderDescriptor; use Google\ApiCore\RetrySettings; @@ -61,32 +62,18 @@ * ``` * $uptimeCheckServiceClient = new Google\Cloud\Monitoring\V3\UptimeCheckServiceClient(); * try { - * $formattedParent = $uptimeCheckServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $parent = 'parent'; + * $uptimeCheckConfig = new Google\Cloud\Monitoring\V3\UptimeCheckConfig(); + * $response = $uptimeCheckServiceClient->createUptimeCheckConfig($parent, $uptimeCheckConfig); * } finally { * $uptimeCheckServiceClient->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. + * 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. */ class UptimeCheckServiceGapicClient { @@ -119,43 +106,67 @@ class UptimeCheckServiceGapicClient 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/monitoring', 'https://www.googleapis.com/auth/monitoring.read', - 'https://www.googleapis.com/auth/monitoring.write', ]; - private static $projectNameTemplate; + + private static $folderUptimeCheckConfigNameTemplate; + + private static $organizationUptimeCheckConfigNameTemplate; + + private static $projectUptimeCheckConfigNameTemplate; + private static $uptimeCheckConfigNameTemplate; + private static $pathTemplateMap; private static function getClientDefaults() { return [ 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__.'/../resources/uptime_check_service_client_config.json', - 'descriptorsConfigPath' => __DIR__.'/../resources/uptime_check_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__.'/../resources/uptime_check_service_grpc_config.json', + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/uptime_check_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/uptime_check_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/uptime_check_service_grpc_config.json', 'credentialsConfig' => [ - 'scopes' => self::$serviceScopes, + 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__.'/../resources/uptime_check_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/uptime_check_service_rest_client_config.php', ], ], ]; } - private static function getProjectNameTemplate() + private static function getFolderUptimeCheckConfigNameTemplate() + { + if (self::$folderUptimeCheckConfigNameTemplate == null) { + self::$folderUptimeCheckConfigNameTemplate = new PathTemplate('folders/{folder}/uptimeCheckConfigs/{uptime_check_config}'); + } + + return self::$folderUptimeCheckConfigNameTemplate; + } + + private static function getOrganizationUptimeCheckConfigNameTemplate() + { + if (self::$organizationUptimeCheckConfigNameTemplate == null) { + self::$organizationUptimeCheckConfigNameTemplate = new PathTemplate('organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}'); + } + + return self::$organizationUptimeCheckConfigNameTemplate; + } + + private static function getProjectUptimeCheckConfigNameTemplate() { - if (null == self::$projectNameTemplate) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); + if (self::$projectUptimeCheckConfigNameTemplate == null) { + self::$projectUptimeCheckConfigNameTemplate = new PathTemplate('projects/{project}/uptimeCheckConfigs/{uptime_check_config}'); } - return self::$projectNameTemplate; + return self::$projectUptimeCheckConfigNameTemplate; } private static function getUptimeCheckConfigNameTemplate() { - if (null == self::$uptimeCheckConfigNameTemplate) { + if (self::$uptimeCheckConfigNameTemplate == null) { self::$uptimeCheckConfigNameTemplate = new PathTemplate('projects/{project}/uptimeCheckConfigs/{uptime_check_config}'); } @@ -164,9 +175,11 @@ private static function getUptimeCheckConfigNameTemplate() private static function getPathTemplateMap() { - if (null == self::$pathTemplateMap) { + if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ - 'project' => self::getProjectNameTemplate(), + 'folderUptimeCheckConfig' => self::getFolderUptimeCheckConfigNameTemplate(), + 'organizationUptimeCheckConfig' => self::getOrganizationUptimeCheckConfigNameTemplate(), + 'projectUptimeCheckConfig' => self::getProjectUptimeCheckConfigNameTemplate(), 'uptimeCheckConfig' => self::getUptimeCheckConfigNameTemplate(), ]; } @@ -175,23 +188,59 @@ private static function getPathTemplateMap() } /** - * Formats a string containing the fully-qualified path to represent - * a project resource. + * Formats a string containing the fully-qualified path to represent a + * folder_uptime_check_config resource. + * + * @param string $folder + * @param string $uptimeCheckConfig + * + * @return string The formatted folder_uptime_check_config resource. + */ + public static function folderUptimeCheckConfigName($folder, $uptimeCheckConfig) + { + return self::getFolderUptimeCheckConfigNameTemplate()->render([ + 'folder' => $folder, + 'uptime_check_config' => $uptimeCheckConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_uptime_check_config resource. + * + * @param string $organization + * @param string $uptimeCheckConfig + * + * @return string The formatted organization_uptime_check_config resource. + */ + public static function organizationUptimeCheckConfigName($organization, $uptimeCheckConfig) + { + return self::getOrganizationUptimeCheckConfigNameTemplate()->render([ + 'organization' => $organization, + 'uptime_check_config' => $uptimeCheckConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_uptime_check_config resource. * * @param string $project + * @param string $uptimeCheckConfig * - * @return string The formatted project resource. + * @return string The formatted project_uptime_check_config resource. */ - public static function projectName($project) + public static function projectUptimeCheckConfigName($project, $uptimeCheckConfig) { - return self::getProjectNameTemplate()->render([ + return self::getProjectUptimeCheckConfigNameTemplate()->render([ 'project' => $project, + 'uptime_check_config' => $uptimeCheckConfig, ]); } /** - * Formats a string containing the fully-qualified path to represent - * a uptime_check_config resource. + * Formats a string containing the fully-qualified path to represent a + * uptime_check_config resource. * * @param string $project * @param string $uptimeCheckConfig @@ -210,13 +259,16 @@ public static function uptimeCheckConfigName($project, $uptimeCheckConfig) * 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} - * - uptimeCheckConfig: projects/{project}/uptimeCheckConfigs/{uptime_check_config}. + * - folderUptimeCheckConfig: folders/{folder}/uptimeCheckConfigs/{uptime_check_config} + * - organizationUptimeCheckConfig: organizations/{organization}/uptimeCheckConfigs/{uptime_check_config} + * - projectUptimeCheckConfig: projects/{project}/uptimeCheckConfigs/{uptime_check_config} + * - uptimeCheckConfig: projects/{project}/uptimeCheckConfigs/{uptime_check_config} * - * 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. + * 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 @@ -228,7 +280,6 @@ public static function uptimeCheckConfigName($project, $uptimeCheckConfig) 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"); @@ -244,6 +295,7 @@ public static function parseName($formattedName, $template = null) // Swallow the exception to continue trying other path templates } } + throw new ValidationException("Input did not match any known format. Input: $formattedName"); } @@ -251,7 +303,7 @@ public static function parseName($formattedName, $template = null) * Constructor. * * @param array $options { - * Optional. Options for configuring the service API wrapper. + * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress * **Deprecated**. This option will be removed in a future major release. Please @@ -268,35 +320,38 @@ public static function parseName($formattedName, $template = null) * {@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()}. + * 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. + * 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. + * 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 + * $serviceAddress 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' => [...] + * '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 @@ -308,315 +363,210 @@ public function __construct(array $options = []) } /** - * Lists the existing valid Uptime check configurations for the project - * (leaving out any invalid configurations). + * Creates a new Uptime check configuration. * * Sample code: * ``` * $uptimeCheckServiceClient = new Google\Cloud\Monitoring\V3\UptimeCheckServiceClient(); * try { - * $formattedParent = $uptimeCheckServiceClient->projectName('[PROJECT]'); - * // Iterate over pages of elements - * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * - * - * // Alternatively: - * - * // Iterate through all elements - * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } + * $parent = 'parent'; + * $uptimeCheckConfig = new Google\Cloud\Monitoring\V3\UptimeCheckConfig(); + * $response = $uptimeCheckServiceClient->createUptimeCheckConfig($parent, $uptimeCheckConfig); * } finally { * $uptimeCheckServiceClient->close(); * } * ``` * - * @param string $parent Required. The project whose Uptime check configurations are listed. The format is: + * @param string $parent Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) in + * which to create the Uptime check. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER] + * @param UptimeCheckConfig $uptimeCheckConfig Required. The new Uptime check configuration. + * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\ApiCore\PagedListResponse + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig * * @throws ApiException if the remote call fails */ - public function listUptimeCheckConfigs($parent, array $optionalArgs = []) + public function createUptimeCheckConfig($parent, $uptimeCheckConfig, array $optionalArgs = []) { - $request = new ListUptimeCheckConfigsRequest(); + $request = new CreateUptimeCheckConfigRequest(); + $requestParamHeaders = []; $request->setParent($parent); - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->getPagedListResponse( - 'ListUptimeCheckConfigs', - $optionalArgs, - ListUptimeCheckConfigsResponse::class, - $request - ); + $request->setUptimeCheckConfig($uptimeCheckConfig); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('CreateUptimeCheckConfig', UptimeCheckConfig::class, $optionalArgs, $request)->wait(); } /** - * Gets a single Uptime check configuration. + * Deletes an Uptime check configuration. Note that this method will fail + * if the Uptime check configuration is referenced by an alert policy or + * other dependent configs that would be rendered invalid by the deletion. * * Sample code: * ``` * $uptimeCheckServiceClient = new Google\Cloud\Monitoring\V3\UptimeCheckServiceClient(); * try { * $formattedName = $uptimeCheckServiceClient->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); - * $response = $uptimeCheckServiceClient->getUptimeCheckConfig($formattedName); + * $uptimeCheckServiceClient->deleteUptimeCheckConfig($formattedName); * } finally { * $uptimeCheckServiceClient->close(); * } * ``` * - * @param string $name Required. The Uptime check configuration to retrieve. The format is: + * @param string $name Required. The Uptime check configuration to delete. The format is: * - * projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig - * * @throws ApiException if the remote call fails */ - public function getUptimeCheckConfig($name, array $optionalArgs = []) + public function deleteUptimeCheckConfig($name, array $optionalArgs = []) { - $request = new GetUptimeCheckConfigRequest(); + $request = new DeleteUptimeCheckConfigRequest(); + $requestParamHeaders = []; $request->setName($name); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'GetUptimeCheckConfig', - UptimeCheckConfig::class, - $optionalArgs, - $request - )->wait(); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('DeleteUptimeCheckConfig', GPBEmpty::class, $optionalArgs, $request)->wait(); } /** - * Creates a new Uptime check configuration. + * Gets a single Uptime check configuration. * * Sample code: * ``` * $uptimeCheckServiceClient = new Google\Cloud\Monitoring\V3\UptimeCheckServiceClient(); * try { - * $formattedParent = $uptimeCheckServiceClient->projectName('[PROJECT]'); - * $uptimeCheckConfig = new Google\Cloud\Monitoring\V3\UptimeCheckConfig(); - * $response = $uptimeCheckServiceClient->createUptimeCheckConfig($formattedParent, $uptimeCheckConfig); + * $formattedName = $uptimeCheckServiceClient->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); + * $response = $uptimeCheckServiceClient->getUptimeCheckConfig($formattedName); * } finally { * $uptimeCheckServiceClient->close(); * } * ``` * - * @param string $parent Required. The project in which to create the Uptime check. The format is: + * @param string $name Required. The Uptime check configuration to retrieve. The format is: * - * projects/[PROJECT_ID_OR_NUMBER] - * @param UptimeCheckConfig $uptimeCheckConfig Required. The new Uptime check configuration. - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] + * @param array $optionalArgs { + * Optional. * * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig * * @throws ApiException if the remote call fails */ - public function createUptimeCheckConfig($parent, $uptimeCheckConfig, array $optionalArgs = []) + public function getUptimeCheckConfig($name, array $optionalArgs = []) { - $request = new CreateUptimeCheckConfigRequest(); - $request->setParent($parent); - $request->setUptimeCheckConfig($uptimeCheckConfig); - - $requestParams = new RequestParamsHeaderDescriptor([ - 'parent' => $request->getParent(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'CreateUptimeCheckConfig', - UptimeCheckConfig::class, - $optionalArgs, - $request - )->wait(); + $request = new GetUptimeCheckConfigRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetUptimeCheckConfig', UptimeCheckConfig::class, $optionalArgs, $request)->wait(); } /** - * Updates an Uptime check configuration. You can either replace the entire - * configuration with a new one or replace only certain fields in the current - * configuration by specifying the fields to be updated via `updateMask`. - * Returns the updated configuration. + * Lists the existing valid Uptime check configurations for the project + * (leaving out any invalid configurations). * * Sample code: * ``` * $uptimeCheckServiceClient = new Google\Cloud\Monitoring\V3\UptimeCheckServiceClient(); * try { - * $uptimeCheckConfig = new Google\Cloud\Monitoring\V3\UptimeCheckConfig(); - * $response = $uptimeCheckServiceClient->updateUptimeCheckConfig($uptimeCheckConfig); + * $parent = 'parent'; + * // Iterate over pages of elements + * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($parent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckConfigs($parent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } * } finally { * $uptimeCheckServiceClient->close(); * } * ``` * - * @param UptimeCheckConfig $uptimeCheckConfig Required. If an `updateMask` has been specified, this field gives - * the values for the set of fields mentioned in the `updateMask`. If an - * `updateMask` has not been given, this Uptime check configuration replaces - * the current configuration. If a field is mentioned in `updateMask` but - * the corresonding field is omitted in this partial Uptime check - * configuration, it has the effect of deleting/clearing the field from the - * configuration on the server. + * @param string $parent Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose Uptime check configurations are listed. The format is: * - * The following fields can be updated: `display_name`, - * `http_check`, `tcp_check`, `timeout`, `content_matchers`, and - * `selected_regions`. - * @param array $optionalArgs { - * Optional. + * projects/[PROJECT_ID_OR_NUMBER] + * @param array $optionalArgs { + * Optional. * - * @type FieldMask $updateMask - * Optional. If present, only the listed fields in the current Uptime check - * configuration are updated with values from the new configuration. If this - * field is empty, then the current configuration is completely replaced with - * the new configuration. + * @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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * - * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig + * @return \Google\ApiCore\PagedListResponse * * @throws ApiException if the remote call fails */ - public function updateUptimeCheckConfig($uptimeCheckConfig, array $optionalArgs = []) + public function listUptimeCheckConfigs($parent, array $optionalArgs = []) { - $request = new UpdateUptimeCheckConfigRequest(); - $request->setUptimeCheckConfig($uptimeCheckConfig); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); + $request = new ListUptimeCheckConfigsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); } - $requestParams = new RequestParamsHeaderDescriptor([ - 'uptime_check_config.name' => $request->getUptimeCheckConfig()->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'UpdateUptimeCheckConfig', - UptimeCheckConfig::class, - $optionalArgs, - $request - )->wait(); - } - - /** - * Deletes an Uptime check configuration. Note that this method will fail - * if the Uptime check configuration is referenced by an alert policy or - * other dependent configs that would be rendered invalid by the deletion. - * - * Sample code: - * ``` - * $uptimeCheckServiceClient = new Google\Cloud\Monitoring\V3\UptimeCheckServiceClient(); - * try { - * $formattedName = $uptimeCheckServiceClient->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); - * $uptimeCheckServiceClient->deleteUptimeCheckConfig($formattedName); - * } finally { - * $uptimeCheckServiceClient->close(); - * } - * ``` - * - * @param string $name Required. The Uptime check configuration to delete. The format is: - * - * projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] - * @param array $optionalArgs { - * Optional. - * - * @type RetrySettings|array $retrySettings - * Retry settings to use for this call. Can be a - * {@see Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. - * } - * - * @throws ApiException if the remote call fails - */ - public function deleteUptimeCheckConfig($name, array $optionalArgs = []) - { - $request = new DeleteUptimeCheckConfigRequest(); - $request->setName($name); + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } - $requestParams = new RequestParamsHeaderDescriptor([ - 'name' => $request->getName(), - ]); - $optionalArgs['headers'] = isset($optionalArgs['headers']) - ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) - : $requestParams->getHeader(); - - return $this->startCall( - 'DeleteUptimeCheckConfig', - GPBEmpty::class, - $optionalArgs, - $request - )->wait(); + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListUptimeCheckConfigs', $optionalArgs, ListUptimeCheckConfigsResponse::class, $request); } /** - * Returns the list of IP addresses that checkers run from. + * Returns the list of IP addresses that checkers run from * * Sample code: * ``` @@ -629,10 +579,7 @@ public function deleteUptimeCheckConfig($name, array $optionalArgs = []) * // doSomethingWith($element); * } * } - * - * * // Alternatively: - * * // Iterate through all elements * $pagedResponse = $uptimeCheckServiceClient->listUptimeCheckIps(); * foreach ($pagedResponse->iterateAllElements() as $element) { @@ -644,22 +591,22 @@ public function deleteUptimeCheckConfig($name, array $optionalArgs = []) * ``` * * @param array $optionalArgs { - * Optional. + * 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. + * 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. + * 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 Google\ApiCore\RetrySettings} object, or an associative array - * of retry settings parameters. See the documentation on - * {@see Google\ApiCore\RetrySettings} for example usage. + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. * } * * @return \Google\ApiCore\PagedListResponse @@ -672,15 +619,73 @@ public function listUptimeCheckIps(array $optionalArgs = []) if (isset($optionalArgs['pageSize'])) { $request->setPageSize($optionalArgs['pageSize']); } + if (isset($optionalArgs['pageToken'])) { $request->setPageToken($optionalArgs['pageToken']); } - return $this->getPagedListResponse( - 'ListUptimeCheckIps', - $optionalArgs, - ListUptimeCheckIpsResponse::class, - $request - ); + return $this->getPagedListResponse('ListUptimeCheckIps', $optionalArgs, ListUptimeCheckIpsResponse::class, $request); + } + + /** + * Updates an Uptime check configuration. You can either replace the entire + * configuration with a new one or replace only certain fields in the current + * configuration by specifying the fields to be updated via `updateMask`. + * Returns the updated configuration. + * + * Sample code: + * ``` + * $uptimeCheckServiceClient = new Google\Cloud\Monitoring\V3\UptimeCheckServiceClient(); + * try { + * $uptimeCheckConfig = new Google\Cloud\Monitoring\V3\UptimeCheckConfig(); + * $response = $uptimeCheckServiceClient->updateUptimeCheckConfig($uptimeCheckConfig); + * } finally { + * $uptimeCheckServiceClient->close(); + * } + * ``` + * + * @param UptimeCheckConfig $uptimeCheckConfig Required. If an `updateMask` has been specified, this field gives + * the values for the set of fields mentioned in the `updateMask`. If an + * `updateMask` has not been given, this Uptime check configuration replaces + * the current configuration. If a field is mentioned in `updateMask` but + * the corresonding field is omitted in this partial Uptime check + * configuration, it has the effect of deleting/clearing the field from the + * configuration on the server. + * + * The following fields can be updated: `display_name`, + * `http_check`, `tcp_check`, `timeout`, `content_matchers`, and + * `selected_regions`. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * Optional. If present, only the listed fields in the current Uptime check + * configuration are updated with values from the new configuration. If this + * field is empty, then the current configuration is completely replaced with + * the new configuration. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array of retry + * settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig + * + * @throws ApiException if the remote call fails + */ + public function updateUptimeCheckConfig($uptimeCheckConfig, array $optionalArgs = []) + { + $request = new UpdateUptimeCheckConfigRequest(); + $requestParamHeaders = []; + $request->setUptimeCheckConfig($uptimeCheckConfig); + $requestParamHeaders['uptime_check_config.name'] = $uptimeCheckConfig->getName(); + 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('UpdateUptimeCheckConfig', UptimeCheckConfig::class, $optionalArgs, $request)->wait(); } } diff --git a/Monitoring/src/V3/GetNotificationChannelVerificationCodeRequest.php b/Monitoring/src/V3/GetNotificationChannelVerificationCodeRequest.php index 884284ce3cb..ad026e8f59e 100644 --- a/Monitoring/src/V3/GetNotificationChannelVerificationCodeRequest.php +++ b/Monitoring/src/V3/GetNotificationChannelVerificationCodeRequest.php @@ -107,13 +107,23 @@ public function setName($var) * impose an upper limit on the maximum expiration that is permitted). * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 2; - * @return \Google\Protobuf\Timestamp + * @return \Google\Protobuf\Timestamp|null */ public function getExpireTime() { return $this->expire_time; } + public function hasExpireTime() + { + return isset($this->expire_time); + } + + public function clearExpireTime() + { + unset($this->expire_time); + } + /** * The desired expiration time. If specified, the API will guarantee that * the returned code will not be valid after the specified timestamp; diff --git a/Monitoring/src/V3/GetNotificationChannelVerificationCodeResponse.php b/Monitoring/src/V3/GetNotificationChannelVerificationCodeResponse.php index f0423fa931e..43e578d3a49 100644 --- a/Monitoring/src/V3/GetNotificationChannelVerificationCodeResponse.php +++ b/Monitoring/src/V3/GetNotificationChannelVerificationCodeResponse.php @@ -93,13 +93,23 @@ public function setCode($var) * requested expiration in the request and the max permitted expiration. * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 2; - * @return \Google\Protobuf\Timestamp + * @return \Google\Protobuf\Timestamp|null */ public function getExpireTime() { return $this->expire_time; } + public function hasExpireTime() + { + return isset($this->expire_time); + } + + public function clearExpireTime() + { + unset($this->expire_time); + } + /** * The expiration time associated with the code that was returned. If * an expiration was provided in the request, this is the minimum of the diff --git a/Monitoring/src/V3/GetServiceLevelObjectiveRequest.php b/Monitoring/src/V3/GetServiceLevelObjectiveRequest.php index 99979530d87..09c873393d2 100644 --- a/Monitoring/src/V3/GetServiceLevelObjectiveRequest.php +++ b/Monitoring/src/V3/GetServiceLevelObjectiveRequest.php @@ -107,7 +107,7 @@ public function getView() */ public function setView($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\ServiceLevelObjective_View::class); + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\ServiceLevelObjective\View::class); $this->view = $var; return $this; diff --git a/Monitoring/src/V3/GroupServiceClient.php b/Monitoring/src/V3/GroupServiceClient.php index ba0a7943649..0c5c992a404 100644 --- a/Monitoring/src/V3/GroupServiceClient.php +++ b/Monitoring/src/V3/GroupServiceClient.php @@ -17,20 +17,18 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/group_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/group_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3; use Google\Cloud\Monitoring\V3\Gapic\GroupServiceGapicClient; -/** - * {@inheritdoc} - */ +/** {@inheritdoc} */ class GroupServiceClient extends GroupServiceGapicClient { - // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see GroupServiceGapicClient} class. + // This class is intentionally empty, and is intended to hold manual additions to + // the generated {@see GroupServiceGapicClient} class. } diff --git a/Monitoring/src/V3/GroupServiceGrpcClient.php b/Monitoring/src/V3/GroupServiceGrpcClient.php index 771b5426292..f1971d59247 100644 --- a/Monitoring/src/V3/GroupServiceGrpcClient.php +++ b/Monitoring/src/V3/GroupServiceGrpcClient.php @@ -48,6 +48,7 @@ public function __construct($hostname, $opts, $channel = null) { * @param \Google\Cloud\Monitoring\V3\ListGroupsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListGroups(\Google\Cloud\Monitoring\V3\ListGroupsRequest $argument, $metadata = [], $options = []) { @@ -62,6 +63,7 @@ public function ListGroups(\Google\Cloud\Monitoring\V3\ListGroupsRequest $argume * @param \Google\Cloud\Monitoring\V3\GetGroupRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetGroup(\Google\Cloud\Monitoring\V3\GetGroupRequest $argument, $metadata = [], $options = []) { @@ -76,6 +78,7 @@ public function GetGroup(\Google\Cloud\Monitoring\V3\GetGroupRequest $argument, * @param \Google\Cloud\Monitoring\V3\CreateGroupRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateGroup(\Google\Cloud\Monitoring\V3\CreateGroupRequest $argument, $metadata = [], $options = []) { @@ -91,6 +94,7 @@ public function CreateGroup(\Google\Cloud\Monitoring\V3\CreateGroupRequest $argu * @param \Google\Cloud\Monitoring\V3\UpdateGroupRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function UpdateGroup(\Google\Cloud\Monitoring\V3\UpdateGroupRequest $argument, $metadata = [], $options = []) { @@ -105,6 +109,7 @@ public function UpdateGroup(\Google\Cloud\Monitoring\V3\UpdateGroupRequest $argu * @param \Google\Cloud\Monitoring\V3\DeleteGroupRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteGroup(\Google\Cloud\Monitoring\V3\DeleteGroupRequest $argument, $metadata = [], $options = []) { @@ -119,6 +124,7 @@ public function DeleteGroup(\Google\Cloud\Monitoring\V3\DeleteGroupRequest $argu * @param \Google\Cloud\Monitoring\V3\ListGroupMembersRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListGroupMembers(\Google\Cloud\Monitoring\V3\ListGroupMembersRequest $argument, $metadata = [], $options = []) { diff --git a/Monitoring/src/V3/InternalChecker.php b/Monitoring/src/V3/InternalChecker.php index 9db617dd42c..99552b07193 100644 --- a/Monitoring/src/V3/InternalChecker.php +++ b/Monitoring/src/V3/InternalChecker.php @@ -260,7 +260,7 @@ public function getState() */ public function setState($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\InternalChecker_State::class); + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\InternalChecker\State::class); $this->state = $var; return $this; diff --git a/Monitoring/src/V3/LabelValue.php b/Monitoring/src/V3/LabelValue.php index ee2f5ab9cc6..3a66a26a435 100644 --- a/Monitoring/src/V3/LabelValue.php +++ b/Monitoring/src/V3/LabelValue.php @@ -47,6 +47,11 @@ public function getBoolValue() return $this->readOneof(1); } + public function hasBoolValue() + { + return $this->hasOneof(1); + } + /** * A bool label value. * @@ -73,6 +78,11 @@ public function getInt64Value() return $this->readOneof(2); } + public function hasInt64Value() + { + return $this->hasOneof(2); + } + /** * An int64 label value. * @@ -99,6 +109,11 @@ public function getStringValue() return $this->readOneof(3); } + public function hasStringValue() + { + return $this->hasOneof(3); + } + /** * A string label value. * diff --git a/Monitoring/src/V3/ListAlertPoliciesRequest.php b/Monitoring/src/V3/ListAlertPoliciesRequest.php index 95a9d61df70..6e81de4f6a4 100644 --- a/Monitoring/src/V3/ListAlertPoliciesRequest.php +++ b/Monitoring/src/V3/ListAlertPoliciesRequest.php @@ -16,7 +16,8 @@ class ListAlertPoliciesRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project whose alert policies are to be listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose alert policies are to be listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * Note that this field names the parent container in which the alerting * policies to be listed are stored. To retrieve a single alerting policy @@ -68,7 +69,8 @@ class ListAlertPoliciesRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project whose alert policies are to be listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose alert policies are to be listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * Note that this field names the parent container in which the alerting * policies to be listed are stored. To retrieve a single alerting policy @@ -100,7 +102,8 @@ public function __construct($data = NULL) { } /** - * Required. The project whose alert policies are to be listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose alert policies are to be listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * Note that this field names the parent container in which the alerting * policies to be listed are stored. To retrieve a single alerting policy @@ -117,7 +120,8 @@ public function getName() } /** - * Required. The project whose alert policies are to be listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose alert policies are to be listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * Note that this field names the parent container in which the alerting * policies to be listed are stored. To retrieve a single alerting policy diff --git a/Monitoring/src/V3/ListAlertPoliciesResponse.php b/Monitoring/src/V3/ListAlertPoliciesResponse.php index 7c584632603..770d6f79a9d 100644 --- a/Monitoring/src/V3/ListAlertPoliciesResponse.php +++ b/Monitoring/src/V3/ListAlertPoliciesResponse.php @@ -29,6 +29,13 @@ class ListAlertPoliciesResponse extends \Google\Protobuf\Internal\Message * Generated from protobuf field string next_page_token = 2; */ private $next_page_token = ''; + /** + * The total number of alert policies in all pages. This number is only an + * estimate, and may change in subsequent pages. https://aip.dev/158 + * + * Generated from protobuf field int32 total_size = 4; + */ + private $total_size = 0; /** * Constructor. @@ -42,6 +49,9 @@ class ListAlertPoliciesResponse extends \Google\Protobuf\Internal\Message * If there might be more results than were returned, then this field is set * to a non-empty value. To see the additional results, * use that value as `page_token` in the next call to this method. + * @type int $total_size + * The total number of alert policies in all pages. This number is only an + * estimate, and may change in subsequent pages. https://aip.dev/158 * } */ public function __construct($data = NULL) { @@ -105,5 +115,33 @@ public function setNextPageToken($var) return $this; } + /** + * The total number of alert policies in all pages. This number is only an + * estimate, and may change in subsequent pages. https://aip.dev/158 + * + * Generated from protobuf field int32 total_size = 4; + * @return int + */ + public function getTotalSize() + { + return $this->total_size; + } + + /** + * The total number of alert policies in all pages. This number is only an + * estimate, and may change in subsequent pages. https://aip.dev/158 + * + * Generated from protobuf field int32 total_size = 4; + * @param int $var + * @return $this + */ + public function setTotalSize($var) + { + GPBUtil::checkInt32($var); + $this->total_size = $var; + + return $this; + } + } diff --git a/Monitoring/src/V3/ListGroupMembersRequest.php b/Monitoring/src/V3/ListGroupMembersRequest.php index 5b225944bd3..313adf431dd 100644 --- a/Monitoring/src/V3/ListGroupMembersRequest.php +++ b/Monitoring/src/V3/ListGroupMembersRequest.php @@ -222,13 +222,23 @@ public function setFilter($var) * membership over the last minute is returned. * * Generated from protobuf field .google.monitoring.v3.TimeInterval interval = 6; - * @return \Google\Cloud\Monitoring\V3\TimeInterval + * @return \Google\Cloud\Monitoring\V3\TimeInterval|null */ public function getInterval() { return $this->interval; } + public function hasInterval() + { + return isset($this->interval); + } + + public function clearInterval() + { + unset($this->interval); + } + /** * An optional time interval for which results should be returned. Only * members that were part of the group during the specified interval are diff --git a/Monitoring/src/V3/ListGroupsRequest.php b/Monitoring/src/V3/ListGroupsRequest.php index 2ac88671993..d9203b457d0 100644 --- a/Monitoring/src/V3/ListGroupsRequest.php +++ b/Monitoring/src/V3/ListGroupsRequest.php @@ -16,7 +16,8 @@ class ListGroupsRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project whose groups are to be listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose groups are to be listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 7 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -45,7 +46,8 @@ class ListGroupsRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project whose groups are to be listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose groups are to be listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * @type string $children_of_group * A group name. The format is: @@ -79,7 +81,8 @@ public function __construct($data = NULL) { } /** - * Required. The project whose groups are to be listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose groups are to be listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 7 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -91,7 +94,8 @@ public function getName() } /** - * Required. The project whose groups are to be listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose groups are to be listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 7 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -120,6 +124,11 @@ public function getChildrenOfGroup() return $this->readOneof(2); } + public function hasChildrenOfGroup() + { + return $this->hasOneof(2); + } + /** * A group name. The format is: * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] @@ -154,6 +163,11 @@ public function getAncestorsOfGroup() return $this->readOneof(3); } + public function hasAncestorsOfGroup() + { + return $this->hasOneof(3); + } + /** * A group name. The format is: * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] @@ -189,6 +203,11 @@ public function getDescendantsOfGroup() return $this->readOneof(4); } + public function hasDescendantsOfGroup() + { + return $this->hasOneof(4); + } + /** * A group name. The format is: * projects/[PROJECT_ID_OR_NUMBER]/groups/[GROUP_ID] diff --git a/Monitoring/src/V3/ListMetricDescriptorsRequest.php b/Monitoring/src/V3/ListMetricDescriptorsRequest.php index ca6efe01c32..179cfa52241 100644 --- a/Monitoring/src/V3/ListMetricDescriptorsRequest.php +++ b/Monitoring/src/V3/ListMetricDescriptorsRequest.php @@ -16,7 +16,8 @@ class ListMetricDescriptorsRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -56,7 +57,8 @@ class ListMetricDescriptorsRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * @type string $filter * If this field is empty, all custom and @@ -80,7 +82,8 @@ public function __construct($data = NULL) { } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -92,7 +95,8 @@ public function getName() } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { diff --git a/Monitoring/src/V3/ListMonitoredResourceDescriptorsRequest.php b/Monitoring/src/V3/ListMonitoredResourceDescriptorsRequest.php index ea60efbc500..8cf91b962f0 100644 --- a/Monitoring/src/V3/ListMonitoredResourceDescriptorsRequest.php +++ b/Monitoring/src/V3/ListMonitoredResourceDescriptorsRequest.php @@ -16,7 +16,8 @@ class ListMonitoredResourceDescriptorsRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -54,7 +55,8 @@ class ListMonitoredResourceDescriptorsRequest extends \Google\Protobuf\Internal\ * Optional. Data for populating the Message object. * * @type string $name - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * @type string $filter * An optional [filter](https://cloud.google.com/monitoring/api/v3/filters) @@ -76,7 +78,8 @@ public function __construct($data = NULL) { } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -88,7 +91,8 @@ public function getName() } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string name = 5 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { diff --git a/Monitoring/src/V3/ListNotificationChannelDescriptorsRequest.php b/Monitoring/src/V3/ListNotificationChannelDescriptorsRequest.php index f21fdfcadf1..3174f310040 100644 --- a/Monitoring/src/V3/ListNotificationChannelDescriptorsRequest.php +++ b/Monitoring/src/V3/ListNotificationChannelDescriptorsRequest.php @@ -19,8 +19,10 @@ class ListNotificationChannelDescriptorsRequest extends \Google\Protobuf\Interna * Required. The REST resource name of the parent from which to retrieve * the notification channel descriptors. The expected syntax is: * projects/[PROJECT_ID_OR_NUMBER] - * Note that this names the parent container in which to look for the - * descriptors; to retrieve a single descriptor by name, use the + * Note that this + * [names](https://cloud.google.com/monitoring/api/v3#project_name) the parent + * container in which to look for the descriptors; to retrieve a single + * descriptor by name, use the * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] * operation, instead. * @@ -54,8 +56,10 @@ class ListNotificationChannelDescriptorsRequest extends \Google\Protobuf\Interna * Required. The REST resource name of the parent from which to retrieve * the notification channel descriptors. The expected syntax is: * projects/[PROJECT_ID_OR_NUMBER] - * Note that this names the parent container in which to look for the - * descriptors; to retrieve a single descriptor by name, use the + * Note that this + * [names](https://cloud.google.com/monitoring/api/v3#project_name) the parent + * container in which to look for the descriptors; to retrieve a single + * descriptor by name, use the * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] * operation, instead. * @type int $page_size @@ -77,8 +81,10 @@ public function __construct($data = NULL) { * Required. The REST resource name of the parent from which to retrieve * the notification channel descriptors. The expected syntax is: * projects/[PROJECT_ID_OR_NUMBER] - * Note that this names the parent container in which to look for the - * descriptors; to retrieve a single descriptor by name, use the + * Note that this + * [names](https://cloud.google.com/monitoring/api/v3#project_name) the parent + * container in which to look for the descriptors; to retrieve a single + * descriptor by name, use the * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] * operation, instead. * @@ -94,8 +100,10 @@ public function getName() * Required. The REST resource name of the parent from which to retrieve * the notification channel descriptors. The expected syntax is: * projects/[PROJECT_ID_OR_NUMBER] - * Note that this names the parent container in which to look for the - * descriptors; to retrieve a single descriptor by name, use the + * Note that this + * [names](https://cloud.google.com/monitoring/api/v3#project_name) the parent + * container in which to look for the descriptors; to retrieve a single + * descriptor by name, use the * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] * operation, instead. * diff --git a/Monitoring/src/V3/ListNotificationChannelsRequest.php b/Monitoring/src/V3/ListNotificationChannelsRequest.php index f93e2f029db..61de5cfa15f 100644 --- a/Monitoring/src/V3/ListNotificationChannelsRequest.php +++ b/Monitoring/src/V3/ListNotificationChannelsRequest.php @@ -16,7 +16,8 @@ class ListNotificationChannelsRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * This names the container * in which to look for the notification channels; it does not name a @@ -71,7 +72,8 @@ class ListNotificationChannelsRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * This names the container * in which to look for the notification channels; it does not name a @@ -106,7 +108,8 @@ public function __construct($data = NULL) { } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * This names the container * in which to look for the notification channels; it does not name a @@ -124,7 +127,8 @@ public function getName() } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * This names the container * in which to look for the notification channels; it does not name a diff --git a/Monitoring/src/V3/ListNotificationChannelsResponse.php b/Monitoring/src/V3/ListNotificationChannelsResponse.php index 551a50c0a31..07dbfe06731 100644 --- a/Monitoring/src/V3/ListNotificationChannelsResponse.php +++ b/Monitoring/src/V3/ListNotificationChannelsResponse.php @@ -30,6 +30,13 @@ class ListNotificationChannelsResponse extends \Google\Protobuf\Internal\Message * Generated from protobuf field string next_page_token = 2; */ private $next_page_token = ''; + /** + * The total number of notification channels in all pages. This number is only + * an estimate, and may change in subsequent pages. https://aip.dev/158 + * + * Generated from protobuf field int32 total_size = 4; + */ + private $total_size = 0; /** * Constructor. @@ -44,6 +51,9 @@ class ListNotificationChannelsResponse extends \Google\Protobuf\Internal\Message * the request. Use the value in the `page_token` field in a * subsequent request to fetch the next set of results. If empty, * all results have been returned. + * @type int $total_size + * The total number of notification channels in all pages. This number is only + * an estimate, and may change in subsequent pages. https://aip.dev/158 * } */ public function __construct($data = NULL) { @@ -109,5 +119,33 @@ public function setNextPageToken($var) return $this; } + /** + * The total number of notification channels in all pages. This number is only + * an estimate, and may change in subsequent pages. https://aip.dev/158 + * + * Generated from protobuf field int32 total_size = 4; + * @return int + */ + public function getTotalSize() + { + return $this->total_size; + } + + /** + * The total number of notification channels in all pages. This number is only + * an estimate, and may change in subsequent pages. https://aip.dev/158 + * + * Generated from protobuf field int32 total_size = 4; + * @param int $var + * @return $this + */ + public function setTotalSize($var) + { + GPBUtil::checkInt32($var); + $this->total_size = $var; + + return $this; + } + } diff --git a/Monitoring/src/V3/ListServiceLevelObjectivesRequest.php b/Monitoring/src/V3/ListServiceLevelObjectivesRequest.php index 6ed5e630c25..ea32fd24384 100644 --- a/Monitoring/src/V3/ListServiceLevelObjectivesRequest.php +++ b/Monitoring/src/V3/ListServiceLevelObjectivesRequest.php @@ -229,7 +229,7 @@ public function getView() */ public function setView($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\ServiceLevelObjective_View::class); + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\ServiceLevelObjective\View::class); $this->view = $var; return $this; diff --git a/Monitoring/src/V3/ListServicesRequest.php b/Monitoring/src/V3/ListServicesRequest.php index 05fb79a3d16..9689cd9be0d 100644 --- a/Monitoring/src/V3/ListServicesRequest.php +++ b/Monitoring/src/V3/ListServicesRequest.php @@ -17,7 +17,8 @@ class ListServicesRequest extends \Google\Protobuf\Internal\Message { /** * Required. Resource name of the parent containing the listed services, either a - * project or a Monitoring Workspace. The formats are: + * [project](https://cloud.google.com/monitoring/api/v3#project_name) or a + * Monitoring Workspace. The formats are: * projects/[PROJECT_ID_OR_NUMBER] * workspaces/[HOST_PROJECT_ID_OR_NUMBER] * @@ -29,15 +30,19 @@ class ListServicesRequest extends \Google\Protobuf\Internal\Message * supports the following fields: * - `identifier_case` * - `app_engine.module_id` - * - `cloud_endpoints.service` - * - `cluster_istio.location` - * - `cluster_istio.cluster_name` - * - `cluster_istio.service_namespace` - * - `cluster_istio.service_name` + * - `cloud_endpoints.service` (reserved for future use) + * - `mesh_istio.mesh_uid` + * - `mesh_istio.service_namespace` + * - `mesh_istio.service_name` + * - `cluster_istio.location` (deprecated) + * - `cluster_istio.cluster_name` (deprecated) + * - `cluster_istio.service_namespace` (deprecated) + * - `cluster_istio.service_name` (deprecated) * `identifier_case` refers to which option in the identifier oneof is * populated. For example, the filter `identifier_case = "CUSTOM"` would match * all services with a value for the `custom` field. Valid options are - * "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO". + * "CUSTOM", "APP_ENGINE", "MESH_ISTIO", plus "CLUSTER_ISTIO" (deprecated) + * and "CLOUD_ENDPOINTS" (reserved for future use). * * Generated from protobuf field string filter = 2; */ @@ -66,7 +71,8 @@ class ListServicesRequest extends \Google\Protobuf\Internal\Message * * @type string $parent * Required. Resource name of the parent containing the listed services, either a - * project or a Monitoring Workspace. The formats are: + * [project](https://cloud.google.com/monitoring/api/v3#project_name) or a + * Monitoring Workspace. The formats are: * projects/[PROJECT_ID_OR_NUMBER] * workspaces/[HOST_PROJECT_ID_OR_NUMBER] * @type string $filter @@ -74,15 +80,19 @@ class ListServicesRequest extends \Google\Protobuf\Internal\Message * supports the following fields: * - `identifier_case` * - `app_engine.module_id` - * - `cloud_endpoints.service` - * - `cluster_istio.location` - * - `cluster_istio.cluster_name` - * - `cluster_istio.service_namespace` - * - `cluster_istio.service_name` + * - `cloud_endpoints.service` (reserved for future use) + * - `mesh_istio.mesh_uid` + * - `mesh_istio.service_namespace` + * - `mesh_istio.service_name` + * - `cluster_istio.location` (deprecated) + * - `cluster_istio.cluster_name` (deprecated) + * - `cluster_istio.service_namespace` (deprecated) + * - `cluster_istio.service_name` (deprecated) * `identifier_case` refers to which option in the identifier oneof is * populated. For example, the filter `identifier_case = "CUSTOM"` would match * all services with a value for the `custom` field. Valid options are - * "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO". + * "CUSTOM", "APP_ENGINE", "MESH_ISTIO", plus "CLUSTER_ISTIO" (deprecated) + * and "CLOUD_ENDPOINTS" (reserved for future use). * @type int $page_size * A non-negative number that is the maximum number of results to return. * When 0, use default page size. @@ -99,7 +109,8 @@ public function __construct($data = NULL) { /** * Required. Resource name of the parent containing the listed services, either a - * project or a Monitoring Workspace. The formats are: + * [project](https://cloud.google.com/monitoring/api/v3#project_name) or a + * Monitoring Workspace. The formats are: * projects/[PROJECT_ID_OR_NUMBER] * workspaces/[HOST_PROJECT_ID_OR_NUMBER] * @@ -113,7 +124,8 @@ public function getParent() /** * Required. Resource name of the parent containing the listed services, either a - * project or a Monitoring Workspace. The formats are: + * [project](https://cloud.google.com/monitoring/api/v3#project_name) or a + * Monitoring Workspace. The formats are: * projects/[PROJECT_ID_OR_NUMBER] * workspaces/[HOST_PROJECT_ID_OR_NUMBER] * @@ -134,15 +146,19 @@ public function setParent($var) * supports the following fields: * - `identifier_case` * - `app_engine.module_id` - * - `cloud_endpoints.service` - * - `cluster_istio.location` - * - `cluster_istio.cluster_name` - * - `cluster_istio.service_namespace` - * - `cluster_istio.service_name` + * - `cloud_endpoints.service` (reserved for future use) + * - `mesh_istio.mesh_uid` + * - `mesh_istio.service_namespace` + * - `mesh_istio.service_name` + * - `cluster_istio.location` (deprecated) + * - `cluster_istio.cluster_name` (deprecated) + * - `cluster_istio.service_namespace` (deprecated) + * - `cluster_istio.service_name` (deprecated) * `identifier_case` refers to which option in the identifier oneof is * populated. For example, the filter `identifier_case = "CUSTOM"` would match * all services with a value for the `custom` field. Valid options are - * "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO". + * "CUSTOM", "APP_ENGINE", "MESH_ISTIO", plus "CLUSTER_ISTIO" (deprecated) + * and "CLOUD_ENDPOINTS" (reserved for future use). * * Generated from protobuf field string filter = 2; * @return string @@ -157,15 +173,19 @@ public function getFilter() * supports the following fields: * - `identifier_case` * - `app_engine.module_id` - * - `cloud_endpoints.service` - * - `cluster_istio.location` - * - `cluster_istio.cluster_name` - * - `cluster_istio.service_namespace` - * - `cluster_istio.service_name` + * - `cloud_endpoints.service` (reserved for future use) + * - `mesh_istio.mesh_uid` + * - `mesh_istio.service_namespace` + * - `mesh_istio.service_name` + * - `cluster_istio.location` (deprecated) + * - `cluster_istio.cluster_name` (deprecated) + * - `cluster_istio.service_namespace` (deprecated) + * - `cluster_istio.service_name` (deprecated) * `identifier_case` refers to which option in the identifier oneof is * populated. For example, the filter `identifier_case = "CUSTOM"` would match * all services with a value for the `custom` field. Valid options are - * "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO". + * "CUSTOM", "APP_ENGINE", "MESH_ISTIO", plus "CLUSTER_ISTIO" (deprecated) + * and "CLOUD_ENDPOINTS" (reserved for future use). * * Generated from protobuf field string filter = 2; * @param string $var diff --git a/Monitoring/src/V3/ListTimeSeriesRequest.php b/Monitoring/src/V3/ListTimeSeriesRequest.php index 91ee0744df0..2ccbd8dfb64 100644 --- a/Monitoring/src/V3/ListTimeSeriesRequest.php +++ b/Monitoring/src/V3/ListTimeSeriesRequest.php @@ -16,8 +16,11 @@ class ListTimeSeriesRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name), + * organization or folder on which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] + * organizations/[ORGANIZATION_ID] + * folders/[FOLDER_ID] * * Generated from protobuf field string name = 10 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -50,6 +53,13 @@ class ListTimeSeriesRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.monitoring.v3.Aggregation aggregation = 5; */ private $aggregation = null; + /** + * Apply a second aggregation after `aggregation` is applied. May only be + * specified if `aggregation` is specified. + * + * Generated from protobuf field .google.monitoring.v3.Aggregation secondary_aggregation = 11; + */ + private $secondary_aggregation = null; /** * Unsupported: must be left blank. The points in each time series are * currently returned in reverse time order (most recent to oldest). @@ -89,8 +99,11 @@ class ListTimeSeriesRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name), + * organization or folder on which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] + * organizations/[ORGANIZATION_ID] + * folders/[FOLDER_ID] * @type string $filter * Required. A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) * that specifies which time series should be returned. The filter must @@ -107,6 +120,9 @@ class ListTimeSeriesRequest extends \Google\Protobuf\Internal\Message * well as how to combine the retrieved time series across specified labels. * By default (if no `aggregation` is explicitly specified), the raw time * series data is returned. + * @type \Google\Cloud\Monitoring\V3\Aggregation $secondary_aggregation + * Apply a second aggregation after `aggregation` is applied. May only be + * specified if `aggregation` is specified. * @type string $order_by * Unsupported: must be left blank. The points in each time series are * currently returned in reverse time order (most recent to oldest). @@ -130,8 +146,11 @@ public function __construct($data = NULL) { } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name), + * organization or folder on which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] + * organizations/[ORGANIZATION_ID] + * folders/[FOLDER_ID] * * Generated from protobuf field string name = 10 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -142,8 +161,11 @@ public function getName() } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name), + * organization or folder on which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] + * organizations/[ORGANIZATION_ID] + * folders/[FOLDER_ID] * * Generated from protobuf field string name = 10 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var @@ -199,13 +221,23 @@ public function setFilter($var) * in the response. * * Generated from protobuf field .google.monitoring.v3.TimeInterval interval = 4 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\TimeInterval + * @return \Google\Cloud\Monitoring\V3\TimeInterval|null */ public function getInterval() { return $this->interval; } + public function hasInterval() + { + return isset($this->interval); + } + + public function clearInterval() + { + unset($this->interval); + } + /** * Required. The time interval for which results should be returned. Only time series * that contain data points in the specified interval are included @@ -230,13 +262,23 @@ public function setInterval($var) * series data is returned. * * Generated from protobuf field .google.monitoring.v3.Aggregation aggregation = 5; - * @return \Google\Cloud\Monitoring\V3\Aggregation + * @return \Google\Cloud\Monitoring\V3\Aggregation|null */ public function getAggregation() { return $this->aggregation; } + public function hasAggregation() + { + return isset($this->aggregation); + } + + public function clearAggregation() + { + unset($this->aggregation); + } + /** * Specifies the alignment of data points in individual time series as * well as how to combine the retrieved time series across specified labels. @@ -255,6 +297,44 @@ public function setAggregation($var) return $this; } + /** + * Apply a second aggregation after `aggregation` is applied. May only be + * specified if `aggregation` is specified. + * + * Generated from protobuf field .google.monitoring.v3.Aggregation secondary_aggregation = 11; + * @return \Google\Cloud\Monitoring\V3\Aggregation|null + */ + public function getSecondaryAggregation() + { + return $this->secondary_aggregation; + } + + public function hasSecondaryAggregation() + { + return isset($this->secondary_aggregation); + } + + public function clearSecondaryAggregation() + { + unset($this->secondary_aggregation); + } + + /** + * Apply a second aggregation after `aggregation` is applied. May only be + * specified if `aggregation` is specified. + * + * Generated from protobuf field .google.monitoring.v3.Aggregation secondary_aggregation = 11; + * @param \Google\Cloud\Monitoring\V3\Aggregation $var + * @return $this + */ + public function setSecondaryAggregation($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Aggregation::class); + $this->secondary_aggregation = $var; + + return $this; + } + /** * Unsupported: must be left blank. The points in each time series are * currently returned in reverse time order (most recent to oldest). @@ -303,7 +383,7 @@ public function getView() */ public function setView($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\ListTimeSeriesRequest_TimeSeriesView::class); + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\ListTimeSeriesRequest\TimeSeriesView::class); $this->view = $var; return $this; diff --git a/Monitoring/src/V3/ListTimeSeriesResponse.php b/Monitoring/src/V3/ListTimeSeriesResponse.php index 413a97831a9..3c95ae4b6eb 100644 --- a/Monitoring/src/V3/ListTimeSeriesResponse.php +++ b/Monitoring/src/V3/ListTimeSeriesResponse.php @@ -36,6 +36,17 @@ class ListTimeSeriesResponse extends \Google\Protobuf\Internal\Message * Generated from protobuf field repeated .google.rpc.Status execution_errors = 3; */ private $execution_errors; + /** + * The unit in which all `time_series` point values are reported. `unit` + * follows the UCUM format for units as seen in + * https://unitsofmeasure.org/ucum.html. + * If different `time_series` have different units (for example, because they + * come from different metric types, or a unit is absent), then `unit` will be + * "{not_a_unit}". + * + * Generated from protobuf field string unit = 5; + */ + private $unit = ''; /** * Constructor. @@ -52,6 +63,13 @@ class ListTimeSeriesResponse extends \Google\Protobuf\Internal\Message * @type \Google\Rpc\Status[]|\Google\Protobuf\Internal\RepeatedField $execution_errors * Query execution errors that may have caused the time series data returned * to be incomplete. + * @type string $unit + * The unit in which all `time_series` point values are reported. `unit` + * follows the UCUM format for units as seen in + * https://unitsofmeasure.org/ucum.html. + * If different `time_series` have different units (for example, because they + * come from different metric types, or a unit is absent), then `unit` will be + * "{not_a_unit}". * } */ public function __construct($data = NULL) { @@ -143,5 +161,41 @@ public function setExecutionErrors($var) return $this; } + /** + * The unit in which all `time_series` point values are reported. `unit` + * follows the UCUM format for units as seen in + * https://unitsofmeasure.org/ucum.html. + * If different `time_series` have different units (for example, because they + * come from different metric types, or a unit is absent), then `unit` will be + * "{not_a_unit}". + * + * Generated from protobuf field string unit = 5; + * @return string + */ + public function getUnit() + { + return $this->unit; + } + + /** + * The unit in which all `time_series` point values are reported. `unit` + * follows the UCUM format for units as seen in + * https://unitsofmeasure.org/ucum.html. + * If different `time_series` have different units (for example, because they + * come from different metric types, or a unit is absent), then `unit` will be + * "{not_a_unit}". + * + * Generated from protobuf field string unit = 5; + * @param string $var + * @return $this + */ + public function setUnit($var) + { + GPBUtil::checkString($var, True); + $this->unit = $var; + + return $this; + } + } diff --git a/Monitoring/src/V3/ListUptimeCheckConfigsRequest.php b/Monitoring/src/V3/ListUptimeCheckConfigsRequest.php index 362cf253b5d..dc89eba494a 100644 --- a/Monitoring/src/V3/ListUptimeCheckConfigsRequest.php +++ b/Monitoring/src/V3/ListUptimeCheckConfigsRequest.php @@ -16,7 +16,8 @@ class ListUptimeCheckConfigsRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project whose Uptime check configurations are listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose Uptime check configurations are listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -47,7 +48,8 @@ class ListUptimeCheckConfigsRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $parent - * Required. The project whose Uptime check configurations are listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose Uptime check configurations are listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * @type int $page_size * The maximum number of results to return in a single response. The server @@ -66,7 +68,8 @@ public function __construct($data = NULL) { } /** - * Required. The project whose Uptime check configurations are listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose Uptime check configurations are listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -78,7 +81,8 @@ public function getParent() } /** - * Required. The project whose Uptime check configurations are listed. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) + * whose Uptime check configurations are listed. The format is: * projects/[PROJECT_ID_OR_NUMBER] * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { diff --git a/Monitoring/src/V3/MetricServiceClient.php b/Monitoring/src/V3/MetricServiceClient.php index e1c93fccab4..9b684d833d4 100644 --- a/Monitoring/src/V3/MetricServiceClient.php +++ b/Monitoring/src/V3/MetricServiceClient.php @@ -17,20 +17,18 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/metric_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/metric_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3; use Google\Cloud\Monitoring\V3\Gapic\MetricServiceGapicClient; -/** - * {@inheritdoc} - */ +/** {@inheritdoc} */ class MetricServiceClient extends MetricServiceGapicClient { - // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see MetricServiceGapicClient} class. + // This class is intentionally empty, and is intended to hold manual additions to + // the generated {@see MetricServiceGapicClient} class. } diff --git a/Monitoring/src/V3/MetricServiceGrpcClient.php b/Monitoring/src/V3/MetricServiceGrpcClient.php index 192297fc62d..c8800806006 100644 --- a/Monitoring/src/V3/MetricServiceGrpcClient.php +++ b/Monitoring/src/V3/MetricServiceGrpcClient.php @@ -38,6 +38,7 @@ public function __construct($hostname, $opts, $channel = null) { * @param \Google\Cloud\Monitoring\V3\ListMonitoredResourceDescriptorsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListMonitoredResourceDescriptors(\Google\Cloud\Monitoring\V3\ListMonitoredResourceDescriptorsRequest $argument, $metadata = [], $options = []) { @@ -52,6 +53,7 @@ public function ListMonitoredResourceDescriptors(\Google\Cloud\Monitoring\V3\Lis * @param \Google\Cloud\Monitoring\V3\GetMonitoredResourceDescriptorRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetMonitoredResourceDescriptor(\Google\Cloud\Monitoring\V3\GetMonitoredResourceDescriptorRequest $argument, $metadata = [], $options = []) { @@ -66,6 +68,7 @@ public function GetMonitoredResourceDescriptor(\Google\Cloud\Monitoring\V3\GetMo * @param \Google\Cloud\Monitoring\V3\ListMetricDescriptorsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListMetricDescriptors(\Google\Cloud\Monitoring\V3\ListMetricDescriptorsRequest $argument, $metadata = [], $options = []) { @@ -80,6 +83,7 @@ public function ListMetricDescriptors(\Google\Cloud\Monitoring\V3\ListMetricDesc * @param \Google\Cloud\Monitoring\V3\GetMetricDescriptorRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetMetricDescriptor(\Google\Cloud\Monitoring\V3\GetMetricDescriptorRequest $argument, $metadata = [], $options = []) { @@ -91,11 +95,14 @@ public function GetMetricDescriptor(\Google\Cloud\Monitoring\V3\GetMetricDescrip /** * Creates a new metric descriptor. + * The creation is executed asynchronously and callers may check the returned + * operation to track its progress. * User-created metric descriptors define * [custom metrics](https://cloud.google.com/monitoring/custom-metrics). * @param \Google\Cloud\Monitoring\V3\CreateMetricDescriptorRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateMetricDescriptor(\Google\Cloud\Monitoring\V3\CreateMetricDescriptorRequest $argument, $metadata = [], $options = []) { @@ -112,6 +119,7 @@ public function CreateMetricDescriptor(\Google\Cloud\Monitoring\V3\CreateMetricD * @param \Google\Cloud\Monitoring\V3\DeleteMetricDescriptorRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteMetricDescriptor(\Google\Cloud\Monitoring\V3\DeleteMetricDescriptorRequest $argument, $metadata = [], $options = []) { @@ -126,6 +134,7 @@ public function DeleteMetricDescriptor(\Google\Cloud\Monitoring\V3\DeleteMetricD * @param \Google\Cloud\Monitoring\V3\ListTimeSeriesRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListTimeSeries(\Google\Cloud\Monitoring\V3\ListTimeSeriesRequest $argument, $metadata = [], $options = []) { @@ -143,6 +152,7 @@ public function ListTimeSeries(\Google\Cloud\Monitoring\V3\ListTimeSeriesRequest * @param \Google\Cloud\Monitoring\V3\CreateTimeSeriesRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateTimeSeries(\Google\Cloud\Monitoring\V3\CreateTimeSeriesRequest $argument, $metadata = [], $options = []) { @@ -152,4 +162,27 @@ public function CreateTimeSeries(\Google\Cloud\Monitoring\V3\CreateTimeSeriesReq $metadata, $options); } + /** + * Creates or adds data to one or more service time series. A service time + * series is a time series for a metric from a Google Cloud service. The + * response is empty if all time series in the request were written. If any + * time series could not be written, a corresponding failure message is + * included in the error response. This endpoint rejects writes to + * user-defined metrics. + * This method is only for use by Google Cloud services. Use + * [projects.timeSeries.create][google.monitoring.v3.MetricService.CreateTimeSeries] + * instead. + * @param \Google\Cloud\Monitoring\V3\CreateTimeSeriesRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function CreateServiceTimeSeries(\Google\Cloud\Monitoring\V3\CreateTimeSeriesRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.monitoring.v3.MetricService/CreateServiceTimeSeries', + $argument, + ['\Google\Protobuf\GPBEmpty', 'decode'], + $metadata, $options); + } + } diff --git a/Monitoring/src/V3/MutationRecord.php b/Monitoring/src/V3/MutationRecord.php index 6aef66c995a..9b2c8b6a9fa 100644 --- a/Monitoring/src/V3/MutationRecord.php +++ b/Monitoring/src/V3/MutationRecord.php @@ -49,13 +49,23 @@ public function __construct($data = NULL) { * When the change occurred. * * Generated from protobuf field .google.protobuf.Timestamp mutate_time = 1; - * @return \Google\Protobuf\Timestamp + * @return \Google\Protobuf\Timestamp|null */ public function getMutateTime() { return $this->mutate_time; } + public function hasMutateTime() + { + return isset($this->mutate_time); + } + + public function clearMutateTime() + { + unset($this->mutate_time); + } + /** * When the change occurred. * diff --git a/Monitoring/src/V3/NotificationChannel.php b/Monitoring/src/V3/NotificationChannel.php index 0b8a0bb1712..b97f550ea86 100644 --- a/Monitoring/src/V3/NotificationChannel.php +++ b/Monitoring/src/V3/NotificationChannel.php @@ -105,6 +105,18 @@ class NotificationChannel extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.protobuf.BoolValue enabled = 11; */ private $enabled = null; + /** + * Record of the creation of this channel. + * + * Generated from protobuf field .google.monitoring.v3.MutationRecord creation_record = 12; + */ + private $creation_record = null; + /** + * Records of the modification of this channel. + * + * Generated from protobuf field repeated .google.monitoring.v3.MutationRecord mutation_records = 13; + */ + private $mutation_records; /** * Constructor. @@ -166,6 +178,10 @@ class NotificationChannel extends \Google\Protobuf\Internal\Message * the channel. This is a more convenient approach when the change is * temporary and you want to receive notifications from the same set * of alerting policies on the channel at some point in the future. + * @type \Google\Cloud\Monitoring\V3\MutationRecord $creation_record + * Record of the creation of this channel. + * @type \Google\Cloud\Monitoring\V3\MutationRecord[]|\Google\Protobuf\Internal\RepeatedField $mutation_records + * Records of the modification of this channel. * } */ public function __construct($data = NULL) { @@ -415,7 +431,7 @@ public function getVerificationStatus() */ public function setVerificationStatus($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\NotificationChannel_VerificationStatus::class); + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\NotificationChannel\VerificationStatus::class); $this->verification_status = $var; return $this; @@ -430,13 +446,23 @@ public function setVerificationStatus($var) * of alerting policies on the channel at some point in the future. * * Generated from protobuf field .google.protobuf.BoolValue enabled = 11; - * @return \Google\Protobuf\BoolValue + * @return \Google\Protobuf\BoolValue|null */ public function getEnabled() { return $this->enabled; } + public function hasEnabled() + { + return isset($this->enabled); + } + + public function clearEnabled() + { + unset($this->enabled); + } + /** * Returns the unboxed value from getEnabled() @@ -494,5 +520,67 @@ public function setEnabledValue($var) $this->writeWrapperValue("enabled", $var); return $this;} + /** + * Record of the creation of this channel. + * + * Generated from protobuf field .google.monitoring.v3.MutationRecord creation_record = 12; + * @return \Google\Cloud\Monitoring\V3\MutationRecord|null + */ + public function getCreationRecord() + { + return $this->creation_record; + } + + public function hasCreationRecord() + { + return isset($this->creation_record); + } + + public function clearCreationRecord() + { + unset($this->creation_record); + } + + /** + * Record of the creation of this channel. + * + * Generated from protobuf field .google.monitoring.v3.MutationRecord creation_record = 12; + * @param \Google\Cloud\Monitoring\V3\MutationRecord $var + * @return $this + */ + public function setCreationRecord($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\MutationRecord::class); + $this->creation_record = $var; + + return $this; + } + + /** + * Records of the modification of this channel. + * + * Generated from protobuf field repeated .google.monitoring.v3.MutationRecord mutation_records = 13; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMutationRecords() + { + return $this->mutation_records; + } + + /** + * Records of the modification of this channel. + * + * Generated from protobuf field repeated .google.monitoring.v3.MutationRecord mutation_records = 13; + * @param \Google\Cloud\Monitoring\V3\MutationRecord[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMutationRecords($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\MutationRecord::class); + $this->mutation_records = $arr; + + return $this; + } + } diff --git a/Monitoring/src/V3/NotificationChannelDescriptor.php b/Monitoring/src/V3/NotificationChannelDescriptor.php index bb9457d58d4..ffb3ef61807 100644 --- a/Monitoring/src/V3/NotificationChannelDescriptor.php +++ b/Monitoring/src/V3/NotificationChannelDescriptor.php @@ -26,7 +26,10 @@ class NotificationChannelDescriptor extends \Google\Protobuf\Internal\Message */ private $name = ''; /** - * The type of notification channel, such as "email", "sms", etc. + * The type of notification channel, such as "email" and "sms". To view the + * full list of channels, see + * [Channel + * descriptors](https://cloud.google.com/monitoring/alerts/using-channels-api#ncd). * Notification channel types are globally unique. * * Generated from protobuf field string type = 1; @@ -60,6 +63,7 @@ class NotificationChannelDescriptor extends \Google\Protobuf\Internal\Message * must be one of the supported_tiers. * * Generated from protobuf field repeated .google.monitoring.v3.ServiceTier supported_tiers = 5 [deprecated = true]; + * @deprecated */ private $supported_tiers; /** @@ -80,7 +84,10 @@ class NotificationChannelDescriptor extends \Google\Protobuf\Internal\Message * projects/[PROJECT_ID_OR_NUMBER]/notificationChannelDescriptors/[TYPE] * In the above, `[TYPE]` is the value of the `type` field. * @type string $type - * The type of notification channel, such as "email", "sms", etc. + * The type of notification channel, such as "email" and "sms". To view the + * full list of channels, see + * [Channel + * descriptors](https://cloud.google.com/monitoring/alerts/using-channels-api#ncd). * Notification channel types are globally unique. * @type string $display_name * A human-readable name for the notification channel type. This @@ -136,7 +143,10 @@ public function setName($var) } /** - * The type of notification channel, such as "email", "sms", etc. + * The type of notification channel, such as "email" and "sms". To view the + * full list of channels, see + * [Channel + * descriptors](https://cloud.google.com/monitoring/alerts/using-channels-api#ncd). * Notification channel types are globally unique. * * Generated from protobuf field string type = 1; @@ -148,7 +158,10 @@ public function getType() } /** - * The type of notification channel, such as "email", "sms", etc. + * The type of notification channel, such as "email" and "sms". To view the + * full list of channels, see + * [Channel + * descriptors](https://cloud.google.com/monitoring/alerts/using-channels-api#ncd). * Notification channel types are globally unique. * * Generated from protobuf field string type = 1; @@ -257,9 +270,11 @@ public function setLabels($var) * * Generated from protobuf field repeated .google.monitoring.v3.ServiceTier supported_tiers = 5 [deprecated = true]; * @return \Google\Protobuf\Internal\RepeatedField + * @deprecated */ public function getSupportedTiers() { + @trigger_error('supported_tiers is deprecated.', E_USER_DEPRECATED); return $this->supported_tiers; } @@ -270,9 +285,11 @@ public function getSupportedTiers() * Generated from protobuf field repeated .google.monitoring.v3.ServiceTier supported_tiers = 5 [deprecated = true]; * @param int[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this + * @deprecated */ public function setSupportedTiers($var) { + @trigger_error('supported_tiers is deprecated.', E_USER_DEPRECATED); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Monitoring\V3\ServiceTier::class); $this->supported_tiers = $arr; diff --git a/Monitoring/src/V3/NotificationChannelServiceClient.php b/Monitoring/src/V3/NotificationChannelServiceClient.php index fafd92251ef..9d3f0043f2b 100644 --- a/Monitoring/src/V3/NotificationChannelServiceClient.php +++ b/Monitoring/src/V3/NotificationChannelServiceClient.php @@ -17,20 +17,18 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/notification_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/notification_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3; use Google\Cloud\Monitoring\V3\Gapic\NotificationChannelServiceGapicClient; -/** - * {@inheritdoc} - */ +/** {@inheritdoc} */ class NotificationChannelServiceClient extends NotificationChannelServiceGapicClient { - // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see NotificationChannelServiceGapicClient} class. + // This class is intentionally empty, and is intended to hold manual additions to + // the generated {@see NotificationChannelServiceGapicClient} class. } diff --git a/Monitoring/src/V3/NotificationChannelServiceGrpcClient.php b/Monitoring/src/V3/NotificationChannelServiceGrpcClient.php index fc3234b67ae..71047be673f 100644 --- a/Monitoring/src/V3/NotificationChannelServiceGrpcClient.php +++ b/Monitoring/src/V3/NotificationChannelServiceGrpcClient.php @@ -39,6 +39,7 @@ public function __construct($hostname, $opts, $channel = null) { * @param \Google\Cloud\Monitoring\V3\ListNotificationChannelDescriptorsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListNotificationChannelDescriptors(\Google\Cloud\Monitoring\V3\ListNotificationChannelDescriptorsRequest $argument, $metadata = [], $options = []) { @@ -54,6 +55,7 @@ public function ListNotificationChannelDescriptors(\Google\Cloud\Monitoring\V3\L * @param \Google\Cloud\Monitoring\V3\GetNotificationChannelDescriptorRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetNotificationChannelDescriptor(\Google\Cloud\Monitoring\V3\GetNotificationChannelDescriptorRequest $argument, $metadata = [], $options = []) { @@ -68,6 +70,7 @@ public function GetNotificationChannelDescriptor(\Google\Cloud\Monitoring\V3\Get * @param \Google\Cloud\Monitoring\V3\ListNotificationChannelsRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListNotificationChannels(\Google\Cloud\Monitoring\V3\ListNotificationChannelsRequest $argument, $metadata = [], $options = []) { @@ -86,6 +89,7 @@ public function ListNotificationChannels(\Google\Cloud\Monitoring\V3\ListNotific * @param \Google\Cloud\Monitoring\V3\GetNotificationChannelRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetNotificationChannel(\Google\Cloud\Monitoring\V3\GetNotificationChannelRequest $argument, $metadata = [], $options = []) { @@ -101,6 +105,7 @@ public function GetNotificationChannel(\Google\Cloud\Monitoring\V3\GetNotificati * @param \Google\Cloud\Monitoring\V3\CreateNotificationChannelRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateNotificationChannel(\Google\Cloud\Monitoring\V3\CreateNotificationChannelRequest $argument, $metadata = [], $options = []) { @@ -116,6 +121,7 @@ public function CreateNotificationChannel(\Google\Cloud\Monitoring\V3\CreateNoti * @param \Google\Cloud\Monitoring\V3\UpdateNotificationChannelRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function UpdateNotificationChannel(\Google\Cloud\Monitoring\V3\UpdateNotificationChannelRequest $argument, $metadata = [], $options = []) { @@ -130,6 +136,7 @@ public function UpdateNotificationChannel(\Google\Cloud\Monitoring\V3\UpdateNoti * @param \Google\Cloud\Monitoring\V3\DeleteNotificationChannelRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteNotificationChannel(\Google\Cloud\Monitoring\V3\DeleteNotificationChannelRequest $argument, $metadata = [], $options = []) { @@ -145,6 +152,7 @@ public function DeleteNotificationChannel(\Google\Cloud\Monitoring\V3\DeleteNoti * @param \Google\Cloud\Monitoring\V3\SendNotificationChannelVerificationCodeRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function SendNotificationChannelVerificationCode(\Google\Cloud\Monitoring\V3\SendNotificationChannelVerificationCodeRequest $argument, $metadata = [], $options = []) { @@ -179,6 +187,7 @@ public function SendNotificationChannelVerificationCode(\Google\Cloud\Monitoring * @param \Google\Cloud\Monitoring\V3\GetNotificationChannelVerificationCodeRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetNotificationChannelVerificationCode(\Google\Cloud\Monitoring\V3\GetNotificationChannelVerificationCodeRequest $argument, $metadata = [], $options = []) { @@ -195,6 +204,7 @@ public function GetNotificationChannelVerificationCode(\Google\Cloud\Monitoring\ * @param \Google\Cloud\Monitoring\V3\VerifyNotificationChannelRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function VerifyNotificationChannel(\Google\Cloud\Monitoring\V3\VerifyNotificationChannelRequest $argument, $metadata = [], $options = []) { diff --git a/Monitoring/src/V3/Point.php b/Monitoring/src/V3/Point.php index c80c9763978..394d71566e8 100644 --- a/Monitoring/src/V3/Point.php +++ b/Monitoring/src/V3/Point.php @@ -73,13 +73,23 @@ public function __construct($data = NULL) { * time for the following points. * * Generated from protobuf field .google.monitoring.v3.TimeInterval interval = 1; - * @return \Google\Cloud\Monitoring\V3\TimeInterval + * @return \Google\Cloud\Monitoring\V3\TimeInterval|null */ public function getInterval() { return $this->interval; } + public function hasInterval() + { + return isset($this->interval); + } + + public function clearInterval() + { + unset($this->interval); + } + /** * The time interval to which the data point applies. For `GAUGE` metrics, * the start time is optional, but if it is supplied, it must equal the @@ -107,13 +117,23 @@ public function setInterval($var) * The value of the data point. * * Generated from protobuf field .google.monitoring.v3.TypedValue value = 2; - * @return \Google\Cloud\Monitoring\V3\TypedValue + * @return \Google\Cloud\Monitoring\V3\TypedValue|null */ public function getValue() { return $this->value; } + public function hasValue() + { + return isset($this->value); + } + + public function clearValue() + { + unset($this->value); + } + /** * The value of the data point. * diff --git a/Monitoring/src/V3/QueryError.php b/Monitoring/src/V3/QueryError.php index 194bab830d3..e7f8b174c73 100644 --- a/Monitoring/src/V3/QueryError.php +++ b/Monitoring/src/V3/QueryError.php @@ -52,13 +52,23 @@ public function __construct($data = NULL) { * to. * * Generated from protobuf field .google.monitoring.v3.TextLocator locator = 1; - * @return \Google\Cloud\Monitoring\V3\TextLocator + * @return \Google\Cloud\Monitoring\V3\TextLocator|null */ public function getLocator() { return $this->locator; } + public function hasLocator() + { + return isset($this->locator); + } + + public function clearLocator() + { + unset($this->locator); + } + /** * The location of the time series query language text that this error applies * to. diff --git a/Monitoring/src/V3/QueryServiceClient.php b/Monitoring/src/V3/QueryServiceClient.php new file mode 100644 index 00000000000..57a9d7a46a6 --- /dev/null +++ b/Monitoring/src/V3/QueryServiceClient.php @@ -0,0 +1,34 @@ +_simpleRequest('/google.monitoring.v3.QueryService/QueryTimeSeries', + $argument, + ['\Google\Cloud\Monitoring\V3\QueryTimeSeriesResponse', 'decode'], + $metadata, $options); + } + +} diff --git a/Monitoring/src/V3/QueryTimeSeriesRequest.php b/Monitoring/src/V3/QueryTimeSeriesRequest.php index c4655be4704..9e1e3bcf747 100644 --- a/Monitoring/src/V3/QueryTimeSeriesRequest.php +++ b/Monitoring/src/V3/QueryTimeSeriesRequest.php @@ -16,17 +16,19 @@ class QueryTimeSeriesRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ private $name = ''; /** - * Required. The query in the monitoring query language format. The default - * time zone is in UTC. + * Required. The query in the [Monitoring Query + * Language](https://cloud.google.com/monitoring/mql/reference) format. + * The default time zone is in UTC. * - * Generated from protobuf field string query = 7; + * Generated from protobuf field string query = 7 [(.google.api.field_behavior) = REQUIRED]; */ private $query = ''; /** @@ -51,11 +53,13 @@ class QueryTimeSeriesRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * @type string $query - * Required. The query in the monitoring query language format. The default - * time zone is in UTC. + * Required. The query in the [Monitoring Query + * Language](https://cloud.google.com/monitoring/mql/reference) format. + * The default time zone is in UTC. * @type int $page_size * A positive number that is the maximum number of time_series_data to return. * @type string $page_token @@ -70,10 +74,11 @@ public function __construct($data = NULL) { } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getName() @@ -82,10 +87,11 @@ public function getName() } /** - * Required. The project on which to execute the request. The format is: + * Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name) on + * which to execute the request. The format is: * projects/[PROJECT_ID_OR_NUMBER] * - * Generated from protobuf field string name = 1; + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ @@ -98,10 +104,11 @@ public function setName($var) } /** - * Required. The query in the monitoring query language format. The default - * time zone is in UTC. + * Required. The query in the [Monitoring Query + * Language](https://cloud.google.com/monitoring/mql/reference) format. + * The default time zone is in UTC. * - * Generated from protobuf field string query = 7; + * Generated from protobuf field string query = 7 [(.google.api.field_behavior) = REQUIRED]; * @return string */ public function getQuery() @@ -110,10 +117,11 @@ public function getQuery() } /** - * Required. The query in the monitoring query language format. The default - * time zone is in UTC. + * Required. The query in the [Monitoring Query + * Language](https://cloud.google.com/monitoring/mql/reference) format. + * The default time zone is in UTC. * - * Generated from protobuf field string query = 7; + * Generated from protobuf field string query = 7 [(.google.api.field_behavior) = REQUIRED]; * @param string $var * @return $this */ diff --git a/Monitoring/src/V3/QueryTimeSeriesResponse.php b/Monitoring/src/V3/QueryTimeSeriesResponse.php index 67377082c11..6bf5f6b56a7 100644 --- a/Monitoring/src/V3/QueryTimeSeriesResponse.php +++ b/Monitoring/src/V3/QueryTimeSeriesResponse.php @@ -73,13 +73,23 @@ public function __construct($data = NULL) { * The descriptor for the time series data. * * Generated from protobuf field .google.monitoring.v3.TimeSeriesDescriptor time_series_descriptor = 8; - * @return \Google\Cloud\Monitoring\V3\TimeSeriesDescriptor + * @return \Google\Cloud\Monitoring\V3\TimeSeriesDescriptor|null */ public function getTimeSeriesDescriptor() { return $this->time_series_descriptor; } + public function hasTimeSeriesDescriptor() + { + return isset($this->time_series_descriptor); + } + + public function clearTimeSeriesDescriptor() + { + unset($this->time_series_descriptor); + } + /** * The descriptor for the time series data. * diff --git a/Monitoring/src/V3/Range.php b/Monitoring/src/V3/Range.php index 4c67ef56aa4..685c9574f8a 100644 --- a/Monitoring/src/V3/Range.php +++ b/Monitoring/src/V3/Range.php @@ -9,9 +9,7 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Range of numerical values, inclusive of `min` and exclusive of `max`. If the - * open range "< range.max" is desired, set `range.min = -infinity`. If the open - * range ">= range.min" is desired, set `range.max = infinity`. + * Range of numerical values within `min` and `max`. * * Generated from protobuf message google.monitoring.v3.Range */ diff --git a/Monitoring/src/V3/RequestBasedSli.php b/Monitoring/src/V3/RequestBasedSli.php index 43b9d6f3e05..e4820f273c2 100644 --- a/Monitoring/src/V3/RequestBasedSli.php +++ b/Monitoring/src/V3/RequestBasedSli.php @@ -44,13 +44,18 @@ public function __construct($data = NULL) { * `total_service` is computed from two `TimeSeries`. * * Generated from protobuf field .google.monitoring.v3.TimeSeriesRatio good_total_ratio = 1; - * @return \Google\Cloud\Monitoring\V3\TimeSeriesRatio + * @return \Google\Cloud\Monitoring\V3\TimeSeriesRatio|null */ public function getGoodTotalRatio() { return $this->readOneof(1); } + public function hasGoodTotalRatio() + { + return $this->hasOneof(1); + } + /** * `good_total_ratio` is used when the ratio of `good_service` to * `total_service` is computed from two `TimeSeries`. @@ -74,13 +79,18 @@ public function setGoodTotalRatio($var) * `Distribution`. * * Generated from protobuf field .google.monitoring.v3.DistributionCut distribution_cut = 3; - * @return \Google\Cloud\Monitoring\V3\DistributionCut + * @return \Google\Cloud\Monitoring\V3\DistributionCut|null */ public function getDistributionCut() { return $this->readOneof(3); } + public function hasDistributionCut() + { + return $this->hasOneof(3); + } + /** * `distribution_cut` is used when `good_service` is a count of values * aggregated in a `Distribution` that fall into a good range. The diff --git a/Monitoring/src/V3/Service.php b/Monitoring/src/V3/Service.php index 042b3764cd7..af568f611c2 100644 --- a/Monitoring/src/V3/Service.php +++ b/Monitoring/src/V3/Service.php @@ -38,6 +38,17 @@ class Service extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.monitoring.v3.Service.Telemetry telemetry = 13; */ private $telemetry = null; + /** + * Labels which have been used to annotate the service. Label keys must start + * with a letter. Label keys and values may contain lowercase letters, + * numbers, underscores, and dashes. Label keys and values have a maximum + * length of 63 characters, and must be less than 128 bytes in size. Up to 64 + * label entries may be stored. For labels which do not have a semantic value, + * the empty string may be supplied for the label value. + * + * Generated from protobuf field map user_labels = 14; + */ + private $user_labels; protected $identifier; /** @@ -61,8 +72,19 @@ class Service extends \Google\Protobuf\Internal\Message * Type used for Istio services that live in a Kubernetes cluster. * @type \Google\Cloud\Monitoring\V3\Service\MeshIstio $mesh_istio * Type used for Istio services scoped to an Istio mesh. + * @type \Google\Cloud\Monitoring\V3\Service\IstioCanonicalService $istio_canonical_service + * Type used for canonical services scoped to an Istio mesh. + * Metrics for Istio are + * [documented here](https://istio.io/latest/docs/reference/config/metrics/) * @type \Google\Cloud\Monitoring\V3\Service\Telemetry $telemetry * Configuration for how to query telemetry on a Service. + * @type array|\Google\Protobuf\Internal\MapField $user_labels + * Labels which have been used to annotate the service. Label keys must start + * with a letter. Label keys and values may contain lowercase letters, + * numbers, underscores, and dashes. Label keys and values have a maximum + * length of 63 characters, and must be less than 128 bytes in size. Up to 64 + * label entries may be stored. For labels which do not have a semantic value, + * the empty string may be supplied for the label value. * } */ public function __construct($data = NULL) { @@ -128,13 +150,18 @@ public function setDisplayName($var) * Custom service type. * * Generated from protobuf field .google.monitoring.v3.Service.Custom custom = 6; - * @return \Google\Cloud\Monitoring\V3\Service\Custom + * @return \Google\Cloud\Monitoring\V3\Service\Custom|null */ public function getCustom() { return $this->readOneof(6); } + public function hasCustom() + { + return $this->hasOneof(6); + } + /** * Custom service type. * @@ -144,7 +171,7 @@ public function getCustom() */ public function setCustom($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service_Custom::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service\Custom::class); $this->writeOneof(6, $var); return $this; @@ -154,13 +181,18 @@ public function setCustom($var) * Type used for App Engine services. * * Generated from protobuf field .google.monitoring.v3.Service.AppEngine app_engine = 7; - * @return \Google\Cloud\Monitoring\V3\Service\AppEngine + * @return \Google\Cloud\Monitoring\V3\Service\AppEngine|null */ public function getAppEngine() { return $this->readOneof(7); } + public function hasAppEngine() + { + return $this->hasOneof(7); + } + /** * Type used for App Engine services. * @@ -170,7 +202,7 @@ public function getAppEngine() */ public function setAppEngine($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service_AppEngine::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service\AppEngine::class); $this->writeOneof(7, $var); return $this; @@ -180,13 +212,18 @@ public function setAppEngine($var) * Type used for Cloud Endpoints services. * * Generated from protobuf field .google.monitoring.v3.Service.CloudEndpoints cloud_endpoints = 8; - * @return \Google\Cloud\Monitoring\V3\Service\CloudEndpoints + * @return \Google\Cloud\Monitoring\V3\Service\CloudEndpoints|null */ public function getCloudEndpoints() { return $this->readOneof(8); } + public function hasCloudEndpoints() + { + return $this->hasOneof(8); + } + /** * Type used for Cloud Endpoints services. * @@ -196,7 +233,7 @@ public function getCloudEndpoints() */ public function setCloudEndpoints($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service_CloudEndpoints::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service\CloudEndpoints::class); $this->writeOneof(8, $var); return $this; @@ -205,24 +242,29 @@ public function setCloudEndpoints($var) /** * Type used for Istio services that live in a Kubernetes cluster. * - * Generated from protobuf field .google.monitoring.v3.Service.ClusterIstio cluster_istio = 9 [deprecated = true]; - * @return \Google\Cloud\Monitoring\V3\Service\ClusterIstio + * Generated from protobuf field .google.monitoring.v3.Service.ClusterIstio cluster_istio = 9; + * @return \Google\Cloud\Monitoring\V3\Service\ClusterIstio|null */ public function getClusterIstio() { return $this->readOneof(9); } + public function hasClusterIstio() + { + return $this->hasOneof(9); + } + /** * Type used for Istio services that live in a Kubernetes cluster. * - * Generated from protobuf field .google.monitoring.v3.Service.ClusterIstio cluster_istio = 9 [deprecated = true]; + * Generated from protobuf field .google.monitoring.v3.Service.ClusterIstio cluster_istio = 9; * @param \Google\Cloud\Monitoring\V3\Service\ClusterIstio $var * @return $this */ public function setClusterIstio($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service_ClusterIstio::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service\ClusterIstio::class); $this->writeOneof(9, $var); return $this; @@ -232,13 +274,18 @@ public function setClusterIstio($var) * Type used for Istio services scoped to an Istio mesh. * * Generated from protobuf field .google.monitoring.v3.Service.MeshIstio mesh_istio = 10; - * @return \Google\Cloud\Monitoring\V3\Service\MeshIstio + * @return \Google\Cloud\Monitoring\V3\Service\MeshIstio|null */ public function getMeshIstio() { return $this->readOneof(10); } + public function hasMeshIstio() + { + return $this->hasOneof(10); + } + /** * Type used for Istio services scoped to an Istio mesh. * @@ -248,23 +295,68 @@ public function getMeshIstio() */ public function setMeshIstio($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service_MeshIstio::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service\MeshIstio::class); $this->writeOneof(10, $var); return $this; } + /** + * Type used for canonical services scoped to an Istio mesh. + * Metrics for Istio are + * [documented here](https://istio.io/latest/docs/reference/config/metrics/) + * + * Generated from protobuf field .google.monitoring.v3.Service.IstioCanonicalService istio_canonical_service = 11; + * @return \Google\Cloud\Monitoring\V3\Service\IstioCanonicalService|null + */ + public function getIstioCanonicalService() + { + return $this->readOneof(11); + } + + public function hasIstioCanonicalService() + { + return $this->hasOneof(11); + } + + /** + * Type used for canonical services scoped to an Istio mesh. + * Metrics for Istio are + * [documented here](https://istio.io/latest/docs/reference/config/metrics/) + * + * Generated from protobuf field .google.monitoring.v3.Service.IstioCanonicalService istio_canonical_service = 11; + * @param \Google\Cloud\Monitoring\V3\Service\IstioCanonicalService $var + * @return $this + */ + public function setIstioCanonicalService($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service\IstioCanonicalService::class); + $this->writeOneof(11, $var); + + return $this; + } + /** * Configuration for how to query telemetry on a Service. * * Generated from protobuf field .google.monitoring.v3.Service.Telemetry telemetry = 13; - * @return \Google\Cloud\Monitoring\V3\Service\Telemetry + * @return \Google\Cloud\Monitoring\V3\Service\Telemetry|null */ public function getTelemetry() { return $this->telemetry; } + public function hasTelemetry() + { + return isset($this->telemetry); + } + + public function clearTelemetry() + { + unset($this->telemetry); + } + /** * Configuration for how to query telemetry on a Service. * @@ -274,12 +366,48 @@ public function getTelemetry() */ public function setTelemetry($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service_Telemetry::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\Service\Telemetry::class); $this->telemetry = $var; return $this; } + /** + * Labels which have been used to annotate the service. Label keys must start + * with a letter. Label keys and values may contain lowercase letters, + * numbers, underscores, and dashes. Label keys and values have a maximum + * length of 63 characters, and must be less than 128 bytes in size. Up to 64 + * label entries may be stored. For labels which do not have a semantic value, + * the empty string may be supplied for the label value. + * + * Generated from protobuf field map user_labels = 14; + * @return \Google\Protobuf\Internal\MapField + */ + public function getUserLabels() + { + return $this->user_labels; + } + + /** + * Labels which have been used to annotate the service. Label keys must start + * with a letter. Label keys and values may contain lowercase letters, + * numbers, underscores, and dashes. Label keys and values have a maximum + * length of 63 characters, and must be less than 128 bytes in size. Up to 64 + * label entries may be stored. For labels which do not have a semantic value, + * the empty string may be supplied for the label value. + * + * Generated from protobuf field map user_labels = 14; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setUserLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->user_labels = $arr; + + return $this; + } + /** * @return string */ diff --git a/Monitoring/src/V3/Service/ClusterIstio.php b/Monitoring/src/V3/Service/ClusterIstio.php index 93601fdd426..46beffd3f24 100644 --- a/Monitoring/src/V3/Service/ClusterIstio.php +++ b/Monitoring/src/V3/Service/ClusterIstio.php @@ -10,7 +10,8 @@ /** * Istio service scoped to a single Kubernetes cluster. Learn more at - * http://istio.io. + * https://istio.io. Clusters running OSS Istio will have their services + * ingested as this type. * * Generated from protobuf message google.monitoring.v3.Service.ClusterIstio */ diff --git a/Monitoring/src/V3/Service/IstioCanonicalService.php b/Monitoring/src/V3/Service/IstioCanonicalService.php new file mode 100644 index 00000000000..e226bfee397 --- /dev/null +++ b/Monitoring/src/V3/Service/IstioCanonicalService.php @@ -0,0 +1,171 @@ += + * 1.6.8 will have their services ingested as this type. + * + * Generated from protobuf message google.monitoring.v3.Service.IstioCanonicalService + */ +class IstioCanonicalService extends \Google\Protobuf\Internal\Message +{ + /** + * Identifier for the Istio mesh in which this canonical service is defined. + * Corresponds to the `mesh_uid` metric label in + * [Istio metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * + * Generated from protobuf field string mesh_uid = 1; + */ + private $mesh_uid = ''; + /** + * The namespace of the canonical service underlying this service. + * Corresponds to the `destination_canonical_service_namespace` metric + * label in [Istio + * metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * + * Generated from protobuf field string canonical_service_namespace = 3; + */ + private $canonical_service_namespace = ''; + /** + * The name of the canonical service underlying this service. + * Corresponds to the `destination_canonical_service_name` metric label in + * label in [Istio + * metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * + * Generated from protobuf field string canonical_service = 4; + */ + private $canonical_service = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $mesh_uid + * Identifier for the Istio mesh in which this canonical service is defined. + * Corresponds to the `mesh_uid` metric label in + * [Istio metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * @type string $canonical_service_namespace + * The namespace of the canonical service underlying this service. + * Corresponds to the `destination_canonical_service_namespace` metric + * label in [Istio + * metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * @type string $canonical_service + * The name of the canonical service underlying this service. + * Corresponds to the `destination_canonical_service_name` metric label in + * label in [Istio + * metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Monitoring\V3\Service::initOnce(); + parent::__construct($data); + } + + /** + * Identifier for the Istio mesh in which this canonical service is defined. + * Corresponds to the `mesh_uid` metric label in + * [Istio metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * + * Generated from protobuf field string mesh_uid = 1; + * @return string + */ + public function getMeshUid() + { + return $this->mesh_uid; + } + + /** + * Identifier for the Istio mesh in which this canonical service is defined. + * Corresponds to the `mesh_uid` metric label in + * [Istio metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * + * Generated from protobuf field string mesh_uid = 1; + * @param string $var + * @return $this + */ + public function setMeshUid($var) + { + GPBUtil::checkString($var, True); + $this->mesh_uid = $var; + + return $this; + } + + /** + * The namespace of the canonical service underlying this service. + * Corresponds to the `destination_canonical_service_namespace` metric + * label in [Istio + * metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * + * Generated from protobuf field string canonical_service_namespace = 3; + * @return string + */ + public function getCanonicalServiceNamespace() + { + return $this->canonical_service_namespace; + } + + /** + * The namespace of the canonical service underlying this service. + * Corresponds to the `destination_canonical_service_namespace` metric + * label in [Istio + * metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * + * Generated from protobuf field string canonical_service_namespace = 3; + * @param string $var + * @return $this + */ + public function setCanonicalServiceNamespace($var) + { + GPBUtil::checkString($var, True); + $this->canonical_service_namespace = $var; + + return $this; + } + + /** + * The name of the canonical service underlying this service. + * Corresponds to the `destination_canonical_service_name` metric label in + * label in [Istio + * metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * + * Generated from protobuf field string canonical_service = 4; + * @return string + */ + public function getCanonicalService() + { + return $this->canonical_service; + } + + /** + * The name of the canonical service underlying this service. + * Corresponds to the `destination_canonical_service_name` metric label in + * label in [Istio + * metrics](https://cloud.google.com/monitoring/api/metrics_istio). + * + * Generated from protobuf field string canonical_service = 4; + * @param string $var + * @return $this + */ + public function setCanonicalService($var) + { + GPBUtil::checkString($var, True); + $this->canonical_service = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(IstioCanonicalService::class, \Google\Cloud\Monitoring\V3\Service_IstioCanonicalService::class); + diff --git a/Monitoring/src/V3/Service/MeshIstio.php b/Monitoring/src/V3/Service/MeshIstio.php index d8999d5cc8c..065c874bb0c 100644 --- a/Monitoring/src/V3/Service/MeshIstio.php +++ b/Monitoring/src/V3/Service/MeshIstio.php @@ -9,7 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Istio service scoped to an Istio mesh + * Istio service scoped to an Istio mesh. Anthos clusters running ASM < 1.6.8 + * will have their services ingested as this type. * * Generated from protobuf message google.monitoring.v3.Service.MeshIstio */ diff --git a/Monitoring/src/V3/ServiceLevelIndicator.php b/Monitoring/src/V3/ServiceLevelIndicator.php index cbae960c0f2..a1d08a4e348 100644 --- a/Monitoring/src/V3/ServiceLevelIndicator.php +++ b/Monitoring/src/V3/ServiceLevelIndicator.php @@ -52,13 +52,18 @@ public function __construct($data = NULL) { * Basic SLI on a well-known service type. * * Generated from protobuf field .google.monitoring.v3.BasicSli basic_sli = 4; - * @return \Google\Cloud\Monitoring\V3\BasicSli + * @return \Google\Cloud\Monitoring\V3\BasicSli|null */ public function getBasicSli() { return $this->readOneof(4); } + public function hasBasicSli() + { + return $this->hasOneof(4); + } + /** * Basic SLI on a well-known service type. * @@ -78,13 +83,18 @@ public function setBasicSli($var) * Request-based SLIs * * Generated from protobuf field .google.monitoring.v3.RequestBasedSli request_based = 1; - * @return \Google\Cloud\Monitoring\V3\RequestBasedSli + * @return \Google\Cloud\Monitoring\V3\RequestBasedSli|null */ public function getRequestBased() { return $this->readOneof(1); } + public function hasRequestBased() + { + return $this->hasOneof(1); + } + /** * Request-based SLIs * @@ -104,13 +114,18 @@ public function setRequestBased($var) * Windows-based SLIs * * Generated from protobuf field .google.monitoring.v3.WindowsBasedSli windows_based = 2; - * @return \Google\Cloud\Monitoring\V3\WindowsBasedSli + * @return \Google\Cloud\Monitoring\V3\WindowsBasedSli|null */ public function getWindowsBased() { return $this->readOneof(2); } + public function hasWindowsBased() + { + return $this->hasOneof(2); + } + /** * Windows-based SLIs * diff --git a/Monitoring/src/V3/ServiceLevelObjective.php b/Monitoring/src/V3/ServiceLevelObjective.php index bff193c196f..38ca81f6b3a 100644 --- a/Monitoring/src/V3/ServiceLevelObjective.php +++ b/Monitoring/src/V3/ServiceLevelObjective.php @@ -48,6 +48,17 @@ class ServiceLevelObjective extends \Google\Protobuf\Internal\Message * Generated from protobuf field double goal = 4; */ private $goal = 0.0; + /** + * Labels which have been used to annotate the service-level objective. Label + * keys must start with a letter. Label keys and values may contain lowercase + * letters, numbers, underscores, and dashes. Label keys and values have a + * maximum length of 63 characters, and must be less than 128 bytes in size. + * Up to 64 label entries may be stored. For labels which do not have a + * semantic value, the empty string may be supplied for the label value. + * + * Generated from protobuf field map user_labels = 12; + */ + private $user_labels; protected $period; /** @@ -75,6 +86,13 @@ class ServiceLevelObjective extends \Google\Protobuf\Internal\Message * A calendar period, semantically "since the start of the current * ``". At this time, only `DAY`, `WEEK`, `FORTNIGHT`, and * `MONTH` are supported. + * @type array|\Google\Protobuf\Internal\MapField $user_labels + * Labels which have been used to annotate the service-level objective. Label + * keys must start with a letter. Label keys and values may contain lowercase + * letters, numbers, underscores, and dashes. Label keys and values have a + * maximum length of 63 characters, and must be less than 128 bytes in size. + * Up to 64 label entries may be stored. For labels which do not have a + * semantic value, the empty string may be supplied for the label value. * } */ public function __construct($data = NULL) { @@ -142,13 +160,23 @@ public function setDisplayName($var) * quality. * * Generated from protobuf field .google.monitoring.v3.ServiceLevelIndicator service_level_indicator = 3; - * @return \Google\Cloud\Monitoring\V3\ServiceLevelIndicator + * @return \Google\Cloud\Monitoring\V3\ServiceLevelIndicator|null */ public function getServiceLevelIndicator() { return $this->service_level_indicator; } + public function hasServiceLevelIndicator() + { + return isset($this->service_level_indicator); + } + + public function clearServiceLevelIndicator() + { + unset($this->service_level_indicator); + } + /** * The definition of good service, used to measure and calculate the quality * of the `Service`'s performance with respect to a single aspect of service @@ -199,13 +227,18 @@ public function setGoal($var) * Must be an integer multiple of 1 day no larger than 30 days. * * Generated from protobuf field .google.protobuf.Duration rolling_period = 5; - * @return \Google\Protobuf\Duration + * @return \Google\Protobuf\Duration|null */ public function getRollingPeriod() { return $this->readOneof(5); } + public function hasRollingPeriod() + { + return $this->hasOneof(5); + } + /** * A rolling time period, semantically "in the past ``". * Must be an integer multiple of 1 day no larger than 30 days. @@ -235,6 +268,11 @@ public function getCalendarPeriod() return $this->readOneof(6); } + public function hasCalendarPeriod() + { + return $this->hasOneof(6); + } + /** * A calendar period, semantically "since the start of the current * ``". At this time, only `DAY`, `WEEK`, `FORTNIGHT`, and @@ -252,6 +290,42 @@ public function setCalendarPeriod($var) return $this; } + /** + * Labels which have been used to annotate the service-level objective. Label + * keys must start with a letter. Label keys and values may contain lowercase + * letters, numbers, underscores, and dashes. Label keys and values have a + * maximum length of 63 characters, and must be less than 128 bytes in size. + * Up to 64 label entries may be stored. For labels which do not have a + * semantic value, the empty string may be supplied for the label value. + * + * Generated from protobuf field map user_labels = 12; + * @return \Google\Protobuf\Internal\MapField + */ + public function getUserLabels() + { + return $this->user_labels; + } + + /** + * Labels which have been used to annotate the service-level objective. Label + * keys must start with a letter. Label keys and values may contain lowercase + * letters, numbers, underscores, and dashes. Label keys and values have a + * maximum length of 63 characters, and must be less than 128 bytes in size. + * Up to 64 label entries may be stored. For labels which do not have a + * semantic value, the empty string may be supplied for the label value. + * + * Generated from protobuf field map user_labels = 12; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setUserLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->user_labels = $arr; + + return $this; + } + /** * @return string */ diff --git a/Monitoring/src/V3/ServiceMonitoringServiceClient.php b/Monitoring/src/V3/ServiceMonitoringServiceClient.php index 9c32d71f8bd..d4e7b2cbfc2 100644 --- a/Monitoring/src/V3/ServiceMonitoringServiceClient.php +++ b/Monitoring/src/V3/ServiceMonitoringServiceClient.php @@ -17,20 +17,18 @@ /* * GENERATED CODE WARNING - * This file was generated from the file - * https://github.com/google/googleapis/blob/master/google/monitoring/v3/service_service.proto - * and updates to that file get reflected here through a refresh process. + * Generated by gapic-generator-php from the file + * https://github.com/googleapis/googleapis/blob/master/google/monitoring/v3/service_service.proto + * Updates to the above are reflected here through a refresh process. */ namespace Google\Cloud\Monitoring\V3; use Google\Cloud\Monitoring\V3\Gapic\ServiceMonitoringServiceGapicClient; -/** - * {@inheritdoc} - */ +/** {@inheritdoc} */ class ServiceMonitoringServiceClient extends ServiceMonitoringServiceGapicClient { - // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see ServiceMonitoringServiceGapicClient} class. + // This class is intentionally empty, and is intended to hold manual additions to + // the generated {@see ServiceMonitoringServiceGapicClient} class. } diff --git a/Monitoring/src/V3/ServiceMonitoringServiceGrpcClient.php b/Monitoring/src/V3/ServiceMonitoringServiceGrpcClient.php index 282e06f346a..6d3aeb58dd5 100644 --- a/Monitoring/src/V3/ServiceMonitoringServiceGrpcClient.php +++ b/Monitoring/src/V3/ServiceMonitoringServiceGrpcClient.php @@ -40,6 +40,7 @@ public function __construct($hostname, $opts, $channel = null) { * @param \Google\Cloud\Monitoring\V3\CreateServiceRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateService(\Google\Cloud\Monitoring\V3\CreateServiceRequest $argument, $metadata = [], $options = []) { @@ -54,6 +55,7 @@ public function CreateService(\Google\Cloud\Monitoring\V3\CreateServiceRequest $ * @param \Google\Cloud\Monitoring\V3\GetServiceRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetService(\Google\Cloud\Monitoring\V3\GetServiceRequest $argument, $metadata = [], $options = []) { @@ -68,6 +70,7 @@ public function GetService(\Google\Cloud\Monitoring\V3\GetServiceRequest $argume * @param \Google\Cloud\Monitoring\V3\ListServicesRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListServices(\Google\Cloud\Monitoring\V3\ListServicesRequest $argument, $metadata = [], $options = []) { @@ -82,6 +85,7 @@ public function ListServices(\Google\Cloud\Monitoring\V3\ListServicesRequest $ar * @param \Google\Cloud\Monitoring\V3\UpdateServiceRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function UpdateService(\Google\Cloud\Monitoring\V3\UpdateServiceRequest $argument, $metadata = [], $options = []) { @@ -96,6 +100,7 @@ public function UpdateService(\Google\Cloud\Monitoring\V3\UpdateServiceRequest $ * @param \Google\Cloud\Monitoring\V3\DeleteServiceRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteService(\Google\Cloud\Monitoring\V3\DeleteServiceRequest $argument, $metadata = [], $options = []) { @@ -110,6 +115,7 @@ public function DeleteService(\Google\Cloud\Monitoring\V3\DeleteServiceRequest $ * @param \Google\Cloud\Monitoring\V3\CreateServiceLevelObjectiveRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function CreateServiceLevelObjective(\Google\Cloud\Monitoring\V3\CreateServiceLevelObjectiveRequest $argument, $metadata = [], $options = []) { @@ -124,6 +130,7 @@ public function CreateServiceLevelObjective(\Google\Cloud\Monitoring\V3\CreateSe * @param \Google\Cloud\Monitoring\V3\GetServiceLevelObjectiveRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function GetServiceLevelObjective(\Google\Cloud\Monitoring\V3\GetServiceLevelObjectiveRequest $argument, $metadata = [], $options = []) { @@ -138,6 +145,7 @@ public function GetServiceLevelObjective(\Google\Cloud\Monitoring\V3\GetServiceL * @param \Google\Cloud\Monitoring\V3\ListServiceLevelObjectivesRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function ListServiceLevelObjectives(\Google\Cloud\Monitoring\V3\ListServiceLevelObjectivesRequest $argument, $metadata = [], $options = []) { @@ -152,6 +160,7 @@ public function ListServiceLevelObjectives(\Google\Cloud\Monitoring\V3\ListServi * @param \Google\Cloud\Monitoring\V3\UpdateServiceLevelObjectiveRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function UpdateServiceLevelObjective(\Google\Cloud\Monitoring\V3\UpdateServiceLevelObjectiveRequest $argument, $metadata = [], $options = []) { @@ -166,6 +175,7 @@ public function UpdateServiceLevelObjective(\Google\Cloud\Monitoring\V3\UpdateSe * @param \Google\Cloud\Monitoring\V3\DeleteServiceLevelObjectiveRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function DeleteServiceLevelObjective(\Google\Cloud\Monitoring\V3\DeleteServiceLevelObjectiveRequest $argument, $metadata = [], $options = []) { diff --git a/Monitoring/src/V3/Service_IstioCanonicalService.php b/Monitoring/src/V3/Service_IstioCanonicalService.php new file mode 100644 index 00000000000..9fb3870f18a --- /dev/null +++ b/Monitoring/src/V3/Service_IstioCanonicalService.php @@ -0,0 +1,16 @@ +.google.monitoring.v3.TextLocator.Position start_position = 2; - * @return \Google\Cloud\Monitoring\V3\TextLocator\Position + * @return \Google\Cloud\Monitoring\V3\TextLocator\Position|null */ public function getStartPosition() { return $this->start_position; } + public function hasStartPosition() + { + return isset($this->start_position); + } + + public function clearStartPosition() + { + unset($this->start_position); + } + /** * The position of the first byte within the text. * @@ -169,7 +179,7 @@ public function getStartPosition() */ public function setStartPosition($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\TextLocator_Position::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\TextLocator\Position::class); $this->start_position = $var; return $this; @@ -179,13 +189,23 @@ public function setStartPosition($var) * The position of the last byte within the text. * * Generated from protobuf field .google.monitoring.v3.TextLocator.Position end_position = 3; - * @return \Google\Cloud\Monitoring\V3\TextLocator\Position + * @return \Google\Cloud\Monitoring\V3\TextLocator\Position|null */ public function getEndPosition() { return $this->end_position; } + public function hasEndPosition() + { + return isset($this->end_position); + } + + public function clearEndPosition() + { + unset($this->end_position); + } + /** * The position of the last byte within the text. * @@ -195,7 +215,7 @@ public function getEndPosition() */ public function setEndPosition($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\TextLocator_Position::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\TextLocator\Position::class); $this->end_position = $var; return $this; @@ -208,13 +228,23 @@ public function setEndPosition($var) * identifies the location within that object. * * Generated from protobuf field .google.monitoring.v3.TextLocator nested_locator = 4; - * @return \Google\Cloud\Monitoring\V3\TextLocator + * @return \Google\Cloud\Monitoring\V3\TextLocator|null */ public function getNestedLocator() { return $this->nested_locator; } + public function hasNestedLocator() + { + return isset($this->nested_locator); + } + + public function clearNestedLocator() + { + unset($this->nested_locator); + } + /** * If `source`, `start_position`, and `end_position` describe a call on * some object (e.g. a macro in the time series query language text) and a diff --git a/Monitoring/src/V3/TimeInterval.php b/Monitoring/src/V3/TimeInterval.php index 5e80ab990b5..532a64739b0 100644 --- a/Monitoring/src/V3/TimeInterval.php +++ b/Monitoring/src/V3/TimeInterval.php @@ -9,21 +9,30 @@ use Google\Protobuf\Internal\GPBUtil; /** - * A closed time interval. It extends from the start time to the end time, and includes both: `[startTime, endTime]`. Valid time intervals depend on the [`MetricKind`](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors#MetricKind) of the metric value. In no case can the end time be earlier than the start time. - * * For a `GAUGE` metric, the `startTime` value is technically optional; if + * A closed time interval. It extends from the start time to the end time, and includes both: `[startTime, endTime]`. Valid time intervals depend on the [`MetricKind`](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors#MetricKind) of the metric value. The end time must not be earlier than the start time. When writing data points, the start time must not be more than 25 hours in the past and the end time must not be more than five minutes in the future. + * * For `GAUGE` metrics, the `startTime` value is technically optional; if * no value is specified, the start time defaults to the value of the * end time, and the interval represents a single point in time. If both * start and end times are specified, they must be identical. Such an * interval is valid only for `GAUGE` metrics, which are point-in-time - * measurements. - * * For `DELTA` and `CUMULATIVE` metrics, the start time must be earlier - * than the end time. - * * In all cases, the start time of the next interval must be - * at least a millisecond after the end time of the previous interval. - * Because the interval is closed, if the start time of a new interval - * is the same as the end time of the previous interval, data written - * at the new start time could overwrite data written at the previous - * end time. + * measurements. The end time of a new interval must be at least a + * millisecond after the end time of the previous interval. + * * For `DELTA` metrics, the start time and end time must specify a + * non-zero interval, with subsequent points specifying contiguous and + * non-overlapping intervals. For `DELTA` metrics, the start time of + * the next interval must be at least a millisecond after the end time + * of the previous interval. + * * For `CUMULATIVE` metrics, the start time and end time must specify a + * non-zero interval, with subsequent points specifying the same + * start time and increasing end times, until an event resets the + * cumulative value to zero and sets a new start time for the following + * points. The new start time must be at least a millisecond after the + * end time of the previous interval. + * * The start time of a new interval must be at least a millisecond after the + * end time of the previous interval because intervals are closed. If the + * start time of a new interval is the same as the end time of the previous + * interval, then data written at the new start time could overwrite data + * written at the previous end time. * * Generated from protobuf message google.monitoring.v3.TimeInterval */ @@ -67,13 +76,23 @@ public function __construct($data = NULL) { * Required. The end of the time interval. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2; - * @return \Google\Protobuf\Timestamp + * @return \Google\Protobuf\Timestamp|null */ public function getEndTime() { return $this->end_time; } + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + /** * Required. The end of the time interval. * @@ -95,13 +114,23 @@ public function setEndTime($var) * later than the end time. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 1; - * @return \Google\Protobuf\Timestamp + * @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); + } + /** * Optional. The beginning of the time interval. The default value * for the start time is the end time. The start time must not be diff --git a/Monitoring/src/V3/TimeSeries.php b/Monitoring/src/V3/TimeSeries.php index 900fb385557..869bcb7ef92 100644 --- a/Monitoring/src/V3/TimeSeries.php +++ b/Monitoring/src/V3/TimeSeries.php @@ -27,15 +27,17 @@ class TimeSeries extends \Google\Protobuf\Internal\Message private $metric = null; /** * The associated monitored resource. Custom metrics can use only certain - * monitored resource types in their time series data. + * monitored resource types in their time series data. For more information, + * see [Monitored resources for custom + * metrics](https://cloud.google.com/monitoring/custom-metrics/creating-metrics#custom-metric-resources). * * Generated from protobuf field .google.api.MonitoredResource resource = 2; */ private $resource = null; /** * Output only. The associated monitored resource metadata. When reading a - * a timeseries, this field will include metadata labels that are explicitly - * named in the reduction. When creating a timeseries, this field is ignored. + * time series, this field will include metadata labels that are explicitly + * named in the reduction. When creating a time series, this field is ignored. * * Generated from protobuf field .google.api.MonitoredResourceMetadata metadata = 7; */ @@ -75,6 +77,14 @@ class TimeSeries extends \Google\Protobuf\Internal\Message * Generated from protobuf field repeated .google.monitoring.v3.Point points = 5; */ private $points; + /** + * The units in which the metric value is reported. It is only applicable + * if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit` + * defines the representation of the stored metric values. + * + * Generated from protobuf field string unit = 8; + */ + private $unit = ''; /** * Constructor. @@ -87,11 +97,13 @@ class TimeSeries extends \Google\Protobuf\Internal\Message * series. * @type \Google\Api\MonitoredResource $resource * The associated monitored resource. Custom metrics can use only certain - * monitored resource types in their time series data. + * monitored resource types in their time series data. For more information, + * see [Monitored resources for custom + * metrics](https://cloud.google.com/monitoring/custom-metrics/creating-metrics#custom-metric-resources). * @type \Google\Api\MonitoredResourceMetadata $metadata * Output only. The associated monitored resource metadata. When reading a - * a timeseries, this field will include metadata labels that are explicitly - * named in the reduction. When creating a timeseries, this field is ignored. + * time series, this field will include metadata labels that are explicitly + * named in the reduction. When creating a time series, this field is ignored. * @type int $metric_kind * The metric kind of the time series. When listing time series, this metric * kind might be different from the metric kind of the associated metric if @@ -115,6 +127,10 @@ class TimeSeries extends \Google\Protobuf\Internal\Message * metric. If the associated metric's descriptor must be auto-created, then * the value type of the descriptor is determined by the point's type, which * must be `BOOL`, `INT64`, `DOUBLE`, or `DISTRIBUTION`. + * @type string $unit + * The units in which the metric value is reported. It is only applicable + * if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit` + * defines the representation of the stored metric values. * } */ public function __construct($data = NULL) { @@ -127,13 +143,23 @@ public function __construct($data = NULL) { * series. * * Generated from protobuf field .google.api.Metric metric = 1; - * @return \Google\Api\Metric + * @return \Google\Api\Metric|null */ public function getMetric() { return $this->metric; } + public function hasMetric() + { + return isset($this->metric); + } + + public function clearMetric() + { + unset($this->metric); + } + /** * The associated metric. A fully-specified metric used to identify the time * series. @@ -152,19 +178,33 @@ public function setMetric($var) /** * The associated monitored resource. Custom metrics can use only certain - * monitored resource types in their time series data. + * monitored resource types in their time series data. For more information, + * see [Monitored resources for custom + * metrics](https://cloud.google.com/monitoring/custom-metrics/creating-metrics#custom-metric-resources). * * Generated from protobuf field .google.api.MonitoredResource resource = 2; - * @return \Google\Api\MonitoredResource + * @return \Google\Api\MonitoredResource|null */ public function getResource() { return $this->resource; } + public function hasResource() + { + return isset($this->resource); + } + + public function clearResource() + { + unset($this->resource); + } + /** * The associated monitored resource. Custom metrics can use only certain - * monitored resource types in their time series data. + * monitored resource types in their time series data. For more information, + * see [Monitored resources for custom + * metrics](https://cloud.google.com/monitoring/custom-metrics/creating-metrics#custom-metric-resources). * * Generated from protobuf field .google.api.MonitoredResource resource = 2; * @param \Google\Api\MonitoredResource $var @@ -180,21 +220,31 @@ public function setResource($var) /** * Output only. The associated monitored resource metadata. When reading a - * a timeseries, this field will include metadata labels that are explicitly - * named in the reduction. When creating a timeseries, this field is ignored. + * time series, this field will include metadata labels that are explicitly + * named in the reduction. When creating a time series, this field is ignored. * * Generated from protobuf field .google.api.MonitoredResourceMetadata metadata = 7; - * @return \Google\Api\MonitoredResourceMetadata + * @return \Google\Api\MonitoredResourceMetadata|null */ public function getMetadata() { return $this->metadata; } + public function hasMetadata() + { + return isset($this->metadata); + } + + public function clearMetadata() + { + unset($this->metadata); + } + /** * Output only. The associated monitored resource metadata. When reading a - * a timeseries, this field will include metadata labels that are explicitly - * named in the reduction. When creating a timeseries, this field is ignored. + * time series, this field will include metadata labels that are explicitly + * named in the reduction. When creating a time series, this field is ignored. * * Generated from protobuf field .google.api.MonitoredResourceMetadata metadata = 7; * @param \Google\Api\MonitoredResourceMetadata $var @@ -242,7 +292,7 @@ public function getMetricKind() */ public function setMetricKind($var) { - GPBUtil::checkEnum($var, \Google\Api\MetricDescriptor_MetricKind::class); + GPBUtil::checkEnum($var, \Google\Api\MetricDescriptor\MetricKind::class); $this->metric_kind = $var; return $this; @@ -276,7 +326,7 @@ public function getValueType() */ public function setValueType($var) { - GPBUtil::checkEnum($var, \Google\Api\MetricDescriptor_ValueType::class); + GPBUtil::checkEnum($var, \Google\Api\MetricDescriptor\ValueType::class); $this->value_type = $var; return $this; @@ -320,5 +370,35 @@ public function setPoints($var) return $this; } + /** + * The units in which the metric value is reported. It is only applicable + * if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit` + * defines the representation of the stored metric values. + * + * Generated from protobuf field string unit = 8; + * @return string + */ + public function getUnit() + { + return $this->unit; + } + + /** + * The units in which the metric value is reported. It is only applicable + * if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit` + * defines the representation of the stored metric values. + * + * Generated from protobuf field string unit = 8; + * @param string $var + * @return $this + */ + public function setUnit($var) + { + GPBUtil::checkString($var, True); + $this->unit = $var; + + return $this; + } + } diff --git a/Monitoring/src/V3/TimeSeriesData/PointData.php b/Monitoring/src/V3/TimeSeriesData/PointData.php index ff73eb6a9bd..a4406d93644 100644 --- a/Monitoring/src/V3/TimeSeriesData/PointData.php +++ b/Monitoring/src/V3/TimeSeriesData/PointData.php @@ -77,13 +77,23 @@ public function setValues($var) * The time interval associated with the point. * * Generated from protobuf field .google.monitoring.v3.TimeInterval time_interval = 2; - * @return \Google\Cloud\Monitoring\V3\TimeInterval + * @return \Google\Cloud\Monitoring\V3\TimeInterval|null */ public function getTimeInterval() { return $this->time_interval; } + public function hasTimeInterval() + { + return isset($this->time_interval); + } + + public function clearTimeInterval() + { + unset($this->time_interval); + } + /** * The time interval associated with the point. * diff --git a/Monitoring/src/V3/TimeSeriesDescriptor.php b/Monitoring/src/V3/TimeSeriesDescriptor.php index 916e87928eb..6bd08bc8355 100644 --- a/Monitoring/src/V3/TimeSeriesDescriptor.php +++ b/Monitoring/src/V3/TimeSeriesDescriptor.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\GPBUtil; /** - * A descriptor for the labels and points in a timeseries. + * A descriptor for the labels and points in a time series. * * Generated from protobuf message google.monitoring.v3.TimeSeriesDescriptor */ diff --git a/Monitoring/src/V3/TimeSeriesDescriptor/ValueDescriptor.php b/Monitoring/src/V3/TimeSeriesDescriptor/ValueDescriptor.php index 5429f9062e0..a3eff313914 100644 --- a/Monitoring/src/V3/TimeSeriesDescriptor/ValueDescriptor.php +++ b/Monitoring/src/V3/TimeSeriesDescriptor/ValueDescriptor.php @@ -33,6 +33,15 @@ class ValueDescriptor extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.api.MetricDescriptor.MetricKind metric_kind = 3; */ private $metric_kind = 0; + /** + * The unit in which `time_series` point values are reported. `unit` + * follows the UCUM format for units as seen in + * https://unitsofmeasure.org/ucum.html. + * `unit` is only valid if `value_type` is INTEGER, DOUBLE, DISTRIBUTION. + * + * Generated from protobuf field string unit = 4; + */ + private $unit = ''; /** * Constructor. @@ -46,6 +55,11 @@ class ValueDescriptor extends \Google\Protobuf\Internal\Message * The value type. * @type int $metric_kind * The value stream kind. + * @type string $unit + * The unit in which `time_series` point values are reported. `unit` + * follows the UCUM format for units as seen in + * https://unitsofmeasure.org/ucum.html. + * `unit` is only valid if `value_type` is INTEGER, DOUBLE, DISTRIBUTION. * } */ public function __construct($data = NULL) { @@ -99,7 +113,7 @@ public function getValueType() */ public function setValueType($var) { - GPBUtil::checkEnum($var, \Google\Api\MetricDescriptor_ValueType::class); + GPBUtil::checkEnum($var, \Google\Api\MetricDescriptor\ValueType::class); $this->value_type = $var; return $this; @@ -125,12 +139,44 @@ public function getMetricKind() */ public function setMetricKind($var) { - GPBUtil::checkEnum($var, \Google\Api\MetricDescriptor_MetricKind::class); + GPBUtil::checkEnum($var, \Google\Api\MetricDescriptor\MetricKind::class); $this->metric_kind = $var; return $this; } + /** + * The unit in which `time_series` point values are reported. `unit` + * follows the UCUM format for units as seen in + * https://unitsofmeasure.org/ucum.html. + * `unit` is only valid if `value_type` is INTEGER, DOUBLE, DISTRIBUTION. + * + * Generated from protobuf field string unit = 4; + * @return string + */ + public function getUnit() + { + return $this->unit; + } + + /** + * The unit in which `time_series` point values are reported. `unit` + * follows the UCUM format for units as seen in + * https://unitsofmeasure.org/ucum.html. + * `unit` is only valid if `value_type` is INTEGER, DOUBLE, DISTRIBUTION. + * + * Generated from protobuf field string unit = 4; + * @param string $var + * @return $this + */ + public function setUnit($var) + { + GPBUtil::checkString($var, True); + $this->unit = $var; + + return $this; + } + } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/Monitoring/src/V3/TypedValue.php b/Monitoring/src/V3/TypedValue.php index 17be9bcbf77..866bd8da016 100644 --- a/Monitoring/src/V3/TypedValue.php +++ b/Monitoring/src/V3/TypedValue.php @@ -53,6 +53,11 @@ public function getBoolValue() return $this->readOneof(1); } + public function hasBoolValue() + { + return $this->hasOneof(1); + } + /** * A Boolean value: `true` or `false`. * @@ -79,6 +84,11 @@ public function getInt64Value() return $this->readOneof(2); } + public function hasInt64Value() + { + return $this->hasOneof(2); + } + /** * A 64-bit integer. Its range is approximately ±9.2x1018. * @@ -107,6 +117,11 @@ public function getDoubleValue() return $this->readOneof(3); } + public function hasDoubleValue() + { + return $this->hasOneof(3); + } + /** * A 64-bit double-precision floating-point number. Its magnitude * is approximately ±10±300 and it has 16 @@ -135,6 +150,11 @@ public function getStringValue() return $this->readOneof(4); } + public function hasStringValue() + { + return $this->hasOneof(4); + } + /** * A variable-length string value. * @@ -154,13 +174,18 @@ public function setStringValue($var) * A distribution value. * * Generated from protobuf field .google.api.Distribution distribution_value = 5; - * @return \Google\Api\Distribution + * @return \Google\Api\Distribution|null */ public function getDistributionValue() { return $this->readOneof(5); } + public function hasDistributionValue() + { + return $this->hasOneof(5); + } + /** * A distribution value. * diff --git a/Monitoring/src/V3/UpdateAlertPolicyRequest.php b/Monitoring/src/V3/UpdateAlertPolicyRequest.php index fa0dde31f88..f57aefb4402 100644 --- a/Monitoring/src/V3/UpdateAlertPolicyRequest.php +++ b/Monitoring/src/V3/UpdateAlertPolicyRequest.php @@ -106,13 +106,23 @@ public function __construct($data = NULL) { * then a new `[CONDITION_ID]` is created. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; - * @return \Google\Protobuf\FieldMask + * @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); + } + /** * Optional. A list of alerting policy field names. If this field is not * empty, each listed field in the existing alerting policy is set to the @@ -152,13 +162,23 @@ public function setUpdateMask($var) * not in `update_mask` are ignored. * * Generated from protobuf field .google.monitoring.v3.AlertPolicy alert_policy = 3 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\AlertPolicy + * @return \Google\Cloud\Monitoring\V3\AlertPolicy|null */ public function getAlertPolicy() { return $this->alert_policy; } + public function hasAlertPolicy() + { + return isset($this->alert_policy); + } + + public function clearAlertPolicy() + { + unset($this->alert_policy); + } + /** * Required. The updated alerting policy or the updated values for the * fields listed in `update_mask`. diff --git a/Monitoring/src/V3/UpdateGroupRequest.php b/Monitoring/src/V3/UpdateGroupRequest.php index 538b82b3695..3ae1729c8f1 100644 --- a/Monitoring/src/V3/UpdateGroupRequest.php +++ b/Monitoring/src/V3/UpdateGroupRequest.php @@ -52,13 +52,23 @@ public function __construct($data = NULL) { * excepting `name`, are replaced with the corresponding fields of this group. * * Generated from protobuf field .google.monitoring.v3.Group group = 2 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\Group + * @return \Google\Cloud\Monitoring\V3\Group|null */ public function getGroup() { return $this->group; } + public function hasGroup() + { + return isset($this->group); + } + + public function clearGroup() + { + unset($this->group); + } + /** * Required. The new definition of the group. All fields of the existing group, * excepting `name`, are replaced with the corresponding fields of this group. diff --git a/Monitoring/src/V3/UpdateNotificationChannelRequest.php b/Monitoring/src/V3/UpdateNotificationChannelRequest.php index 1a85f2ad172..2e2dc8fe082 100644 --- a/Monitoring/src/V3/UpdateNotificationChannelRequest.php +++ b/Monitoring/src/V3/UpdateNotificationChannelRequest.php @@ -55,13 +55,23 @@ public function __construct($data = NULL) { * The fields to update. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; - * @return \Google\Protobuf\FieldMask + * @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); + } + /** * The fields to update. * @@ -84,13 +94,23 @@ public function setUpdateMask($var) * included in the `update_mask`. * * Generated from protobuf field .google.monitoring.v3.NotificationChannel notification_channel = 3 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\NotificationChannel + * @return \Google\Cloud\Monitoring\V3\NotificationChannel|null */ public function getNotificationChannel() { return $this->notification_channel; } + public function hasNotificationChannel() + { + return isset($this->notification_channel); + } + + public function clearNotificationChannel() + { + unset($this->notification_channel); + } + /** * Required. A description of the changes to be applied to the specified * notification channel. The description must provide a definition for diff --git a/Monitoring/src/V3/UpdateServiceLevelObjectiveRequest.php b/Monitoring/src/V3/UpdateServiceLevelObjectiveRequest.php index 3bf99609c2c..dd37432b2e2 100644 --- a/Monitoring/src/V3/UpdateServiceLevelObjectiveRequest.php +++ b/Monitoring/src/V3/UpdateServiceLevelObjectiveRequest.php @@ -52,13 +52,23 @@ public function __construct($data = NULL) { * The given `name` specifies the resource to update. * * Generated from protobuf field .google.monitoring.v3.ServiceLevelObjective service_level_objective = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\ServiceLevelObjective + * @return \Google\Cloud\Monitoring\V3\ServiceLevelObjective|null */ public function getServiceLevelObjective() { return $this->service_level_objective; } + public function hasServiceLevelObjective() + { + return isset($this->service_level_objective); + } + + public function clearServiceLevelObjective() + { + unset($this->service_level_objective); + } + /** * Required. The `ServiceLevelObjective` to draw updates from. * The given `name` specifies the resource to update. @@ -79,13 +89,23 @@ public function setServiceLevelObjective($var) * A set of field paths defining which fields to use for the update. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; - * @return \Google\Protobuf\FieldMask + * @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); + } + /** * A set of field paths defining which fields to use for the update. * diff --git a/Monitoring/src/V3/UpdateServiceRequest.php b/Monitoring/src/V3/UpdateServiceRequest.php index c2df403a3fa..a577427e2fa 100644 --- a/Monitoring/src/V3/UpdateServiceRequest.php +++ b/Monitoring/src/V3/UpdateServiceRequest.php @@ -52,13 +52,23 @@ public function __construct($data = NULL) { * The given `name` specifies the resource to update. * * Generated from protobuf field .google.monitoring.v3.Service service = 1 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\Service + * @return \Google\Cloud\Monitoring\V3\Service|null */ public function getService() { return $this->service; } + public function hasService() + { + return isset($this->service); + } + + public function clearService() + { + unset($this->service); + } + /** * Required. The `Service` to draw updates from. * The given `name` specifies the resource to update. @@ -79,13 +89,23 @@ public function setService($var) * A set of field paths defining which fields to use for the update. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; - * @return \Google\Protobuf\FieldMask + * @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); + } + /** * A set of field paths defining which fields to use for the update. * diff --git a/Monitoring/src/V3/UpdateUptimeCheckConfigRequest.php b/Monitoring/src/V3/UpdateUptimeCheckConfigRequest.php index 3333b41bb00..7128d96eb50 100644 --- a/Monitoring/src/V3/UpdateUptimeCheckConfigRequest.php +++ b/Monitoring/src/V3/UpdateUptimeCheckConfigRequest.php @@ -76,13 +76,23 @@ public function __construct($data = NULL) { * the new configuration. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; - * @return \Google\Protobuf\FieldMask + * @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); + } + /** * Optional. If present, only the listed fields in the current Uptime check * configuration are updated with values from the new configuration. If this @@ -114,13 +124,23 @@ public function setUpdateMask($var) * `selected_regions`. * * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig uptime_check_config = 3 [(.google.api.field_behavior) = REQUIRED]; - * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig|null */ public function getUptimeCheckConfig() { return $this->uptime_check_config; } + public function hasUptimeCheckConfig() + { + return isset($this->uptime_check_config); + } + + public function clearUptimeCheckConfig() + { + unset($this->uptime_check_config); + } + /** * Required. If an `updateMask` has been specified, this field gives * the values for the set of fields mentioned in the `updateMask`. If an diff --git a/Monitoring/src/V3/UptimeCheckConfig.php b/Monitoring/src/V3/UptimeCheckConfig.php index f05685ab407..f797836ddab 100644 --- a/Monitoring/src/V3/UptimeCheckConfig.php +++ b/Monitoring/src/V3/UptimeCheckConfig.php @@ -19,6 +19,8 @@ class UptimeCheckConfig extends \Google\Protobuf\Internal\Message /** * A unique resource name for this Uptime check configuration. The format is: * projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] + * `[PROJECT_ID_OR_NUMBER]` is the Workspace host project associated with the + * Uptime check. * This field should be omitted when creating the Uptime check configuration; * on create, the resource name is assigned by the server and included in the * response. @@ -77,8 +79,9 @@ class UptimeCheckConfig extends \Google\Protobuf\Internal\Message * or to provide 'internal_checkers' when is_internal is `false`. * * Generated from protobuf field bool is_internal = 15 [deprecated = true]; + * @deprecated */ - private $is_internal = false; + protected $is_internal = false; /** * The internal checkers that this check will egress from. If `is_internal` is * `true` and this list is empty, the check will egress from all the @@ -86,6 +89,7 @@ class UptimeCheckConfig extends \Google\Protobuf\Internal\Message * `UptimeCheckConfig`. * * Generated from protobuf field repeated .google.monitoring.v3.InternalChecker internal_checkers = 14 [deprecated = true]; + * @deprecated */ private $internal_checkers; protected $resource; @@ -100,6 +104,8 @@ class UptimeCheckConfig extends \Google\Protobuf\Internal\Message * @type string $name * A unique resource name for this Uptime check configuration. The format is: * projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] + * `[PROJECT_ID_OR_NUMBER]` is the Workspace host project associated with the + * Uptime check. * This field should be omitted when creating the Uptime check configuration; * on create, the resource name is assigned by the server and included in the * response. @@ -111,12 +117,13 @@ class UptimeCheckConfig extends \Google\Protobuf\Internal\Message * The [monitored * resource](https://cloud.google.com/monitoring/api/resources) associated * with the configuration. - * The following monitored resource types are supported for Uptime checks: + * The following monitored resource types are valid for this field: * `uptime_url`, * `gce_instance`, * `gae_app`, * `aws_ec2_instance`, * `aws_elb_load_balancer` + * `k8s_service` * @type \Google\Cloud\Monitoring\V3\UptimeCheckConfig\ResourceGroup $resource_group * The group resource associated with the configuration. * @type \Google\Cloud\Monitoring\V3\UptimeCheckConfig\HttpCheck $http_check @@ -163,6 +170,8 @@ public function __construct($data = NULL) { /** * A unique resource name for this Uptime check configuration. The format is: * projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] + * `[PROJECT_ID_OR_NUMBER]` is the Workspace host project associated with the + * Uptime check. * This field should be omitted when creating the Uptime check configuration; * on create, the resource name is assigned by the server and included in the * response. @@ -178,6 +187,8 @@ public function getName() /** * A unique resource name for this Uptime check configuration. The format is: * projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] + * `[PROJECT_ID_OR_NUMBER]` is the Workspace host project associated with the + * Uptime check. * This field should be omitted when creating the Uptime check configuration; * on create, the resource name is assigned by the server and included in the * response. @@ -228,31 +239,38 @@ public function setDisplayName($var) * The [monitored * resource](https://cloud.google.com/monitoring/api/resources) associated * with the configuration. - * The following monitored resource types are supported for Uptime checks: + * The following monitored resource types are valid for this field: * `uptime_url`, * `gce_instance`, * `gae_app`, * `aws_ec2_instance`, * `aws_elb_load_balancer` + * `k8s_service` * * Generated from protobuf field .google.api.MonitoredResource monitored_resource = 3; - * @return \Google\Api\MonitoredResource + * @return \Google\Api\MonitoredResource|null */ public function getMonitoredResource() { return $this->readOneof(3); } + public function hasMonitoredResource() + { + return $this->hasOneof(3); + } + /** * The [monitored * resource](https://cloud.google.com/monitoring/api/resources) associated * with the configuration. - * The following monitored resource types are supported for Uptime checks: + * The following monitored resource types are valid for this field: * `uptime_url`, * `gce_instance`, * `gae_app`, * `aws_ec2_instance`, * `aws_elb_load_balancer` + * `k8s_service` * * Generated from protobuf field .google.api.MonitoredResource monitored_resource = 3; * @param \Google\Api\MonitoredResource $var @@ -270,13 +288,18 @@ public function setMonitoredResource($var) * The group resource associated with the configuration. * * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.ResourceGroup resource_group = 4; - * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig\ResourceGroup + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig\ResourceGroup|null */ public function getResourceGroup() { return $this->readOneof(4); } + public function hasResourceGroup() + { + return $this->hasOneof(4); + } + /** * The group resource associated with the configuration. * @@ -286,7 +309,7 @@ public function getResourceGroup() */ public function setResourceGroup($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_ResourceGroup::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig\ResourceGroup::class); $this->writeOneof(4, $var); return $this; @@ -296,13 +319,18 @@ public function setResourceGroup($var) * Contains information needed to make an HTTP or HTTPS check. * * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.HttpCheck http_check = 5; - * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig\HttpCheck + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig\HttpCheck|null */ public function getHttpCheck() { return $this->readOneof(5); } + public function hasHttpCheck() + { + return $this->hasOneof(5); + } + /** * Contains information needed to make an HTTP or HTTPS check. * @@ -312,7 +340,7 @@ public function getHttpCheck() */ public function setHttpCheck($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_HttpCheck::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig\HttpCheck::class); $this->writeOneof(5, $var); return $this; @@ -322,13 +350,18 @@ public function setHttpCheck($var) * Contains information needed to make a TCP check. * * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.TcpCheck tcp_check = 6; - * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig\TcpCheck + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig\TcpCheck|null */ public function getTcpCheck() { return $this->readOneof(6); } + public function hasTcpCheck() + { + return $this->hasOneof(6); + } + /** * Contains information needed to make a TCP check. * @@ -338,7 +371,7 @@ public function getTcpCheck() */ public function setTcpCheck($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_TcpCheck::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig\TcpCheck::class); $this->writeOneof(6, $var); return $this; @@ -351,13 +384,23 @@ public function setTcpCheck($var) * defaults to `60s`. * * Generated from protobuf field .google.protobuf.Duration period = 7; - * @return \Google\Protobuf\Duration + * @return \Google\Protobuf\Duration|null */ public function getPeriod() { return $this->period; } + public function hasPeriod() + { + return isset($this->period); + } + + public function clearPeriod() + { + unset($this->period); + } + /** * How often, in seconds, the Uptime check is performed. * Currently, the only supported values are `60s` (1 minute), `300s` @@ -381,13 +424,23 @@ public function setPeriod($var) * between 1 and 60 seconds). Required. * * Generated from protobuf field .google.protobuf.Duration timeout = 8; - * @return \Google\Protobuf\Duration + * @return \Google\Protobuf\Duration|null */ public function getTimeout() { return $this->timeout; } + public function hasTimeout() + { + return isset($this->timeout); + } + + public function clearTimeout() + { + unset($this->timeout); + } + /** * The maximum amount of time to wait for the request to complete (must be * between 1 and 60 seconds). Required. @@ -480,9 +533,11 @@ public function setSelectedRegions($var) * * Generated from protobuf field bool is_internal = 15 [deprecated = true]; * @return bool + * @deprecated */ public function getIsInternal() { + @trigger_error('is_internal is deprecated.', E_USER_DEPRECATED); return $this->is_internal; } @@ -495,9 +550,11 @@ public function getIsInternal() * Generated from protobuf field bool is_internal = 15 [deprecated = true]; * @param bool $var * @return $this + * @deprecated */ public function setIsInternal($var) { + @trigger_error('is_internal is deprecated.', E_USER_DEPRECATED); GPBUtil::checkBool($var); $this->is_internal = $var; @@ -512,9 +569,11 @@ public function setIsInternal($var) * * Generated from protobuf field repeated .google.monitoring.v3.InternalChecker internal_checkers = 14 [deprecated = true]; * @return \Google\Protobuf\Internal\RepeatedField + * @deprecated */ public function getInternalCheckers() { + @trigger_error('internal_checkers is deprecated.', E_USER_DEPRECATED); return $this->internal_checkers; } @@ -527,9 +586,11 @@ public function getInternalCheckers() * Generated from protobuf field repeated .google.monitoring.v3.InternalChecker internal_checkers = 14 [deprecated = true]; * @param \Google\Cloud\Monitoring\V3\InternalChecker[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this + * @deprecated */ public function setInternalCheckers($var) { + @trigger_error('internal_checkers is deprecated.', E_USER_DEPRECATED); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Monitoring\V3\InternalChecker::class); $this->internal_checkers = $arr; diff --git a/Monitoring/src/V3/UptimeCheckConfig/ContentMatcher.php b/Monitoring/src/V3/UptimeCheckConfig/ContentMatcher.php index ce3bfdb7c0f..70d67f1e0a9 100644 --- a/Monitoring/src/V3/UptimeCheckConfig/ContentMatcher.php +++ b/Monitoring/src/V3/UptimeCheckConfig/ContentMatcher.php @@ -103,7 +103,7 @@ public function getMatcher() */ public function setMatcher($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_ContentMatcher_ContentMatcherOption::class); + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig\ContentMatcher\ContentMatcherOption::class); $this->matcher = $var; return $this; diff --git a/Monitoring/src/V3/UptimeCheckConfig/ContentMatcher/ContentMatcherOption.php b/Monitoring/src/V3/UptimeCheckConfig/ContentMatcher/ContentMatcherOption.php index 42873757d09..b2d900726d2 100644 --- a/Monitoring/src/V3/UptimeCheckConfig/ContentMatcher/ContentMatcherOption.php +++ b/Monitoring/src/V3/UptimeCheckConfig/ContentMatcher/ContentMatcherOption.php @@ -40,6 +40,7 @@ class ContentMatcherOption /** * Selects regular-expression matching. The match succeeds of the output * matches the regular expression specified in the `content` string. + * Regex matching is only supported for HTTP/HTTPS checks. * * Generated from protobuf enum MATCHES_REGEX = 3; */ @@ -47,7 +48,8 @@ class ContentMatcherOption /** * Selects negation of regular-expression matching. The match succeeds if * the output does _NOT_ match the regular expression specified in the - * `content` string. + * `content` string. Regex matching is only supported for HTTP/HTTPS + * checks. * * Generated from protobuf enum NOT_MATCHES_REGEX = 4; */ diff --git a/Monitoring/src/V3/UptimeCheckConfig/HttpCheck.php b/Monitoring/src/V3/UptimeCheckConfig/HttpCheck.php index 30387e19007..41a1e56fac2 100644 --- a/Monitoring/src/V3/UptimeCheckConfig/HttpCheck.php +++ b/Monitoring/src/V3/UptimeCheckConfig/HttpCheck.php @@ -15,6 +15,13 @@ */ class HttpCheck extends \Google\Protobuf\Internal\Message { + /** + * The HTTP request method to use for the check. If set to + * `METHOD_UNSPECIFIED` then `request_method` defaults to `GET`. + * + * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.HttpCheck.RequestMethod request_method = 8; + */ + private $request_method = 0; /** * If `true`, use HTTPS instead of HTTP to run the check. * @@ -48,7 +55,7 @@ class HttpCheck extends \Google\Protobuf\Internal\Message */ private $auth_info = null; /** - * Boolean specifiying whether to encrypt the header information. + * Boolean specifying whether to encrypt the header information. * Encryption should be specified for any headers related to authentication * that you do not wish to be seen when retrieving the configuration. The * server will be responsible for encrypting the headers. @@ -71,6 +78,19 @@ class HttpCheck extends \Google\Protobuf\Internal\Message * Generated from protobuf field map headers = 6; */ private $headers; + /** + * The content type header to use for the check. The following + * configurations result in errors: + * 1. Content type is specified in both the `headers` field and the + * `content_type` field. + * 2. Request method is `GET` and `content_type` is not `TYPE_UNSPECIFIED` + * 3. Request method is `POST` and `content_type` is `TYPE_UNSPECIFIED`. + * 4. Request method is `POST` and a "Content-Type" header is provided via + * `headers` field. The `content_type` field should be used instead. + * + * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.HttpCheck.ContentType content_type = 9; + */ + private $content_type = 0; /** * Boolean specifying whether to include SSL certificate validation as a * part of the Uptime check. Only applies to checks where @@ -80,6 +100,19 @@ class HttpCheck extends \Google\Protobuf\Internal\Message * Generated from protobuf field bool validate_ssl = 7; */ private $validate_ssl = false; + /** + * The request body associated with the HTTP POST request. If `content_type` + * is `URL_ENCODED`, the body passed in must be URL-encoded. Users can + * provide a `Content-Length` header via the `headers` field or the API will + * do so. If the `request_method` is `GET` and `body` is not empty, the API + * will return an error. The maximum byte size is 1 megabyte. Note: As with + * all `bytes` fields, JSON representations are base64 encoded. e.g.: + * "foo=bar" in URL-encoded form is "foo%3Dbar" and in base64 encoding is + * "Zm9vJTI1M0RiYXI=". + * + * Generated from protobuf field bytes body = 10; + */ + private $body = ''; /** * Constructor. @@ -87,6 +120,9 @@ class HttpCheck extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * + * @type int $request_method + * The HTTP request method to use for the check. If set to + * `METHOD_UNSPECIFIED` then `request_method` defaults to `GET`. * @type bool $use_ssl * If `true`, use HTTPS instead of HTTP to run the check. * @type string $path @@ -104,7 +140,7 @@ class HttpCheck extends \Google\Protobuf\Internal\Message * The authentication information. Optional when creating an HTTP check; * defaults to empty. * @type bool $mask_headers - * Boolean specifiying whether to encrypt the header information. + * Boolean specifying whether to encrypt the header information. * Encryption should be specified for any headers related to authentication * that you do not wish to be seen when retrieving the configuration. The * server will be responsible for encrypting the headers. @@ -119,11 +155,29 @@ class HttpCheck extends \Google\Protobuf\Internal\Message * Entering two separate headers with the same key in a Create call will * cause the first to be overwritten by the second. * The maximum number of headers allowed is 100. + * @type int $content_type + * The content type header to use for the check. The following + * configurations result in errors: + * 1. Content type is specified in both the `headers` field and the + * `content_type` field. + * 2. Request method is `GET` and `content_type` is not `TYPE_UNSPECIFIED` + * 3. Request method is `POST` and `content_type` is `TYPE_UNSPECIFIED`. + * 4. Request method is `POST` and a "Content-Type" header is provided via + * `headers` field. The `content_type` field should be used instead. * @type bool $validate_ssl * Boolean specifying whether to include SSL certificate validation as a * part of the Uptime check. Only applies to checks where * `monitored_resource` is set to `uptime_url`. If `use_ssl` is `false`, * setting `validate_ssl` to `true` has no effect. + * @type string $body + * The request body associated with the HTTP POST request. If `content_type` + * is `URL_ENCODED`, the body passed in must be URL-encoded. Users can + * provide a `Content-Length` header via the `headers` field or the API will + * do so. If the `request_method` is `GET` and `body` is not empty, the API + * will return an error. The maximum byte size is 1 megabyte. Note: As with + * all `bytes` fields, JSON representations are base64 encoded. e.g.: + * "foo=bar" in URL-encoded form is "foo%3Dbar" and in base64 encoding is + * "Zm9vJTI1M0RiYXI=". * } */ public function __construct($data = NULL) { @@ -131,6 +185,34 @@ public function __construct($data = NULL) { parent::__construct($data); } + /** + * The HTTP request method to use for the check. If set to + * `METHOD_UNSPECIFIED` then `request_method` defaults to `GET`. + * + * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.HttpCheck.RequestMethod request_method = 8; + * @return int + */ + public function getRequestMethod() + { + return $this->request_method; + } + + /** + * The HTTP request method to use for the check. If set to + * `METHOD_UNSPECIFIED` then `request_method` defaults to `GET`. + * + * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.HttpCheck.RequestMethod request_method = 8; + * @param int $var + * @return $this + */ + public function setRequestMethod($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig\HttpCheck\RequestMethod::class); + $this->request_method = $var; + + return $this; + } + /** * If `true`, use HTTPS instead of HTTP to run the check. * @@ -228,13 +310,23 @@ public function setPort($var) * defaults to empty. * * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.HttpCheck.BasicAuthentication auth_info = 4; - * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig\HttpCheck\BasicAuthentication + * @return \Google\Cloud\Monitoring\V3\UptimeCheckConfig\HttpCheck\BasicAuthentication|null */ public function getAuthInfo() { return $this->auth_info; } + public function hasAuthInfo() + { + return isset($this->auth_info); + } + + public function clearAuthInfo() + { + unset($this->auth_info); + } + /** * The authentication information. Optional when creating an HTTP check; * defaults to empty. @@ -245,14 +337,14 @@ public function getAuthInfo() */ public function setAuthInfo($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_HttpCheck_BasicAuthentication::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig\HttpCheck\BasicAuthentication::class); $this->auth_info = $var; return $this; } /** - * Boolean specifiying whether to encrypt the header information. + * Boolean specifying whether to encrypt the header information. * Encryption should be specified for any headers related to authentication * that you do not wish to be seen when retrieving the configuration. The * server will be responsible for encrypting the headers. @@ -268,7 +360,7 @@ public function getMaskHeaders() } /** - * Boolean specifiying whether to encrypt the header information. + * Boolean specifying whether to encrypt the header information. * Encryption should be specified for any headers related to authentication * that you do not wish to be seen when retrieving the configuration. The * server will be responsible for encrypting the headers. @@ -327,6 +419,46 @@ public function setHeaders($var) return $this; } + /** + * The content type header to use for the check. The following + * configurations result in errors: + * 1. Content type is specified in both the `headers` field and the + * `content_type` field. + * 2. Request method is `GET` and `content_type` is not `TYPE_UNSPECIFIED` + * 3. Request method is `POST` and `content_type` is `TYPE_UNSPECIFIED`. + * 4. Request method is `POST` and a "Content-Type" header is provided via + * `headers` field. The `content_type` field should be used instead. + * + * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.HttpCheck.ContentType content_type = 9; + * @return int + */ + public function getContentType() + { + return $this->content_type; + } + + /** + * The content type header to use for the check. The following + * configurations result in errors: + * 1. Content type is specified in both the `headers` field and the + * `content_type` field. + * 2. Request method is `GET` and `content_type` is not `TYPE_UNSPECIFIED` + * 3. Request method is `POST` and `content_type` is `TYPE_UNSPECIFIED`. + * 4. Request method is `POST` and a "Content-Type" header is provided via + * `headers` field. The `content_type` field should be used instead. + * + * Generated from protobuf field .google.monitoring.v3.UptimeCheckConfig.HttpCheck.ContentType content_type = 9; + * @param int $var + * @return $this + */ + public function setContentType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Monitoring\V3\UptimeCheckConfig\HttpCheck\ContentType::class); + $this->content_type = $var; + + return $this; + } + /** * Boolean specifying whether to include SSL certificate validation as a * part of the Uptime check. Only applies to checks where @@ -359,6 +491,46 @@ public function setValidateSsl($var) return $this; } + /** + * The request body associated with the HTTP POST request. If `content_type` + * is `URL_ENCODED`, the body passed in must be URL-encoded. Users can + * provide a `Content-Length` header via the `headers` field or the API will + * do so. If the `request_method` is `GET` and `body` is not empty, the API + * will return an error. The maximum byte size is 1 megabyte. Note: As with + * all `bytes` fields, JSON representations are base64 encoded. e.g.: + * "foo=bar" in URL-encoded form is "foo%3Dbar" and in base64 encoding is + * "Zm9vJTI1M0RiYXI=". + * + * Generated from protobuf field bytes body = 10; + * @return string + */ + public function getBody() + { + return $this->body; + } + + /** + * The request body associated with the HTTP POST request. If `content_type` + * is `URL_ENCODED`, the body passed in must be URL-encoded. Users can + * provide a `Content-Length` header via the `headers` field or the API will + * do so. If the `request_method` is `GET` and `body` is not empty, the API + * will return an error. The maximum byte size is 1 megabyte. Note: As with + * all `bytes` fields, JSON representations are base64 encoded. e.g.: + * "foo=bar" in URL-encoded form is "foo%3Dbar" and in base64 encoding is + * "Zm9vJTI1M0RiYXI=". + * + * Generated from protobuf field bytes body = 10; + * @param string $var + * @return $this + */ + public function setBody($var) + { + GPBUtil::checkString($var, False); + $this->body = $var; + + return $this; + } + } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/Monitoring/src/V3/UptimeCheckConfig/HttpCheck/ContentType.php b/Monitoring/src/V3/UptimeCheckConfig/HttpCheck/ContentType.php new file mode 100644 index 00000000000..8e06ad7b38b --- /dev/null +++ b/Monitoring/src/V3/UptimeCheckConfig/HttpCheck/ContentType.php @@ -0,0 +1,58 @@ +google.monitoring.v3.UptimeCheckConfig.HttpCheck.ContentType + */ +class ContentType +{ + /** + * No content type specified. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * `body` is in URL-encoded form. Equivalent to setting the `Content-Type` + * to `application/x-www-form-urlencoded` in the HTTP request. + * + * Generated from protobuf enum URL_ENCODED = 1; + */ + const URL_ENCODED = 1; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::URL_ENCODED => 'URL_ENCODED', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ContentType::class, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_HttpCheck_ContentType::class); + diff --git a/Monitoring/src/V3/UptimeCheckConfig/HttpCheck/RequestMethod.php b/Monitoring/src/V3/UptimeCheckConfig/HttpCheck/RequestMethod.php new file mode 100644 index 00000000000..981e2cbc372 --- /dev/null +++ b/Monitoring/src/V3/UptimeCheckConfig/HttpCheck/RequestMethod.php @@ -0,0 +1,64 @@ +google.monitoring.v3.UptimeCheckConfig.HttpCheck.RequestMethod + */ +class RequestMethod +{ + /** + * No request method specified. + * + * Generated from protobuf enum METHOD_UNSPECIFIED = 0; + */ + const METHOD_UNSPECIFIED = 0; + /** + * GET request. + * + * Generated from protobuf enum GET = 1; + */ + const GET = 1; + /** + * POST request. + * + * Generated from protobuf enum POST = 2; + */ + const POST = 2; + + private static $valueToName = [ + self::METHOD_UNSPECIFIED => 'METHOD_UNSPECIFIED', + self::GET => 'GET', + self::POST => 'POST', + ]; + + 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); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(RequestMethod::class, \Google\Cloud\Monitoring\V3\UptimeCheckConfig_HttpCheck_RequestMethod::class); + diff --git a/Monitoring/src/V3/UptimeCheckConfig_HttpCheck_ContentType.php b/Monitoring/src/V3/UptimeCheckConfig_HttpCheck_ContentType.php new file mode 100644 index 00000000000..f3453c3058b --- /dev/null +++ b/Monitoring/src/V3/UptimeCheckConfig_HttpCheck_ContentType.php @@ -0,0 +1,16 @@ +readOneof(5); } + public function hasGoodBadMetricFilter() + { + return $this->hasOneof(5); + } + /** * A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) * specifying a `TimeSeries` with `ValueType = BOOL`. The window is good if @@ -88,13 +93,18 @@ public function setGoodBadMetricFilter($var) * A window is good if its `performance` is high enough. * * Generated from protobuf field .google.monitoring.v3.WindowsBasedSli.PerformanceThreshold good_total_ratio_threshold = 2; - * @return \Google\Cloud\Monitoring\V3\WindowsBasedSli\PerformanceThreshold + * @return \Google\Cloud\Monitoring\V3\WindowsBasedSli\PerformanceThreshold|null */ public function getGoodTotalRatioThreshold() { return $this->readOneof(2); } + public function hasGoodTotalRatioThreshold() + { + return $this->hasOneof(2); + } + /** * A window is good if its `performance` is high enough. * @@ -104,7 +114,7 @@ public function getGoodTotalRatioThreshold() */ public function setGoodTotalRatioThreshold($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\WindowsBasedSli_PerformanceThreshold::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\WindowsBasedSli\PerformanceThreshold::class); $this->writeOneof(2, $var); return $this; @@ -115,13 +125,18 @@ public function setGoodTotalRatioThreshold($var) * across returned streams. * * Generated from protobuf field .google.monitoring.v3.WindowsBasedSli.MetricRange metric_mean_in_range = 6; - * @return \Google\Cloud\Monitoring\V3\WindowsBasedSli\MetricRange + * @return \Google\Cloud\Monitoring\V3\WindowsBasedSli\MetricRange|null */ public function getMetricMeanInRange() { return $this->readOneof(6); } + public function hasMetricMeanInRange() + { + return $this->hasOneof(6); + } + /** * A window is good if the metric's value is in a good range, averaged * across returned streams. @@ -132,7 +147,7 @@ public function getMetricMeanInRange() */ public function setMetricMeanInRange($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\WindowsBasedSli_MetricRange::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\WindowsBasedSli\MetricRange::class); $this->writeOneof(6, $var); return $this; @@ -143,13 +158,18 @@ public function setMetricMeanInRange($var) * returned streams. * * Generated from protobuf field .google.monitoring.v3.WindowsBasedSli.MetricRange metric_sum_in_range = 7; - * @return \Google\Cloud\Monitoring\V3\WindowsBasedSli\MetricRange + * @return \Google\Cloud\Monitoring\V3\WindowsBasedSli\MetricRange|null */ public function getMetricSumInRange() { return $this->readOneof(7); } + public function hasMetricSumInRange() + { + return $this->hasOneof(7); + } + /** * A window is good if the metric's value is in a good range, summed across * returned streams. @@ -160,7 +180,7 @@ public function getMetricSumInRange() */ public function setMetricSumInRange($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\WindowsBasedSli_MetricRange::class); + GPBUtil::checkMessage($var, \Google\Cloud\Monitoring\V3\WindowsBasedSli\MetricRange::class); $this->writeOneof(7, $var); return $this; @@ -171,13 +191,23 @@ public function setMetricSumInRange($var) * fraction of a day and at least `60s`. * * Generated from protobuf field .google.protobuf.Duration window_period = 4; - * @return \Google\Protobuf\Duration + * @return \Google\Protobuf\Duration|null */ public function getWindowPeriod() { return $this->window_period; } + public function hasWindowPeriod() + { + return isset($this->window_period); + } + + public function clearWindowPeriod() + { + unset($this->window_period); + } + /** * Duration over which window quality is evaluated. Must be an integer * fraction of a day and at least `60s`. diff --git a/Monitoring/src/V3/WindowsBasedSli/MetricRange.php b/Monitoring/src/V3/WindowsBasedSli/MetricRange.php index 030d428fe5e..3853a8633aa 100644 --- a/Monitoring/src/V3/WindowsBasedSli/MetricRange.php +++ b/Monitoring/src/V3/WindowsBasedSli/MetricRange.php @@ -10,7 +10,7 @@ /** * A `MetricRange` is used when each window is good when the value x of a - * single `TimeSeries` satisfies `range.min <= x < range.max`. The provided + * single `TimeSeries` satisfies `range.min <= x <= range.max`. The provided * `TimeSeries` must have `ValueType = INT64` or `ValueType = DOUBLE` and * `MetricKind = GAUGE`. * @@ -85,13 +85,23 @@ public function setTimeSeries($var) * to an infinite value. * * Generated from protobuf field .google.monitoring.v3.Range range = 4; - * @return \Google\Cloud\Monitoring\V3\Range + * @return \Google\Cloud\Monitoring\V3\Range|null */ public function getRange() { return $this->range; } + public function hasRange() + { + return isset($this->range); + } + + public function clearRange() + { + unset($this->range); + } + /** * Range of values considered "good." For a one-sided range, set one bound * to an infinite value. diff --git a/Monitoring/src/V3/WindowsBasedSli/PerformanceThreshold.php b/Monitoring/src/V3/WindowsBasedSli/PerformanceThreshold.php index 1dd600370b2..5e7ab1c9a75 100644 --- a/Monitoring/src/V3/WindowsBasedSli/PerformanceThreshold.php +++ b/Monitoring/src/V3/WindowsBasedSli/PerformanceThreshold.php @@ -47,13 +47,18 @@ public function __construct($data = NULL) { * `RequestBasedSli` to evaluate to judge window quality. * * Generated from protobuf field .google.monitoring.v3.RequestBasedSli performance = 1; - * @return \Google\Cloud\Monitoring\V3\RequestBasedSli + * @return \Google\Cloud\Monitoring\V3\RequestBasedSli|null */ public function getPerformance() { return $this->readOneof(1); } + public function hasPerformance() + { + return $this->hasOneof(1); + } + /** * `RequestBasedSli` to evaluate to judge window quality. * @@ -73,13 +78,18 @@ public function setPerformance($var) * `BasicSli` to evaluate to judge window quality. * * Generated from protobuf field .google.monitoring.v3.BasicSli basic_sli_performance = 3; - * @return \Google\Cloud\Monitoring\V3\BasicSli + * @return \Google\Cloud\Monitoring\V3\BasicSli|null */ public function getBasicSliPerformance() { return $this->readOneof(3); } + public function hasBasicSliPerformance() + { + return $this->hasOneof(3); + } + /** * `BasicSli` to evaluate to judge window quality. * diff --git a/Monitoring/src/V3/gapic_metadata.json b/Monitoring/src/V3/gapic_metadata.json new file mode 100644 index 00000000000..5e4571c9cfb --- /dev/null +++ b/Monitoring/src/V3/gapic_metadata.json @@ -0,0 +1,307 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.monitoring.v3", + "libraryPackage": "Google\\Cloud\\Monitoring\\V3", + "services": { + "AlertPolicyService": { + "clients": { + "grpc": { + "libraryClient": "AlertPolicyServiceGapicClient", + "rpcs": { + "CreateAlertPolicy": { + "methods": [ + "createAlertPolicy" + ] + }, + "DeleteAlertPolicy": { + "methods": [ + "deleteAlertPolicy" + ] + }, + "GetAlertPolicy": { + "methods": [ + "getAlertPolicy" + ] + }, + "ListAlertPolicies": { + "methods": [ + "listAlertPolicies" + ] + }, + "UpdateAlertPolicy": { + "methods": [ + "updateAlertPolicy" + ] + } + } + } + } + }, + "GroupService": { + "clients": { + "grpc": { + "libraryClient": "GroupServiceGapicClient", + "rpcs": { + "CreateGroup": { + "methods": [ + "createGroup" + ] + }, + "DeleteGroup": { + "methods": [ + "deleteGroup" + ] + }, + "GetGroup": { + "methods": [ + "getGroup" + ] + }, + "ListGroupMembers": { + "methods": [ + "listGroupMembers" + ] + }, + "ListGroups": { + "methods": [ + "listGroups" + ] + }, + "UpdateGroup": { + "methods": [ + "updateGroup" + ] + } + } + } + } + }, + "MetricService": { + "clients": { + "grpc": { + "libraryClient": "MetricServiceGapicClient", + "rpcs": { + "CreateMetricDescriptor": { + "methods": [ + "createMetricDescriptor" + ] + }, + "CreateServiceTimeSeries": { + "methods": [ + "createServiceTimeSeries" + ] + }, + "CreateTimeSeries": { + "methods": [ + "createTimeSeries" + ] + }, + "DeleteMetricDescriptor": { + "methods": [ + "deleteMetricDescriptor" + ] + }, + "GetMetricDescriptor": { + "methods": [ + "getMetricDescriptor" + ] + }, + "GetMonitoredResourceDescriptor": { + "methods": [ + "getMonitoredResourceDescriptor" + ] + }, + "ListMetricDescriptors": { + "methods": [ + "listMetricDescriptors" + ] + }, + "ListMonitoredResourceDescriptors": { + "methods": [ + "listMonitoredResourceDescriptors" + ] + }, + "ListTimeSeries": { + "methods": [ + "listTimeSeries" + ] + } + } + } + } + }, + "NotificationChannelService": { + "clients": { + "grpc": { + "libraryClient": "NotificationChannelServiceGapicClient", + "rpcs": { + "CreateNotificationChannel": { + "methods": [ + "createNotificationChannel" + ] + }, + "DeleteNotificationChannel": { + "methods": [ + "deleteNotificationChannel" + ] + }, + "GetNotificationChannel": { + "methods": [ + "getNotificationChannel" + ] + }, + "GetNotificationChannelDescriptor": { + "methods": [ + "getNotificationChannelDescriptor" + ] + }, + "GetNotificationChannelVerificationCode": { + "methods": [ + "getNotificationChannelVerificationCode" + ] + }, + "ListNotificationChannelDescriptors": { + "methods": [ + "listNotificationChannelDescriptors" + ] + }, + "ListNotificationChannels": { + "methods": [ + "listNotificationChannels" + ] + }, + "SendNotificationChannelVerificationCode": { + "methods": [ + "sendNotificationChannelVerificationCode" + ] + }, + "UpdateNotificationChannel": { + "methods": [ + "updateNotificationChannel" + ] + }, + "VerifyNotificationChannel": { + "methods": [ + "verifyNotificationChannel" + ] + } + } + } + } + }, + "QueryService": { + "clients": { + "grpc": { + "libraryClient": "QueryServiceGapicClient", + "rpcs": { + "QueryTimeSeries": { + "methods": [ + "queryTimeSeries" + ] + } + } + } + } + }, + "ServiceMonitoringService": { + "clients": { + "grpc": { + "libraryClient": "ServiceMonitoringServiceGapicClient", + "rpcs": { + "CreateService": { + "methods": [ + "createService" + ] + }, + "CreateServiceLevelObjective": { + "methods": [ + "createServiceLevelObjective" + ] + }, + "DeleteService": { + "methods": [ + "deleteService" + ] + }, + "DeleteServiceLevelObjective": { + "methods": [ + "deleteServiceLevelObjective" + ] + }, + "GetService": { + "methods": [ + "getService" + ] + }, + "GetServiceLevelObjective": { + "methods": [ + "getServiceLevelObjective" + ] + }, + "ListServiceLevelObjectives": { + "methods": [ + "listServiceLevelObjectives" + ] + }, + "ListServices": { + "methods": [ + "listServices" + ] + }, + "UpdateService": { + "methods": [ + "updateService" + ] + }, + "UpdateServiceLevelObjective": { + "methods": [ + "updateServiceLevelObjective" + ] + } + } + } + } + }, + "UptimeCheckService": { + "clients": { + "grpc": { + "libraryClient": "UptimeCheckServiceGapicClient", + "rpcs": { + "CreateUptimeCheckConfig": { + "methods": [ + "createUptimeCheckConfig" + ] + }, + "DeleteUptimeCheckConfig": { + "methods": [ + "deleteUptimeCheckConfig" + ] + }, + "GetUptimeCheckConfig": { + "methods": [ + "getUptimeCheckConfig" + ] + }, + "ListUptimeCheckConfigs": { + "methods": [ + "listUptimeCheckConfigs" + ] + }, + "ListUptimeCheckIps": { + "methods": [ + "listUptimeCheckIps" + ] + }, + "UpdateUptimeCheckConfig": { + "methods": [ + "updateUptimeCheckConfig" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Monitoring/src/V3/resources/alert_policy_service_client_config.json b/Monitoring/src/V3/resources/alert_policy_service_client_config.json index d6101ccaae8..f2664a2cd62 100644 --- a/Monitoring/src/V3/resources/alert_policy_service_client_config.json +++ b/Monitoring/src/V3/resources/alert_policy_service_client_config.json @@ -1,51 +1,69 @@ { - "interfaces": { - "google.monitoring.v3.AlertPolicyService": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 + "interfaces": { + "google.monitoring.v3.AlertPolicyService": { + "retry_codes": { + "no_retry_codes": [], + "no_retry_1_codes": [], + "retry_policy_6_codes": [ + "UNAVAILABLE" + ] + }, + "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 + }, + "no_retry_1_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 + }, + "retry_policy_6_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + } + }, + "methods": { + "CreateAlertPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "DeleteAlertPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_6_codes", + "retry_params_name": "retry_policy_6_params" + }, + "GetAlertPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_6_codes", + "retry_params_name": "retry_policy_6_params" + }, + "ListAlertPolicies": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_6_codes", + "retry_params_name": "retry_policy_6_params" + }, + "UpdateAlertPolicy": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + } + } } - }, - "methods": { - "ListAlertPolicies": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetAlertPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateAlertPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteAlertPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateAlertPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } } - } } diff --git a/Monitoring/src/V3/resources/alert_policy_service_rest_client_config.php b/Monitoring/src/V3/resources/alert_policy_service_rest_client_config.php index e0d51cd0398..67393699720 100644 --- a/Monitoring/src/V3/resources/alert_policy_service_rest_client_config.php +++ b/Monitoring/src/V3/resources/alert_policy_service_rest_client_config.php @@ -3,9 +3,10 @@ return [ 'interfaces' => [ 'google.monitoring.v3.AlertPolicyService' => [ - 'ListAlertPolicies' => [ - 'method' => 'get', + 'CreateAlertPolicy' => [ + 'method' => 'post', 'uriTemplate' => '/v3/{name=projects/*}/alertPolicies', + 'body' => 'alert_policy', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -14,8 +15,8 @@ ], ], ], - 'GetAlertPolicy' => [ - 'method' => 'get', + 'DeleteAlertPolicy' => [ + 'method' => 'delete', 'uriTemplate' => '/v3/{name=projects/*/alertPolicies/*}', 'placeholders' => [ 'name' => [ @@ -25,10 +26,9 @@ ], ], ], - 'CreateAlertPolicy' => [ - 'method' => 'post', - 'uriTemplate' => '/v3/{name=projects/*}/alertPolicies', - 'body' => 'alert_policy', + 'GetAlertPolicy' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*/alertPolicies/*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -37,9 +37,9 @@ ], ], ], - 'DeleteAlertPolicy' => [ - 'method' => 'delete', - 'uriTemplate' => '/v3/{name=projects/*/alertPolicies/*}', + 'ListAlertPolicies' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*}/alertPolicies', 'placeholders' => [ 'name' => [ 'getters' => [ diff --git a/Monitoring/src/V3/resources/group_service_client_config.json b/Monitoring/src/V3/resources/group_service_client_config.json index a57878c2ece..3701e6baf28 100644 --- a/Monitoring/src/V3/resources/group_service_client_config.json +++ b/Monitoring/src/V3/resources/group_service_client_config.json @@ -1,56 +1,86 @@ { - "interfaces": { - "google.monitoring.v3.GroupService": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 + "interfaces": { + "google.monitoring.v3.GroupService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ], + "retry_policy_2_codes": [ + "UNAVAILABLE" + ], + "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": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + }, + "retry_policy_2_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 180000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 180000, + "total_timeout_millis": 180000 + }, + "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": { + "CreateGroup": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_2_codes", + "retry_params_name": "no_retry_2_params" + }, + "DeleteGroup": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetGroup": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListGroupMembers": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListGroups": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "UpdateGroup": { + "timeout_millis": 180000, + "retry_codes_name": "retry_policy_2_codes", + "retry_params_name": "retry_policy_2_params" + } + } } - }, - "methods": { - "ListGroups": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetGroup": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateGroup": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateGroup": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteGroup": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListGroupMembers": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } } - } } diff --git a/Monitoring/src/V3/resources/group_service_descriptor_config.php b/Monitoring/src/V3/resources/group_service_descriptor_config.php index f9adbe72c89..23b49cfcfbc 100644 --- a/Monitoring/src/V3/resources/group_service_descriptor_config.php +++ b/Monitoring/src/V3/resources/group_service_descriptor_config.php @@ -3,24 +3,24 @@ return [ 'interfaces' => [ 'google.monitoring.v3.GroupService' => [ - 'ListGroups' => [ + 'ListGroupMembers' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getGroup', + 'resourcesGetMethod' => 'getMembers', ], ], - 'ListGroupMembers' => [ + 'ListGroups' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getMembers', + 'resourcesGetMethod' => 'getGroup', ], ], ], diff --git a/Monitoring/src/V3/resources/group_service_rest_client_config.php b/Monitoring/src/V3/resources/group_service_rest_client_config.php index 19fdff918de..1d828ba8b14 100644 --- a/Monitoring/src/V3/resources/group_service_rest_client_config.php +++ b/Monitoring/src/V3/resources/group_service_rest_client_config.php @@ -3,9 +3,10 @@ return [ 'interfaces' => [ 'google.monitoring.v3.GroupService' => [ - 'ListGroups' => [ - 'method' => 'get', + 'CreateGroup' => [ + 'method' => 'post', 'uriTemplate' => '/v3/{name=projects/*}/groups', + 'body' => 'group', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -14,8 +15,8 @@ ], ], ], - 'GetGroup' => [ - 'method' => 'get', + 'DeleteGroup' => [ + 'method' => 'delete', 'uriTemplate' => '/v3/{name=projects/*/groups/*}', 'placeholders' => [ 'name' => [ @@ -25,10 +26,9 @@ ], ], ], - 'CreateGroup' => [ - 'method' => 'post', - 'uriTemplate' => '/v3/{name=projects/*}/groups', - 'body' => 'group', + 'GetGroup' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*/groups/*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -37,22 +37,20 @@ ], ], ], - 'UpdateGroup' => [ - 'method' => 'put', - 'uriTemplate' => '/v3/{group.name=projects/*/groups/*}', - 'body' => 'group', + 'ListGroupMembers' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*/groups/*}/members', 'placeholders' => [ - 'group.name' => [ + 'name' => [ 'getters' => [ - 'getGroup', 'getName', ], ], ], ], - 'DeleteGroup' => [ - 'method' => 'delete', - 'uriTemplate' => '/v3/{name=projects/*/groups/*}', + 'ListGroups' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*}/groups', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -61,12 +59,14 @@ ], ], ], - 'ListGroupMembers' => [ - 'method' => 'get', - 'uriTemplate' => '/v3/{name=projects/*/groups/*}/members', + 'UpdateGroup' => [ + 'method' => 'put', + 'uriTemplate' => '/v3/{group.name=projects/*/groups/*}', + 'body' => 'group', 'placeholders' => [ - 'name' => [ + 'group.name' => [ 'getters' => [ + 'getGroup', 'getName', ], ], diff --git a/Monitoring/src/V3/resources/metric_service_client_config.json b/Monitoring/src/V3/resources/metric_service_client_config.json index b3d5fa2b7ac..37d238c0584 100644 --- a/Monitoring/src/V3/resources/metric_service_client_config.json +++ b/Monitoring/src/V3/resources/metric_service_client_config.json @@ -1,66 +1,101 @@ { - "interfaces": { - "google.monitoring.v3.MetricService": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 30000, - "rpc_timeout_multiplier": 1.3, - "max_rpc_timeout_millis": 90000, - "total_timeout_millis": 600000 + "interfaces": { + "google.monitoring.v3.MetricService": { + "retry_codes": { + "no_retry_codes": [], + "no_retry_3_codes": [], + "retry_policy_7_codes": [ + "UNAVAILABLE" + ], + "retry_policy_8_codes": [ + "UNAVAILABLE" + ] + }, + "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 + }, + "no_retry_3_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 12000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 12000, + "total_timeout_millis": 12000 + }, + "retry_policy_7_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + }, + "retry_policy_8_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 90000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 90000, + "total_timeout_millis": 90000 + } + }, + "methods": { + "CreateMetricDescriptor": { + "timeout_millis": 12000, + "retry_codes_name": "no_retry_3_codes", + "retry_params_name": "no_retry_3_params" + }, + "CreateServiceTimeSeries": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "CreateTimeSeries": { + "timeout_millis": 12000, + "retry_codes_name": "no_retry_3_codes", + "retry_params_name": "no_retry_3_params" + }, + "DeleteMetricDescriptor": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_7_codes", + "retry_params_name": "retry_policy_7_params" + }, + "GetMetricDescriptor": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_7_codes", + "retry_params_name": "retry_policy_7_params" + }, + "GetMonitoredResourceDescriptor": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_7_codes", + "retry_params_name": "retry_policy_7_params" + }, + "ListMetricDescriptors": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_7_codes", + "retry_params_name": "retry_policy_7_params" + }, + "ListMonitoredResourceDescriptors": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_7_codes", + "retry_params_name": "retry_policy_7_params" + }, + "ListTimeSeries": { + "timeout_millis": 90000, + "retry_codes_name": "retry_policy_8_codes", + "retry_params_name": "retry_policy_8_params" + } + } } - }, - "methods": { - "ListMonitoredResourceDescriptors": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetMonitoredResourceDescriptor": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListMetricDescriptors": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetMetricDescriptor": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateMetricDescriptor": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteMetricDescriptor": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListTimeSeries": { - "timeout_millis": 90000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateTimeSeries": { - "timeout_millis": 12000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } } - } } diff --git a/Monitoring/src/V3/resources/metric_service_descriptor_config.php b/Monitoring/src/V3/resources/metric_service_descriptor_config.php index 8e94f30dfab..e18d6331cf5 100644 --- a/Monitoring/src/V3/resources/metric_service_descriptor_config.php +++ b/Monitoring/src/V3/resources/metric_service_descriptor_config.php @@ -3,24 +3,24 @@ return [ 'interfaces' => [ 'google.monitoring.v3.MetricService' => [ - 'ListMonitoredResourceDescriptors' => [ + 'ListMetricDescriptors' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getResourceDescriptors', + 'resourcesGetMethod' => 'getMetricDescriptors', ], ], - 'ListMetricDescriptors' => [ + 'ListMonitoredResourceDescriptors' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getMetricDescriptors', + 'resourcesGetMethod' => 'getResourceDescriptors', ], ], 'ListTimeSeries' => [ diff --git a/Monitoring/src/V3/resources/metric_service_rest_client_config.php b/Monitoring/src/V3/resources/metric_service_rest_client_config.php index d47cc126c82..c7ed1143106 100644 --- a/Monitoring/src/V3/resources/metric_service_rest_client_config.php +++ b/Monitoring/src/V3/resources/metric_service_rest_client_config.php @@ -3,9 +3,10 @@ return [ 'interfaces' => [ 'google.monitoring.v3.MetricService' => [ - 'ListMonitoredResourceDescriptors' => [ - 'method' => 'get', - 'uriTemplate' => '/v3/{name=projects/*}/monitoredResourceDescriptors', + 'CreateMetricDescriptor' => [ + 'method' => 'post', + 'uriTemplate' => '/v3/{name=projects/*}/metricDescriptors', + 'body' => 'metric_descriptor', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -14,9 +15,10 @@ ], ], ], - 'GetMonitoredResourceDescriptor' => [ - 'method' => 'get', - 'uriTemplate' => '/v3/{name=projects/*/monitoredResourceDescriptors/**}', + 'CreateServiceTimeSeries' => [ + 'method' => 'post', + 'uriTemplate' => '/v3/{name=projects/*}/timeSeries:createService', + 'body' => '*', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -25,9 +27,21 @@ ], ], ], - 'ListMetricDescriptors' => [ - 'method' => 'get', - 'uriTemplate' => '/v3/{name=projects/*}/metricDescriptors', + 'CreateTimeSeries' => [ + 'method' => 'post', + 'uriTemplate' => '/v3/{name=projects/*}/timeSeries', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteMetricDescriptor' => [ + 'method' => 'delete', + 'uriTemplate' => '/v3/{name=projects/*/metricDescriptors/**}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -47,10 +61,9 @@ ], ], ], - 'CreateMetricDescriptor' => [ - 'method' => 'post', - 'uriTemplate' => '/v3/{name=projects/*}/metricDescriptors', - 'body' => 'metric_descriptor', + 'GetMonitoredResourceDescriptor' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*/monitoredResourceDescriptors/**}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -59,9 +72,9 @@ ], ], ], - 'DeleteMetricDescriptor' => [ - 'method' => 'delete', - 'uriTemplate' => '/v3/{name=projects/*/metricDescriptors/**}', + 'ListMetricDescriptors' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*}/metricDescriptors', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -70,9 +83,9 @@ ], ], ], - 'ListTimeSeries' => [ + 'ListMonitoredResourceDescriptors' => [ 'method' => 'get', - 'uriTemplate' => '/v3/{name=projects/*}/timeSeries', + 'uriTemplate' => '/v3/{name=projects/*}/monitoredResourceDescriptors', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -81,10 +94,29 @@ ], ], ], - 'CreateTimeSeries' => [ - 'method' => 'post', + 'ListTimeSeries' => [ + 'method' => 'get', 'uriTemplate' => '/v3/{name=projects/*}/timeSeries', - 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=organizations/*}/timeSeries', + 'queryParams' => [ + 'filter', + 'interval', + 'view', + ], + ], + [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=folders/*}/timeSeries', + 'queryParams' => [ + 'filter', + 'interval', + 'view', + ], + ], + ], 'placeholders' => [ 'name' => [ 'getters' => [ @@ -92,6 +124,11 @@ ], ], ], + 'queryParams' => [ + 'filter', + 'interval', + 'view', + ], ], ], ], diff --git a/Monitoring/src/V3/resources/notification_channel_service_client_config.json b/Monitoring/src/V3/resources/notification_channel_service_client_config.json index 5fddaef1323..90437e7f64c 100644 --- a/Monitoring/src/V3/resources/notification_channel_service_client_config.json +++ b/Monitoring/src/V3/resources/notification_channel_service_client_config.json @@ -1,76 +1,94 @@ { - "interfaces": { - "google.monitoring.v3.NotificationChannelService": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 + "interfaces": { + "google.monitoring.v3.NotificationChannelService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_3_codes": [ + "UNAVAILABLE" + ], + "no_retry_5_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_3_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + }, + "no_retry_5_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": { + "CreateNotificationChannel": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_5_codes", + "retry_params_name": "no_retry_5_params" + }, + "DeleteNotificationChannel": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "GetNotificationChannel": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "GetNotificationChannelDescriptor": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "GetNotificationChannelVerificationCode": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "ListNotificationChannelDescriptors": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "ListNotificationChannels": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + }, + "SendNotificationChannelVerificationCode": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_5_codes", + "retry_params_name": "no_retry_5_params" + }, + "UpdateNotificationChannel": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_5_codes", + "retry_params_name": "no_retry_5_params" + }, + "VerifyNotificationChannel": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_3_codes", + "retry_params_name": "retry_policy_3_params" + } + } } - }, - "methods": { - "ListNotificationChannelDescriptors": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetNotificationChannelDescriptor": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListNotificationChannels": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetNotificationChannel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateNotificationChannel": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateNotificationChannel": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteNotificationChannel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "SendNotificationChannelVerificationCode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetNotificationChannelVerificationCode": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "VerifyNotificationChannel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } } - } } diff --git a/Monitoring/src/V3/resources/notification_channel_service_rest_client_config.php b/Monitoring/src/V3/resources/notification_channel_service_rest_client_config.php index 4825d340264..72d0fce4308 100644 --- a/Monitoring/src/V3/resources/notification_channel_service_rest_client_config.php +++ b/Monitoring/src/V3/resources/notification_channel_service_rest_client_config.php @@ -3,9 +3,10 @@ return [ 'interfaces' => [ 'google.monitoring.v3.NotificationChannelService' => [ - 'ListNotificationChannelDescriptors' => [ - 'method' => 'get', - 'uriTemplate' => '/v3/{name=projects/*}/notificationChannelDescriptors', + 'CreateNotificationChannel' => [ + 'method' => 'post', + 'uriTemplate' => '/v3/{name=projects/*}/notificationChannels', + 'body' => 'notification_channel', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -14,9 +15,9 @@ ], ], ], - 'GetNotificationChannelDescriptor' => [ - 'method' => 'get', - 'uriTemplate' => '/v3/{name=projects/*/notificationChannelDescriptors/*}', + 'DeleteNotificationChannel' => [ + 'method' => 'delete', + 'uriTemplate' => '/v3/{name=projects/*/notificationChannels/*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -25,9 +26,9 @@ ], ], ], - 'ListNotificationChannels' => [ + 'GetNotificationChannel' => [ 'method' => 'get', - 'uriTemplate' => '/v3/{name=projects/*}/notificationChannels', + 'uriTemplate' => '/v3/{name=projects/*/notificationChannels/*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -36,9 +37,9 @@ ], ], ], - 'GetNotificationChannel' => [ + 'GetNotificationChannelDescriptor' => [ 'method' => 'get', - 'uriTemplate' => '/v3/{name=projects/*/notificationChannels/*}', + 'uriTemplate' => '/v3/{name=projects/*/notificationChannelDescriptors/*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -47,10 +48,10 @@ ], ], ], - 'CreateNotificationChannel' => [ + 'GetNotificationChannelVerificationCode' => [ 'method' => 'post', - 'uriTemplate' => '/v3/{name=projects/*}/notificationChannels', - 'body' => 'notification_channel', + 'uriTemplate' => '/v3/{name=projects/*/notificationChannels/*}:getVerificationCode', + 'body' => '*', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -59,22 +60,20 @@ ], ], ], - 'UpdateNotificationChannel' => [ - 'method' => 'patch', - 'uriTemplate' => '/v3/{notification_channel.name=projects/*/notificationChannels/*}', - 'body' => 'notification_channel', + 'ListNotificationChannelDescriptors' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*}/notificationChannelDescriptors', 'placeholders' => [ - 'notification_channel.name' => [ + 'name' => [ 'getters' => [ - 'getNotificationChannel', 'getName', ], ], ], ], - 'DeleteNotificationChannel' => [ - 'method' => 'delete', - 'uriTemplate' => '/v3/{name=projects/*/notificationChannels/*}', + 'ListNotificationChannels' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=projects/*}/notificationChannels', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -95,13 +94,14 @@ ], ], ], - 'GetNotificationChannelVerificationCode' => [ - 'method' => 'post', - 'uriTemplate' => '/v3/{name=projects/*/notificationChannels/*}:getVerificationCode', - 'body' => '*', + 'UpdateNotificationChannel' => [ + 'method' => 'patch', + 'uriTemplate' => '/v3/{notification_channel.name=projects/*/notificationChannels/*}', + 'body' => 'notification_channel', 'placeholders' => [ - 'name' => [ + 'notification_channel.name' => [ 'getters' => [ + 'getNotificationChannel', 'getName', ], ], diff --git a/Monitoring/src/V3/resources/query_service_client_config.json b/Monitoring/src/V3/resources/query_service_client_config.json new file mode 100644 index 00000000000..c20408d0ece --- /dev/null +++ b/Monitoring/src/V3/resources/query_service_client_config.json @@ -0,0 +1,27 @@ +{ + "interfaces": { + "google.monitoring.v3.QueryService": { + "retry_codes": { + "no_retry_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 + } + }, + "methods": { + "QueryTimeSeries": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + } + } + } + } +} diff --git a/Monitoring/src/V3/resources/query_service_descriptor_config.php b/Monitoring/src/V3/resources/query_service_descriptor_config.php new file mode 100644 index 00000000000..12a59d769e4 --- /dev/null +++ b/Monitoring/src/V3/resources/query_service_descriptor_config.php @@ -0,0 +1,18 @@ + [ + 'google.monitoring.v3.QueryService' => [ + 'QueryTimeSeries' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getTimeSeriesData', + ], + ], + ], + ], +]; diff --git a/Monitoring/src/V3/resources/query_service_rest_client_config.php b/Monitoring/src/V3/resources/query_service_rest_client_config.php new file mode 100644 index 00000000000..35a51170d71 --- /dev/null +++ b/Monitoring/src/V3/resources/query_service_rest_client_config.php @@ -0,0 +1,20 @@ + [ + 'google.monitoring.v3.QueryService' => [ + 'QueryTimeSeries' => [ + 'method' => 'post', + 'uriTemplate' => '/v3/{name=projects/*}/timeSeries:query', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], +]; diff --git a/Monitoring/src/V3/resources/service_monitoring_service_client_config.json b/Monitoring/src/V3/resources/service_monitoring_service_client_config.json index dfa25dc0bb1..daae71bdd45 100644 --- a/Monitoring/src/V3/resources/service_monitoring_service_client_config.json +++ b/Monitoring/src/V3/resources/service_monitoring_service_client_config.json @@ -1,76 +1,94 @@ { - "interfaces": { - "google.monitoring.v3.ServiceMonitoringService": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 + "interfaces": { + "google.monitoring.v3.ServiceMonitoringService": { + "retry_codes": { + "no_retry_codes": [], + "no_retry_4_codes": [], + "retry_policy_4_codes": [ + "UNAVAILABLE" + ] + }, + "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 + }, + "no_retry_4_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 + }, + "retry_policy_4_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + } + }, + "methods": { + "CreateService": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_4_codes", + "retry_params_name": "no_retry_4_params" + }, + "CreateServiceLevelObjective": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_4_codes", + "retry_params_name": "no_retry_4_params" + }, + "DeleteService": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + }, + "DeleteServiceLevelObjective": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + }, + "GetService": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + }, + "GetServiceLevelObjective": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + }, + "ListServiceLevelObjectives": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + }, + "ListServices": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_4_codes", + "retry_params_name": "retry_policy_4_params" + }, + "UpdateService": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_4_codes", + "retry_params_name": "no_retry_4_params" + }, + "UpdateServiceLevelObjective": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_4_codes", + "retry_params_name": "no_retry_4_params" + } + } } - }, - "methods": { - "CreateService": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetService": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListServices": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateService": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteService": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateServiceLevelObjective": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetServiceLevelObjective": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListServiceLevelObjectives": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateServiceLevelObjective": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteServiceLevelObjective": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } } - } } diff --git a/Monitoring/src/V3/resources/service_monitoring_service_descriptor_config.php b/Monitoring/src/V3/resources/service_monitoring_service_descriptor_config.php index c119d2b060e..dec870024e1 100644 --- a/Monitoring/src/V3/resources/service_monitoring_service_descriptor_config.php +++ b/Monitoring/src/V3/resources/service_monitoring_service_descriptor_config.php @@ -3,24 +3,24 @@ return [ 'interfaces' => [ 'google.monitoring.v3.ServiceMonitoringService' => [ - 'ListServices' => [ + 'ListServiceLevelObjectives' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getServices', + 'resourcesGetMethod' => 'getServiceLevelObjectives', ], ], - 'ListServiceLevelObjectives' => [ + 'ListServices' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', 'requestPageTokenSetMethod' => 'setPageToken', 'requestPageSizeGetMethod' => 'getPageSize', 'requestPageSizeSetMethod' => 'setPageSize', 'responsePageTokenGetMethod' => 'getNextPageToken', - 'resourcesGetMethod' => 'getServiceLevelObjectives', + 'resourcesGetMethod' => 'getServices', ], ], ], diff --git a/Monitoring/src/V3/resources/service_monitoring_service_rest_client_config.php b/Monitoring/src/V3/resources/service_monitoring_service_rest_client_config.php index de2967987d9..cea286539d5 100644 --- a/Monitoring/src/V3/resources/service_monitoring_service_rest_client_config.php +++ b/Monitoring/src/V3/resources/service_monitoring_service_rest_client_config.php @@ -15,20 +15,10 @@ ], ], ], - 'GetService' => [ - 'method' => 'get', - 'uriTemplate' => '/v3/{name=*/*/services/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'ListServices' => [ - 'method' => 'get', - 'uriTemplate' => '/v3/{parent=*/*}/services', + 'CreateServiceLevelObjective' => [ + 'method' => 'post', + 'uriTemplate' => '/v3/{parent=*/*/services/*}/serviceLevelObjectives', + 'body' => 'service_level_objective', 'placeholders' => [ 'parent' => [ 'getters' => [ @@ -37,22 +27,20 @@ ], ], ], - 'UpdateService' => [ - 'method' => 'patch', - 'uriTemplate' => '/v3/{service.name=*/*/services/*}', - 'body' => 'service', + 'DeleteService' => [ + 'method' => 'delete', + 'uriTemplate' => '/v3/{name=*/*/services/*}', 'placeholders' => [ - 'service.name' => [ + 'name' => [ 'getters' => [ - 'getService', 'getName', ], ], ], ], - 'DeleteService' => [ + 'DeleteServiceLevelObjective' => [ 'method' => 'delete', - 'uriTemplate' => '/v3/{name=*/*/services/*}', + 'uriTemplate' => '/v3/{name=*/*/services/*/serviceLevelObjectives/*}', 'placeholders' => [ 'name' => [ 'getters' => [ @@ -61,14 +49,13 @@ ], ], ], - 'CreateServiceLevelObjective' => [ - 'method' => 'post', - 'uriTemplate' => '/v3/{parent=*/*/services/*}/serviceLevelObjectives', - 'body' => 'service_level_objective', + 'GetService' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{name=*/*/services/*}', 'placeholders' => [ - 'parent' => [ + 'name' => [ 'getters' => [ - 'getParent', + 'getName', ], ], ], @@ -95,25 +82,38 @@ ], ], ], - 'UpdateServiceLevelObjective' => [ + 'ListServices' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/{parent=*/*}/services', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateService' => [ 'method' => 'patch', - 'uriTemplate' => '/v3/{service_level_objective.name=*/*/services/*/serviceLevelObjectives/*}', - 'body' => 'service_level_objective', + 'uriTemplate' => '/v3/{service.name=*/*/services/*}', + 'body' => 'service', 'placeholders' => [ - 'service_level_objective.name' => [ + 'service.name' => [ 'getters' => [ - 'getServiceLevelObjective', + 'getService', 'getName', ], ], ], ], - 'DeleteServiceLevelObjective' => [ - 'method' => 'delete', - 'uriTemplate' => '/v3/{name=*/*/services/*/serviceLevelObjectives/*}', + 'UpdateServiceLevelObjective' => [ + 'method' => 'patch', + 'uriTemplate' => '/v3/{service_level_objective.name=*/*/services/*/serviceLevelObjectives/*}', + 'body' => 'service_level_objective', 'placeholders' => [ - 'name' => [ + 'service_level_objective.name' => [ 'getters' => [ + 'getServiceLevelObjective', 'getName', ], ], diff --git a/Monitoring/src/V3/resources/uptime_check_service_client_config.json b/Monitoring/src/V3/resources/uptime_check_service_client_config.json index 11705881bb1..4e19af23389 100644 --- a/Monitoring/src/V3/resources/uptime_check_service_client_config.json +++ b/Monitoring/src/V3/resources/uptime_check_service_client_config.json @@ -1,56 +1,74 @@ { - "interfaces": { - "google.monitoring.v3.UptimeCheckService": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 + "interfaces": { + "google.monitoring.v3.UptimeCheckService": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_5_codes": [ + "UNAVAILABLE" + ], + "no_retry_6_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_5_params": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 30000 + }, + "no_retry_6_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": { + "CreateUptimeCheckConfig": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_6_codes", + "retry_params_name": "no_retry_6_params" + }, + "DeleteUptimeCheckConfig": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_5_codes", + "retry_params_name": "retry_policy_5_params" + }, + "GetUptimeCheckConfig": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_5_codes", + "retry_params_name": "retry_policy_5_params" + }, + "ListUptimeCheckConfigs": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_5_codes", + "retry_params_name": "retry_policy_5_params" + }, + "ListUptimeCheckIps": { + "timeout_millis": 30000, + "retry_codes_name": "retry_policy_5_codes", + "retry_params_name": "retry_policy_5_params" + }, + "UpdateUptimeCheckConfig": { + "timeout_millis": 30000, + "retry_codes_name": "no_retry_6_codes", + "retry_params_name": "no_retry_6_params" + } + } } - }, - "methods": { - "ListUptimeCheckConfigs": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetUptimeCheckConfig": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateUptimeCheckConfig": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateUptimeCheckConfig": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteUptimeCheckConfig": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListUptimeCheckIps": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } } - } } diff --git a/Monitoring/src/V3/resources/uptime_check_service_rest_client_config.php b/Monitoring/src/V3/resources/uptime_check_service_rest_client_config.php index fdef0614f2d..7e11767438d 100644 --- a/Monitoring/src/V3/resources/uptime_check_service_rest_client_config.php +++ b/Monitoring/src/V3/resources/uptime_check_service_rest_client_config.php @@ -3,9 +3,10 @@ return [ 'interfaces' => [ 'google.monitoring.v3.UptimeCheckService' => [ - 'ListUptimeCheckConfigs' => [ - 'method' => 'get', + 'CreateUptimeCheckConfig' => [ + 'method' => 'post', 'uriTemplate' => '/v3/{parent=projects/*}/uptimeCheckConfigs', + 'body' => 'uptime_check_config', 'placeholders' => [ 'parent' => [ 'getters' => [ @@ -14,6 +15,17 @@ ], ], ], + 'DeleteUptimeCheckConfig' => [ + 'method' => 'delete', + 'uriTemplate' => '/v3/{name=projects/*/uptimeCheckConfigs/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'GetUptimeCheckConfig' => [ 'method' => 'get', 'uriTemplate' => '/v3/{name=projects/*/uptimeCheckConfigs/*}', @@ -25,10 +37,9 @@ ], ], ], - 'CreateUptimeCheckConfig' => [ - 'method' => 'post', + 'ListUptimeCheckConfigs' => [ + 'method' => 'get', 'uriTemplate' => '/v3/{parent=projects/*}/uptimeCheckConfigs', - 'body' => 'uptime_check_config', 'placeholders' => [ 'parent' => [ 'getters' => [ @@ -37,6 +48,10 @@ ], ], ], + 'ListUptimeCheckIps' => [ + 'method' => 'get', + 'uriTemplate' => '/v3/uptimeCheckIps', + ], 'UpdateUptimeCheckConfig' => [ 'method' => 'patch', 'uriTemplate' => '/v3/{uptime_check_config.name=projects/*/uptimeCheckConfigs/*}', @@ -50,21 +65,6 @@ ], ], ], - 'DeleteUptimeCheckConfig' => [ - 'method' => 'delete', - 'uriTemplate' => '/v3/{name=projects/*/uptimeCheckConfigs/*}', - 'placeholders' => [ - 'name' => [ - 'getters' => [ - 'getName', - ], - ], - ], - ], - 'ListUptimeCheckIps' => [ - 'method' => 'get', - 'uriTemplate' => '/v3/uptimeCheckIps', - ], ], ], ]; diff --git a/Monitoring/tests/Unit/V3/AlertPolicyServiceClientTest.php b/Monitoring/tests/Unit/V3/AlertPolicyServiceClientTest.php index c1e0744ea68..dd241c19e08 100644 --- a/Monitoring/tests/Unit/V3/AlertPolicyServiceClientTest.php +++ b/Monitoring/tests/Unit/V3/AlertPolicyServiceClientTest.php @@ -22,20 +22,22 @@ namespace Google\Cloud\Monitoring\Tests\Unit\V3; -use Google\Cloud\Monitoring\V3\AlertPolicyServiceClient; use Google\ApiCore\ApiException; + use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; + use Google\Cloud\Monitoring\V3\AlertPolicy; +use Google\Cloud\Monitoring\V3\AlertPolicyServiceClient; use Google\Cloud\Monitoring\V3\ListAlertPoliciesResponse; -use Google\Protobuf\Any; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; /** * @group monitoring + * * @group gapic */ class AlertPolicyServiceClientTest extends GeneratedTest @@ -53,9 +55,7 @@ private function createTransport($deserialize = null) */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class) - ->disableOriginalConstructor() - ->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } /** @@ -66,84 +66,74 @@ private function createClient(array $options = []) $options += [ 'credentials' => $this->createCredentials(), ]; - return new AlertPolicyServiceClient($options); } /** * @test */ - public function listAlertPoliciesTest() + public function createAlertPolicyTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $alertPoliciesElement = new AlertPolicy(); - $alertPolicies = [$alertPoliciesElement]; - $expectedResponse = new ListAlertPoliciesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAlertPolicies($alertPolicies); + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $expectedResponse = new AlertPolicy(); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - - $response = $client->listAlertPolicies($formattedName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAlertPolicies()[0], $resources[0]); - + $name = 'name3373707'; + $alertPolicy = new AlertPolicy(); + $response = $client->createAlertPolicy($name, $alertPolicy); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.AlertPolicyService/ListAlertPolicies', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.AlertPolicyService/CreateAlertPolicy', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertProtobufEquals($name, $actualValue); + $actualValue = $actualRequestObject->getAlertPolicy(); + $this->assertProtobufEquals($alertPolicy, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listAlertPoliciesExceptionTest() + public function createAlertPolicyExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - + $name = 'name3373707'; + $alertPolicy = new AlertPolicy(); try { - $client->listAlertPolicies($formattedName); + $client->createAlertPolicy($name, $alertPolicy); // If the $client 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()); @@ -152,73 +142,59 @@ public function listAlertPoliciesExceptionTest() /** * @test */ - public function getAlertPolicyTest() + public function deleteAlertPolicyTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $expectedResponse = new AlertPolicy(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request $formattedName = $client->alertPolicyName('[PROJECT]', '[ALERT_POLICY]'); - - $response = $client->getAlertPolicy($formattedName); - $this->assertEquals($expectedResponse, $response); + $client->deleteAlertPolicy($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.AlertPolicyService/GetAlertPolicy', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.AlertPolicyService/DeleteAlertPolicy', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getAlertPolicyExceptionTest() + public function deleteAlertPolicyExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedName = $client->alertPolicyName('[PROJECT]', '[ALERT_POLICY]'); - try { - $client->getAlertPolicy($formattedName); + $client->deleteAlertPolicy($formattedName); // If the $client 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()); @@ -227,13 +203,13 @@ public function getAlertPolicyExceptionTest() /** * @test */ - public function createAlertPolicyTest() + public function getAlertPolicyTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name2 = 'name2-1052831874'; $displayName = 'displayName1615086568'; @@ -241,64 +217,50 @@ public function createAlertPolicyTest() $expectedResponse->setName($name2); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $alertPolicy = new AlertPolicy(); - - $response = $client->createAlertPolicy($formattedName, $alertPolicy); + $formattedName = $client->alertPolicyName('[PROJECT]', '[ALERT_POLICY]'); + $response = $client->getAlertPolicy($formattedName); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.AlertPolicyService/CreateAlertPolicy', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.AlertPolicyService/GetAlertPolicy', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getAlertPolicy(); - - $this->assertProtobufEquals($alertPolicy, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function createAlertPolicyExceptionTest() + public function getAlertPolicyExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $alertPolicy = new AlertPolicy(); - + $formattedName = $client->alertPolicyName('[PROJECT]', '[ALERT_POLICY]'); try { - $client->createAlertPolicy($formattedName, $alertPolicy); + $client->getAlertPolicy($formattedName); // If the $client 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()); @@ -307,68 +269,72 @@ public function createAlertPolicyExceptionTest() /** * @test */ - public function deleteAlertPolicyTest() + public function listAlertPoliciesTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); + $nextPageToken = ''; + $totalSize = 705419236; + $alertPoliciesElement = new AlertPolicy(); + $alertPolicies = [ + $alertPoliciesElement, + ]; + $expectedResponse = new ListAlertPoliciesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setTotalSize($totalSize); + $expectedResponse->setAlertPolicies($alertPolicies); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->alertPolicyName('[PROJECT]', '[ALERT_POLICY]'); - - $client->deleteAlertPolicy($formattedName); + $name = 'name3373707'; + $response = $client->listAlertPolicies($name); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getAlertPolicies()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.AlertPolicyService/DeleteAlertPolicy', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.AlertPolicyService/ListAlertPolicies', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertProtobufEquals($name, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteAlertPolicyExceptionTest() + public function listAlertPoliciesExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->alertPolicyName('[PROJECT]', '[ALERT_POLICY]'); - + $name = 'name3373707'; try { - $client->deleteAlertPolicy($formattedName); + $client->listAlertPolicies($name); // If the $client 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()); @@ -380,10 +346,10 @@ public function deleteAlertPolicyExceptionTest() public function updateAlertPolicyTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name = 'name3373707'; $displayName = 'displayName1615086568'; @@ -391,10 +357,8 @@ public function updateAlertPolicyTest() $expectedResponse->setName($name); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - // Mock request $alertPolicy = new AlertPolicy(); - $response = $client->updateAlertPolicy($alertPolicy); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -402,11 +366,8 @@ public function updateAlertPolicyTest() $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); $this->assertSame('/google.monitoring.v3.AlertPolicyService/UpdateAlertPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getAlertPolicy(); - $this->assertProtobufEquals($alertPolicy, $actualValue); - $this->assertTrue($transport->isExhausted()); } @@ -416,25 +377,22 @@ public function updateAlertPolicyTest() public function updateAlertPolicyExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $alertPolicy = new AlertPolicy(); - try { $client->updateAlertPolicy($alertPolicy); // If the $client method call did not throw, fail the test @@ -443,7 +401,6 @@ public function updateAlertPolicyExceptionTest() $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/Monitoring/tests/Unit/V3/GroupServiceClientTest.php b/Monitoring/tests/Unit/V3/GroupServiceClientTest.php index 295f7c82520..8fe1c701d13 100644 --- a/Monitoring/tests/Unit/V3/GroupServiceClientTest.php +++ b/Monitoring/tests/Unit/V3/GroupServiceClientTest.php @@ -22,22 +22,24 @@ namespace Google\Cloud\Monitoring\Tests\Unit\V3; -use Google\Cloud\Monitoring\V3\GroupServiceClient; +use Google\Api\MonitoredResource; + use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; + use Google\ApiCore\Testing\MockTransport; -use Google\Api\MonitoredResource; use Google\Cloud\Monitoring\V3\Group; +use Google\Cloud\Monitoring\V3\GroupServiceClient; use Google\Cloud\Monitoring\V3\ListGroupMembersResponse; use Google\Cloud\Monitoring\V3\ListGroupsResponse; -use Google\Protobuf\Any; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; /** * @group monitoring + * * @group gapic */ class GroupServiceClientTest extends GeneratedTest @@ -55,9 +57,7 @@ private function createTransport($deserialize = null) */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class) - ->disableOriginalConstructor() - ->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } /** @@ -68,84 +68,80 @@ private function createClient(array $options = []) $options += [ 'credentials' => $this->createCredentials(), ]; - return new GroupServiceClient($options); } /** * @test */ - public function listGroupsTest() + public function createGroupTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $groupElement = new Group(); - $group = [$groupElement]; - $expectedResponse = new ListGroupsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setGroup($group); + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $parentName = 'parentName1015022848'; + $filter = 'filter-1274492040'; + $isCluster = false; + $expectedResponse = new Group(); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setParentName($parentName); + $expectedResponse->setFilter($filter); + $expectedResponse->setIsCluster($isCluster); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - - $response = $client->listGroups($formattedName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getGroup()[0], $resources[0]); - + $name = 'name3373707'; + $group = new Group(); + $response = $client->createGroup($name, $group); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.GroupService/ListGroups', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.GroupService/CreateGroup', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertProtobufEquals($name, $actualValue); + $actualValue = $actualRequestObject->getGroup(); + $this->assertProtobufEquals($group, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listGroupsExceptionTest() + public function createGroupExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - + $name = 'name3373707'; + $group = new Group(); try { - $client->listGroups($formattedName); + $client->createGroup($name, $group); // If the $client 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()); @@ -154,79 +150,59 @@ public function listGroupsExceptionTest() /** * @test */ - public function getGroupTest() + public function deleteGroupTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $parentName = 'parentName1015022848'; - $filter = 'filter-1274492040'; - $isCluster = false; - $expectedResponse = new Group(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setParentName($parentName); - $expectedResponse->setFilter($filter); - $expectedResponse->setIsCluster($isCluster); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); - - $response = $client->getGroup($formattedName); - $this->assertEquals($expectedResponse, $response); + $client->deleteGroup($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.GroupService/GetGroup', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.GroupService/DeleteGroup', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getGroupExceptionTest() + public function deleteGroupExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); - try { - $client->getGroup($formattedName); + $client->deleteGroup($formattedName); // If the $client 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()); @@ -235,13 +211,13 @@ public function getGroupExceptionTest() /** * @test */ - public function createGroupTest() + public function getGroupTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name2 = 'name2-1052831874'; $displayName = 'displayName1615086568'; @@ -255,64 +231,50 @@ public function createGroupTest() $expectedResponse->setFilter($filter); $expectedResponse->setIsCluster($isCluster); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $group = new Group(); - - $response = $client->createGroup($formattedName, $group); + $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); + $response = $client->getGroup($formattedName); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.GroupService/CreateGroup', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.GroupService/GetGroup', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getGroup(); - - $this->assertProtobufEquals($group, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function createGroupExceptionTest() + public function getGroupExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $group = new Group(); - + $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); try { - $client->createGroup($formattedName, $group); + $client->getGroup($formattedName); // If the $client 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()); @@ -321,79 +283,72 @@ public function createGroupExceptionTest() /** * @test */ - public function updateGroupTest() + public function listGroupMembersTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $parentName = 'parentName1015022848'; - $filter = 'filter-1274492040'; - $isCluster = false; - $expectedResponse = new Group(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setParentName($parentName); - $expectedResponse->setFilter($filter); - $expectedResponse->setIsCluster($isCluster); + $nextPageToken = ''; + $totalSize = 705419236; + $membersElement = new MonitoredResource(); + $members = [ + $membersElement, + ]; + $expectedResponse = new ListGroupMembersResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setTotalSize($totalSize); + $expectedResponse->setMembers($members); $transport->addResponse($expectedResponse); - // Mock request - $group = new Group(); - - $response = $client->updateGroup($group); - $this->assertEquals($expectedResponse, $response); + $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); + $response = $client->listGroupMembers($formattedName); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getMembers()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.GroupService/UpdateGroup', $actualFuncCall); - - $actualValue = $actualRequestObject->getGroup(); - - $this->assertProtobufEquals($group, $actualValue); - + $this->assertSame('/google.monitoring.v3.GroupService/ListGroupMembers', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function updateGroupExceptionTest() + public function listGroupMembersExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $group = new Group(); - + $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); try { - $client->updateGroup($group); + $client->listGroupMembers($formattedName); // If the $client 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()); @@ -402,68 +357,70 @@ public function updateGroupExceptionTest() /** * @test */ - public function deleteGroupTest() + public function listGroupsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); + $nextPageToken = ''; + $groupElement = new Group(); + $group = [ + $groupElement, + ]; + $expectedResponse = new ListGroupsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setGroup($group); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); - - $client->deleteGroup($formattedName); + $name = 'name3373707'; + $response = $client->listGroups($name); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getGroup()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.GroupService/DeleteGroup', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.GroupService/ListGroups', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertProtobufEquals($name, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteGroupExceptionTest() + public function listGroupsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); - + $name = 'name3373707'; try { - $client->deleteGroup($formattedName); + $client->listGroups($name); // If the $client 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()); @@ -472,79 +429,70 @@ public function deleteGroupExceptionTest() /** * @test */ - public function listGroupMembersTest() + public function updateGroupTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $totalSize = 705419236; - $membersElement = new MonitoredResource(); - $members = [$membersElement]; - $expectedResponse = new ListGroupMembersResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setTotalSize($totalSize); - $expectedResponse->setMembers($members); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $parentName = 'parentName1015022848'; + $filter = 'filter-1274492040'; + $isCluster = false; + $expectedResponse = new Group(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setParentName($parentName); + $expectedResponse->setFilter($filter); + $expectedResponse->setIsCluster($isCluster); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); - - $response = $client->listGroupMembers($formattedName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getMembers()[0], $resources[0]); - + $group = new Group(); + $response = $client->updateGroup($group); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.GroupService/ListGroupMembers', $actualFuncCall); - - $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertSame('/google.monitoring.v3.GroupService/UpdateGroup', $actualFuncCall); + $actualValue = $actualRequestObject->getGroup(); + $this->assertProtobufEquals($group, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listGroupMembersExceptionTest() + public function updateGroupExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->groupName('[PROJECT]', '[GROUP]'); - + $group = new Group(); try { - $client->listGroupMembers($formattedName); + $client->updateGroup($group); // If the $client 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/Monitoring/tests/Unit/V3/MetricServiceClientTest.php b/Monitoring/tests/Unit/V3/MetricServiceClientTest.php index 84bb6ff0ce3..a4735f08b38 100644 --- a/Monitoring/tests/Unit/V3/MetricServiceClientTest.php +++ b/Monitoring/tests/Unit/V3/MetricServiceClientTest.php @@ -22,26 +22,28 @@ namespace Google\Cloud\Monitoring\Tests\Unit\V3; -use Google\Cloud\Monitoring\V3\MetricServiceClient; +use Google\Api\MetricDescriptor; + +use Google\Api\MonitoredResourceDescriptor; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; + use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; -use Google\Api\MetricDescriptor; -use Google\Api\MonitoredResourceDescriptor; use Google\Cloud\Monitoring\V3\ListMetricDescriptorsResponse; use Google\Cloud\Monitoring\V3\ListMonitoredResourceDescriptorsResponse; use Google\Cloud\Monitoring\V3\ListTimeSeriesRequest\TimeSeriesView; use Google\Cloud\Monitoring\V3\ListTimeSeriesResponse; +use Google\Cloud\Monitoring\V3\MetricServiceClient; use Google\Cloud\Monitoring\V3\TimeInterval; use Google\Cloud\Monitoring\V3\TimeSeries; -use Google\Protobuf\Any; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; /** * @group monitoring + * * @group gapic */ class MetricServiceClientTest extends GeneratedTest @@ -59,9 +61,7 @@ private function createTransport($deserialize = null) */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class) - ->disableOriginalConstructor() - ->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } /** @@ -72,84 +72,145 @@ private function createClient(array $options = []) $options += [ 'credentials' => $this->createCredentials(), ]; - return new MetricServiceClient($options); } /** * @test */ - public function listMonitoredResourceDescriptorsTest() + public function createMetricDescriptorTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $type = 'type3575610'; + $unit = 'unit3594628'; + $description = 'description-1724546052'; + $displayName = 'displayName1615086568'; + $expectedResponse = new MetricDescriptor(); + $expectedResponse->setName($name2); + $expectedResponse->setType($type); + $expectedResponse->setUnit($unit); + $expectedResponse->setDescription($description); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $metricDescriptor = new MetricDescriptor(); + $response = $client->createMetricDescriptor($name, $metricDescriptor); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.monitoring.v3.MetricService/CreateMetricDescriptor', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $actualValue = $actualRequestObject->getMetricDescriptor(); + $this->assertProtobufEquals($metricDescriptor, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + /** + * @test + */ + public function createMetricDescriptorExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 + $name = 'name3373707'; + $metricDescriptor = new MetricDescriptor(); + try { + $client->createMetricDescriptor($name, $metricDescriptor); + // If the $client 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 createServiceTimeSeriesTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); // Mock response - $nextPageToken = ''; - $resourceDescriptorsElement = new MonitoredResourceDescriptor(); - $resourceDescriptors = [$resourceDescriptorsElement]; - $expectedResponse = new ListMonitoredResourceDescriptorsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setResourceDescriptors($resourceDescriptors); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request $formattedName = $client->projectName('[PROJECT]'); - - $response = $client->listMonitoredResourceDescriptors($formattedName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getResourceDescriptors()[0], $resources[0]); - + $timeSeries = []; + $client->createServiceTimeSeries($formattedName, $timeSeries); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.MetricService/ListMonitoredResourceDescriptors', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.MetricService/CreateServiceTimeSeries', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualRequestObject->getTimeSeries(); + $this->assertProtobufEquals($timeSeries, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listMonitoredResourceDescriptorsExceptionTest() + public function createServiceTimeSeriesExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedName = $client->projectName('[PROJECT]'); - + $timeSeries = []; try { - $client->listMonitoredResourceDescriptors($formattedName); + $client->createServiceTimeSeries($formattedName, $timeSeries); // If the $client 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()); @@ -158,77 +219,63 @@ public function listMonitoredResourceDescriptorsExceptionTest() /** * @test */ - public function getMonitoredResourceDescriptorTest() + public function createTimeSeriesTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $type = 'type3575610'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new MonitoredResourceDescriptor(); - $expectedResponse->setName($name2); - $expectedResponse->setType($type); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->monitoredResourceDescriptorName('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]'); - - $response = $client->getMonitoredResourceDescriptor($formattedName); - $this->assertEquals($expectedResponse, $response); + $formattedName = $client->projectName('[PROJECT]'); + $timeSeries = []; + $client->createTimeSeries($formattedName, $timeSeries); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.MetricService/GetMonitoredResourceDescriptor', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.MetricService/CreateTimeSeries', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - + $actualValue = $actualRequestObject->getTimeSeries(); + $this->assertProtobufEquals($timeSeries, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getMonitoredResourceDescriptorExceptionTest() + public function createTimeSeriesExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->monitoredResourceDescriptorName('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]'); - + $formattedName = $client->projectName('[PROJECT]'); + $timeSeries = []; try { - $client->getMonitoredResourceDescriptor($formattedName); + $client->createTimeSeries($formattedName, $timeSeries); // If the $client 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()); @@ -237,39 +284,25 @@ public function getMonitoredResourceDescriptorExceptionTest() /** * @test */ - public function listMetricDescriptorsTest() + public function deleteMetricDescriptorTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $metricDescriptorsElement = new MetricDescriptor(); - $metricDescriptors = [$metricDescriptorsElement]; - $expectedResponse = new ListMetricDescriptorsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setMetricDescriptors($metricDescriptors); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - - $response = $client->listMetricDescriptors($formattedName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getMetricDescriptors()[0], $resources[0]); - + $formattedName = $client->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); + $client->deleteMetricDescriptor($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.MetricService/ListMetricDescriptors', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.MetricService/DeleteMetricDescriptor', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); } @@ -277,37 +310,33 @@ public function listMetricDescriptorsTest() /** * @test */ - public function listMetricDescriptorsExceptionTest() + public function deleteMetricDescriptorExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - + $formattedName = $client->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); try { - $client->listMetricDescriptors($formattedName); + $client->deleteMetricDescriptor($formattedName); // If the $client 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()); @@ -319,10 +348,10 @@ public function listMetricDescriptorsExceptionTest() public function getMetricDescriptorTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name2 = 'name2-1052831874'; $type = 'type3575610'; @@ -336,10 +365,8 @@ public function getMetricDescriptorTest() $expectedResponse->setDescription($description); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - // Mock request $formattedName = $client->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); - $response = $client->getMetricDescriptor($formattedName); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -347,11 +374,8 @@ public function getMetricDescriptorTest() $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); $this->assertSame('/google.monitoring.v3.MetricService/GetMetricDescriptor', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); } @@ -361,25 +385,22 @@ public function getMetricDescriptorTest() public function getMetricDescriptorExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedName = $client->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); - try { $client->getMetricDescriptor($formattedName); // If the $client method call did not throw, fail the test @@ -388,7 +409,6 @@ public function getMetricDescriptorExceptionTest() $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()); @@ -397,84 +417,68 @@ public function getMetricDescriptorExceptionTest() /** * @test */ - public function createMetricDescriptorTest() + public function getMonitoredResourceDescriptorTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name2 = 'name2-1052831874'; $type = 'type3575610'; - $unit = 'unit3594628'; - $description = 'description-1724546052'; $displayName = 'displayName1615086568'; - $expectedResponse = new MetricDescriptor(); + $description = 'description-1724546052'; + $expectedResponse = new MonitoredResourceDescriptor(); $expectedResponse->setName($name2); $expectedResponse->setType($type); - $expectedResponse->setUnit($unit); - $expectedResponse->setDescription($description); $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDescription($description); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $metricDescriptor = new MetricDescriptor(); - - $response = $client->createMetricDescriptor($formattedName, $metricDescriptor); + $formattedName = $client->monitoredResourceDescriptorName('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]'); + $response = $client->getMonitoredResourceDescriptor($formattedName); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.MetricService/CreateMetricDescriptor', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.MetricService/GetMonitoredResourceDescriptor', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getMetricDescriptor(); - - $this->assertProtobufEquals($metricDescriptor, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function createMetricDescriptorExceptionTest() + public function getMonitoredResourceDescriptorExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $metricDescriptor = new MetricDescriptor(); - + $formattedName = $client->monitoredResourceDescriptorName('[PROJECT]', '[MONITORED_RESOURCE_DESCRIPTOR]'); try { - $client->createMetricDescriptor($formattedName, $metricDescriptor); + $client->getMonitoredResourceDescriptor($formattedName); // If the $client 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()); @@ -483,68 +487,70 @@ public function createMetricDescriptorExceptionTest() /** * @test */ - public function deleteMetricDescriptorTest() + public function listMetricDescriptorsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); + $nextPageToken = ''; + $metricDescriptorsElement = new MetricDescriptor(); + $metricDescriptors = [ + $metricDescriptorsElement, + ]; + $expectedResponse = new ListMetricDescriptorsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setMetricDescriptors($metricDescriptors); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); - - $client->deleteMetricDescriptor($formattedName); + $name = 'name3373707'; + $response = $client->listMetricDescriptors($name); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getMetricDescriptors()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.MetricService/DeleteMetricDescriptor', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.MetricService/ListMetricDescriptors', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertProtobufEquals($name, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteMetricDescriptorExceptionTest() + public function listMetricDescriptorsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->metricDescriptorName('[PROJECT]', '[METRIC_DESCRIPTOR]'); - + $name = 'name3373707'; try { - $client->deleteMetricDescriptor($formattedName); + $client->listMetricDescriptors($name); // If the $client 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()); @@ -553,92 +559,70 @@ public function deleteMetricDescriptorExceptionTest() /** * @test */ - public function listTimeSeriesTest() + public function listMonitoredResourceDescriptorsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $nextPageToken = ''; - $timeSeriesElement = new TimeSeries(); - $timeSeries = [$timeSeriesElement]; - $expectedResponse = new ListTimeSeriesResponse(); + $resourceDescriptorsElement = new MonitoredResourceDescriptor(); + $resourceDescriptors = [ + $resourceDescriptorsElement, + ]; + $expectedResponse = new ListMonitoredResourceDescriptorsResponse(); $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setTimeSeries($timeSeries); + $expectedResponse->setResourceDescriptors($resourceDescriptors); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $filter = 'filter-1274492040'; - $interval = new TimeInterval(); - $view = TimeSeriesView::FULL; - - $response = $client->listTimeSeries($formattedName, $filter, $interval, $view); + $name = 'name3373707'; + $response = $client->listMonitoredResourceDescriptors($name); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getTimeSeries()[0], $resources[0]); - + $this->assertEquals($expectedResponse->getResourceDescriptors()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.MetricService/ListTimeSeries', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.MetricService/ListMonitoredResourceDescriptors', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getFilter(); - - $this->assertProtobufEquals($filter, $actualValue); - $actualValue = $actualRequestObject->getInterval(); - - $this->assertProtobufEquals($interval, $actualValue); - $actualValue = $actualRequestObject->getView(); - - $this->assertProtobufEquals($view, $actualValue); + $this->assertProtobufEquals($name, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listTimeSeriesExceptionTest() + public function listMonitoredResourceDescriptorsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $filter = 'filter-1274492040'; - $interval = new TimeInterval(); - $view = TimeSeriesView::FULL; - + $name = 'name3373707'; try { - $client->listTimeSeries($formattedName, $filter, $interval, $view); + $client->listMonitoredResourceDescriptors($name); // If the $client 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()); @@ -647,73 +631,84 @@ public function listTimeSeriesExceptionTest() /** * @test */ - public function createTimeSeriesTest() + public function listTimeSeriesTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); + $nextPageToken = ''; + $unit = 'unit3594628'; + $timeSeriesElement = new TimeSeries(); + $timeSeries = [ + $timeSeriesElement, + ]; + $expectedResponse = new ListTimeSeriesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setUnit($unit); + $expectedResponse->setTimeSeries($timeSeries); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $timeSeries = []; - - $client->createTimeSeries($formattedName, $timeSeries); + $formattedName = $client->workspaceName('[PROJECT]'); + $filter = 'filter-1274492040'; + $interval = new TimeInterval(); + $view = TimeSeriesView::FULL; + $response = $client->listTimeSeries($formattedName, $filter, $interval, $view); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getTimeSeries()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.MetricService/CreateTimeSeries', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.MetricService/ListTimeSeries', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getTimeSeries(); - - $this->assertProtobufEquals($timeSeries, $actualValue); - + $actualValue = $actualRequestObject->getFilter(); + $this->assertProtobufEquals($filter, $actualValue); + $actualValue = $actualRequestObject->getInterval(); + $this->assertProtobufEquals($interval, $actualValue); + $actualValue = $actualRequestObject->getView(); + $this->assertProtobufEquals($view, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function createTimeSeriesExceptionTest() + public function listTimeSeriesExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $timeSeries = []; - + $formattedName = $client->workspaceName('[PROJECT]'); + $filter = 'filter-1274492040'; + $interval = new TimeInterval(); + $view = TimeSeriesView::FULL; try { - $client->createTimeSeries($formattedName, $timeSeries); + $client->listTimeSeries($formattedName, $filter, $interval, $view); // If the $client 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/Monitoring/tests/Unit/V3/NotificationChannelServiceClientTest.php b/Monitoring/tests/Unit/V3/NotificationChannelServiceClientTest.php index 84c67a07bc9..d1b56e01aef 100644 --- a/Monitoring/tests/Unit/V3/NotificationChannelServiceClientTest.php +++ b/Monitoring/tests/Unit/V3/NotificationChannelServiceClientTest.php @@ -22,23 +22,25 @@ namespace Google\Cloud\Monitoring\Tests\Unit\V3; -use Google\Cloud\Monitoring\V3\NotificationChannelServiceClient; use Google\ApiCore\ApiException; + use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; + use Google\Cloud\Monitoring\V3\GetNotificationChannelVerificationCodeResponse; use Google\Cloud\Monitoring\V3\ListNotificationChannelDescriptorsResponse; use Google\Cloud\Monitoring\V3\ListNotificationChannelsResponse; use Google\Cloud\Monitoring\V3\NotificationChannel; use Google\Cloud\Monitoring\V3\NotificationChannelDescriptor; -use Google\Protobuf\Any; +use Google\Cloud\Monitoring\V3\NotificationChannelServiceClient; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; /** * @group monitoring + * * @group gapic */ class NotificationChannelServiceClientTest extends GeneratedTest @@ -56,9 +58,7 @@ private function createTransport($deserialize = null) */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class) - ->disableOriginalConstructor() - ->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } /** @@ -69,84 +69,78 @@ private function createClient(array $options = []) $options += [ 'credentials' => $this->createCredentials(), ]; - return new NotificationChannelServiceClient($options); } /** * @test */ - public function listNotificationChannelDescriptorsTest() + public function createNotificationChannelTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $channelDescriptorsElement = new NotificationChannelDescriptor(); - $channelDescriptors = [$channelDescriptorsElement]; - $expectedResponse = new ListNotificationChannelDescriptorsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setChannelDescriptors($channelDescriptors); + $type = 'type3575610'; + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $description = 'description-1724546052'; + $expectedResponse = new NotificationChannel(); + $expectedResponse->setType($type); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDescription($description); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - - $response = $client->listNotificationChannelDescriptors($formattedName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getChannelDescriptors()[0], $resources[0]); - + $name = 'name3373707'; + $notificationChannel = new NotificationChannel(); + $response = $client->createNotificationChannel($name, $notificationChannel); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.NotificationChannelService/ListNotificationChannelDescriptors', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.NotificationChannelService/CreateNotificationChannel', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertProtobufEquals($name, $actualValue); + $actualValue = $actualRequestObject->getNotificationChannel(); + $this->assertProtobufEquals($notificationChannel, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listNotificationChannelDescriptorsExceptionTest() + public function createNotificationChannelExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - + $name = 'name3373707'; + $notificationChannel = new NotificationChannel(); try { - $client->listNotificationChannelDescriptors($formattedName); + $client->createNotificationChannel($name, $notificationChannel); // If the $client 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()); @@ -155,77 +149,59 @@ public function listNotificationChannelDescriptorsExceptionTest() /** * @test */ - public function getNotificationChannelDescriptorTest() + public function deleteNotificationChannelTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $type = 'type3575610'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new NotificationChannelDescriptor(); - $expectedResponse->setName($name2); - $expectedResponse->setType($type); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->notificationChannelDescriptorName('[PROJECT]', '[CHANNEL_DESCRIPTOR]'); - - $response = $client->getNotificationChannelDescriptor($formattedName); - $this->assertEquals($expectedResponse, $response); + $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); + $client->deleteNotificationChannel($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.NotificationChannelService/GetNotificationChannelDescriptor', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.NotificationChannelService/DeleteNotificationChannel', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getNotificationChannelDescriptorExceptionTest() + public function deleteNotificationChannelExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->notificationChannelDescriptorName('[PROJECT]', '[CHANNEL_DESCRIPTOR]'); - + $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); try { - $client->getNotificationChannelDescriptor($formattedName); + $client->deleteNotificationChannel($formattedName); // If the $client 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()); @@ -234,39 +210,34 @@ public function getNotificationChannelDescriptorExceptionTest() /** * @test */ - public function listNotificationChannelsTest() + public function getNotificationChannelTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $notificationChannelsElement = new NotificationChannel(); - $notificationChannels = [$notificationChannelsElement]; - $expectedResponse = new ListNotificationChannelsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setNotificationChannels($notificationChannels); + $type = 'type3575610'; + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $description = 'description-1724546052'; + $expectedResponse = new NotificationChannel(); + $expectedResponse->setType($type); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDescription($description); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - - $response = $client->listNotificationChannels($formattedName); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getNotificationChannels()[0], $resources[0]); - + $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); + $response = $client->getNotificationChannel($formattedName); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.NotificationChannelService/ListNotificationChannels', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.NotificationChannelService/GetNotificationChannel', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); } @@ -274,37 +245,33 @@ public function listNotificationChannelsTest() /** * @test */ - public function listNotificationChannelsExceptionTest() + public function getNotificationChannelExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - + $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); try { - $client->listNotificationChannels($formattedName); + $client->getNotificationChannel($formattedName); // If the $client 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()); @@ -313,77 +280,68 @@ public function listNotificationChannelsExceptionTest() /** * @test */ - public function getNotificationChannelTest() + public function getNotificationChannelDescriptorTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $type = 'type3575610'; $name2 = 'name2-1052831874'; + $type = 'type3575610'; $displayName = 'displayName1615086568'; $description = 'description-1724546052'; - $expectedResponse = new NotificationChannel(); - $expectedResponse->setType($type); + $expectedResponse = new NotificationChannelDescriptor(); $expectedResponse->setName($name2); + $expectedResponse->setType($type); $expectedResponse->setDisplayName($displayName); $expectedResponse->setDescription($description); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - - $response = $client->getNotificationChannel($formattedName); + $formattedName = $client->notificationChannelDescriptorName('[PROJECT]', '[CHANNEL_DESCRIPTOR]'); + $response = $client->getNotificationChannelDescriptor($formattedName); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.NotificationChannelService/GetNotificationChannel', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.NotificationChannelService/GetNotificationChannelDescriptor', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getNotificationChannelExceptionTest() + public function getNotificationChannelDescriptorExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - + $formattedName = $client->notificationChannelDescriptorName('[PROJECT]', '[CHANNEL_DESCRIPTOR]'); try { - $client->getNotificationChannel($formattedName); + $client->getNotificationChannelDescriptor($formattedName); // If the $client 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()); @@ -392,82 +350,62 @@ public function getNotificationChannelExceptionTest() /** * @test */ - public function createNotificationChannelTest() + public function getNotificationChannelVerificationCodeTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $type = 'type3575610'; - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new NotificationChannel(); - $expectedResponse->setType($type); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); + $code = 'code3059181'; + $expectedResponse = new GetNotificationChannelVerificationCodeResponse(); + $expectedResponse->setCode($code); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $notificationChannel = new NotificationChannel(); - - $response = $client->createNotificationChannel($formattedName, $notificationChannel); + $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); + $response = $client->getNotificationChannelVerificationCode($formattedName); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.NotificationChannelService/CreateNotificationChannel', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.NotificationChannelService/GetNotificationChannelVerificationCode', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getNotificationChannel(); - - $this->assertProtobufEquals($notificationChannel, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function createNotificationChannelExceptionTest() + public function getNotificationChannelVerificationCodeExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->projectName('[PROJECT]'); - $notificationChannel = new NotificationChannel(); - + $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); try { - $client->createNotificationChannel($formattedName, $notificationChannel); + $client->getNotificationChannelVerificationCode($formattedName); // If the $client 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()); @@ -476,77 +414,70 @@ public function createNotificationChannelExceptionTest() /** * @test */ - public function updateNotificationChannelTest() + public function listNotificationChannelDescriptorsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $type = 'type3575610'; - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $description = 'description-1724546052'; - $expectedResponse = new NotificationChannel(); - $expectedResponse->setType($type); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setDescription($description); + $nextPageToken = ''; + $channelDescriptorsElement = new NotificationChannelDescriptor(); + $channelDescriptors = [ + $channelDescriptorsElement, + ]; + $expectedResponse = new ListNotificationChannelDescriptorsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setChannelDescriptors($channelDescriptors); $transport->addResponse($expectedResponse); - // Mock request - $notificationChannel = new NotificationChannel(); - - $response = $client->updateNotificationChannel($notificationChannel); - $this->assertEquals($expectedResponse, $response); + $name = 'name3373707'; + $response = $client->listNotificationChannelDescriptors($name); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getChannelDescriptors()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.NotificationChannelService/UpdateNotificationChannel', $actualFuncCall); - - $actualValue = $actualRequestObject->getNotificationChannel(); - - $this->assertProtobufEquals($notificationChannel, $actualValue); - + $this->assertSame('/google.monitoring.v3.NotificationChannelService/ListNotificationChannelDescriptors', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function updateNotificationChannelExceptionTest() + public function listNotificationChannelDescriptorsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $notificationChannel = new NotificationChannel(); - + $name = 'name3373707'; try { - $client->updateNotificationChannel($notificationChannel); + $client->listNotificationChannelDescriptors($name); // If the $client 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()); @@ -555,68 +486,72 @@ public function updateNotificationChannelExceptionTest() /** * @test */ - public function deleteNotificationChannelTest() + public function listNotificationChannelsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); + $nextPageToken = ''; + $totalSize = 705419236; + $notificationChannelsElement = new NotificationChannel(); + $notificationChannels = [ + $notificationChannelsElement, + ]; + $expectedResponse = new ListNotificationChannelsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setTotalSize($totalSize); + $expectedResponse->setNotificationChannels($notificationChannels); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - - $client->deleteNotificationChannel($formattedName); + $name = 'name3373707'; + $response = $client->listNotificationChannels($name); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getNotificationChannels()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.NotificationChannelService/DeleteNotificationChannel', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.NotificationChannelService/ListNotificationChannels', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertProtobufEquals($name, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteNotificationChannelExceptionTest() + public function listNotificationChannelsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - + $name = 'name3373707'; try { - $client->deleteNotificationChannel($formattedName); + $client->listNotificationChannels($name); // If the $client 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()); @@ -628,28 +563,23 @@ public function deleteNotificationChannelExceptionTest() public function sendNotificationChannelVerificationCodeTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - $client->sendNotificationChannelVerificationCode($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); $this->assertSame('/google.monitoring.v3.NotificationChannelService/SendNotificationChannelVerificationCode', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); } @@ -659,25 +589,22 @@ public function sendNotificationChannelVerificationCodeTest() public function sendNotificationChannelVerificationCodeExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - try { $client->sendNotificationChannelVerificationCode($formattedName); // If the $client method call did not throw, fail the test @@ -686,7 +613,6 @@ public function sendNotificationChannelVerificationCodeExceptionTest() $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()); @@ -695,71 +621,68 @@ public function sendNotificationChannelVerificationCodeExceptionTest() /** * @test */ - public function getNotificationChannelVerificationCodeTest() + public function updateNotificationChannelTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $code = 'code3059181'; - $expectedResponse = new GetNotificationChannelVerificationCodeResponse(); - $expectedResponse->setCode($code); + $type = 'type3575610'; + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $description = 'description-1724546052'; + $expectedResponse = new NotificationChannel(); + $expectedResponse->setType($type); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setDescription($description); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - - $response = $client->getNotificationChannelVerificationCode($formattedName); + $notificationChannel = new NotificationChannel(); + $response = $client->updateNotificationChannel($notificationChannel); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.NotificationChannelService/GetNotificationChannelVerificationCode', $actualFuncCall); - - $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertSame('/google.monitoring.v3.NotificationChannelService/UpdateNotificationChannel', $actualFuncCall); + $actualValue = $actualRequestObject->getNotificationChannel(); + $this->assertProtobufEquals($notificationChannel, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getNotificationChannelVerificationCodeExceptionTest() + public function updateNotificationChannelExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); - + $notificationChannel = new NotificationChannel(); try { - $client->getNotificationChannelVerificationCode($formattedName); + $client->updateNotificationChannel($notificationChannel); // If the $client 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()); @@ -771,10 +694,10 @@ public function getNotificationChannelVerificationCodeExceptionTest() public function verifyNotificationChannelTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $type = 'type3575610'; $name2 = 'name2-1052831874'; @@ -786,11 +709,9 @@ public function verifyNotificationChannelTest() $expectedResponse->setDisplayName($displayName); $expectedResponse->setDescription($description); $transport->addResponse($expectedResponse); - // Mock request $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); $code = 'code3059181'; - $response = $client->verifyNotificationChannel($formattedName, $code); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); @@ -798,14 +719,10 @@ public function verifyNotificationChannelTest() $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); $this->assertSame('/google.monitoring.v3.NotificationChannelService/VerifyNotificationChannel', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); $actualValue = $actualRequestObject->getCode(); - $this->assertProtobufEquals($code, $actualValue); - $this->assertTrue($transport->isExhausted()); } @@ -815,26 +732,23 @@ public function verifyNotificationChannelTest() public function verifyNotificationChannelExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedName = $client->notificationChannelName('[PROJECT]', '[NOTIFICATION_CHANNEL]'); $code = 'code3059181'; - try { $client->verifyNotificationChannel($formattedName, $code); // If the $client method call did not throw, fail the test @@ -843,7 +757,6 @@ public function verifyNotificationChannelExceptionTest() $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/Monitoring/tests/Unit/V3/QueryServiceClientTest.php b/Monitoring/tests/Unit/V3/QueryServiceClientTest.php new file mode 100644 index 00000000000..f57190cf676 --- /dev/null +++ b/Monitoring/tests/Unit/V3/QueryServiceClientTest.php @@ -0,0 +1,145 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** + * @return QueryServiceClient + */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new QueryServiceClient($options); + } + + /** + * @test + */ + public function queryTimeSeriesTest() + { + $transport = $this->createTransport(); + $client = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $timeSeriesDataElement = new TimeSeriesData(); + $timeSeriesData = [ + $timeSeriesDataElement, + ]; + $expectedResponse = new QueryTimeSeriesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setTimeSeriesData($timeSeriesData); + $transport->addResponse($expectedResponse); + // Mock request + $name = 'name3373707'; + $query = 'query107944136'; + $response = $client->queryTimeSeries($name, $query); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getTimeSeriesData()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.monitoring.v3.QueryService/QueryTimeSeries', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($name, $actualValue); + $actualValue = $actualRequestObject->getQuery(); + $this->assertProtobufEquals($query, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function queryTimeSeriesExceptionTest() + { + $transport = $this->createTransport(); + $client = $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 + $name = 'name3373707'; + $query = 'query107944136'; + try { + $client->queryTimeSeries($name, $query); + // If the $client 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/Monitoring/tests/Unit/V3/ServiceMonitoringServiceClientTest.php b/Monitoring/tests/Unit/V3/ServiceMonitoringServiceClientTest.php index 4ce2fb7f088..8cc149952ff 100644 --- a/Monitoring/tests/Unit/V3/ServiceMonitoringServiceClientTest.php +++ b/Monitoring/tests/Unit/V3/ServiceMonitoringServiceClientTest.php @@ -22,22 +22,24 @@ namespace Google\Cloud\Monitoring\Tests\Unit\V3; -use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient; use Google\ApiCore\ApiException; + use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; + use Google\Cloud\Monitoring\V3\ListServiceLevelObjectivesResponse; use Google\Cloud\Monitoring\V3\ListServicesResponse; use Google\Cloud\Monitoring\V3\Service; use Google\Cloud\Monitoring\V3\ServiceLevelObjective; -use Google\Protobuf\Any; +use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; /** * @group monitoring + * * @group gapic */ class ServiceMonitoringServiceClientTest extends GeneratedTest @@ -55,9 +57,7 @@ private function createTransport($deserialize = null) */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class) - ->disableOriginalConstructor() - ->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } /** @@ -68,7 +68,6 @@ private function createClient(array $options = []) $options += [ 'credentials' => $this->createCredentials(), ]; - return new ServiceMonitoringServiceClient($options); } @@ -78,10 +77,10 @@ private function createClient(array $options = []) public function createServiceTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name = 'name3373707'; $displayName = 'displayName1615086568'; @@ -89,26 +88,20 @@ public function createServiceTest() $expectedResponse->setName($name); $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); + $parent = 'parent-995424086'; $service = new Service(); - - $response = $client->createService($formattedParent, $service); + $response = $client->createService($parent, $service); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/CreateService', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertProtobufEquals($parent, $actualValue); $actualValue = $actualRequestObject->getService(); - $this->assertProtobufEquals($service, $actualValue); - $this->assertTrue($transport->isExhausted()); } @@ -118,35 +111,31 @@ public function createServiceTest() public function createServiceExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); + $parent = 'parent-995424086'; $service = new Service(); - try { - $client->createService($formattedParent, $service); + $client->createService($parent, $service); // If the $client 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()); @@ -155,73 +144,70 @@ public function createServiceExceptionTest() /** * @test */ - public function getServiceTest() + public function createServiceLevelObjectiveTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; + $name = 'name3373707'; $displayName = 'displayName1615086568'; - $expectedResponse = new Service(); - $expectedResponse->setName($name2); + $goal = 317825.0; + $expectedResponse = new ServiceLevelObjective(); + $expectedResponse->setName($name); $expectedResponse->setDisplayName($displayName); + $expectedResponse->setGoal($goal); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->serviceName('[PROJECT]', '[SERVICE]'); - - $response = $client->getService($formattedName); + $formattedParent = $client->serviceName('[PROJECT]', '[SERVICE]'); + $serviceLevelObjective = new ServiceLevelObjective(); + $response = $client->createServiceLevelObjective($formattedParent, $serviceLevelObjective); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/GetService', $actualFuncCall); - - $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/CreateServiceLevelObjective', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getServiceLevelObjective(); + $this->assertProtobufEquals($serviceLevelObjective, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getServiceExceptionTest() + public function createServiceLevelObjectiveExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->serviceName('[PROJECT]', '[SERVICE]'); - + $formattedParent = $client->serviceName('[PROJECT]', '[SERVICE]'); + $serviceLevelObjective = new ServiceLevelObjective(); try { - $client->getService($formattedName); + $client->createServiceLevelObjective($formattedParent, $serviceLevelObjective); // If the $client 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()); @@ -230,77 +216,59 @@ public function getServiceExceptionTest() /** * @test */ - public function listServicesTest() + public function deleteServiceTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $servicesElement = new Service(); - $services = [$servicesElement]; - $expectedResponse = new ListServicesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setServices($services); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - - $response = $client->listServices($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getServices()[0], $resources[0]); - + $formattedName = $client->serviceName('[PROJECT]', '[SERVICE]'); + $client->deleteService($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/ListServices', $actualFuncCall); - - $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/DeleteService', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listServicesExceptionTest() + public function deleteServiceExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - + $formattedName = $client->serviceName('[PROJECT]', '[SERVICE]'); try { - $client->listServices($formattedParent); + $client->deleteService($formattedName); // If the $client 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()); @@ -309,73 +277,59 @@ public function listServicesExceptionTest() /** * @test */ - public function updateServiceTest() + public function deleteServiceLevelObjectiveTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $expectedResponse = new Service(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request - $service = new Service(); - - $response = $client->updateService($service); - $this->assertEquals($expectedResponse, $response); + $formattedName = $client->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); + $client->deleteServiceLevelObjective($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/UpdateService', $actualFuncCall); - - $actualValue = $actualRequestObject->getService(); - - $this->assertProtobufEquals($service, $actualValue); - + $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/DeleteServiceLevelObjective', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function updateServiceExceptionTest() + public function deleteServiceLevelObjectiveExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $service = new Service(); - + $formattedName = $client->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); try { - $client->updateService($service); + $client->deleteServiceLevelObjective($formattedName); // If the $client 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()); @@ -384,68 +338,64 @@ public function updateServiceExceptionTest() /** * @test */ - public function deleteServiceTest() + public function getServiceTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); + $name2 = 'name2-1052831874'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Service(); + $expectedResponse->setName($name2); + $expectedResponse->setDisplayName($displayName); $transport->addResponse($expectedResponse); - // Mock request $formattedName = $client->serviceName('[PROJECT]', '[SERVICE]'); - - $client->deleteService($formattedName); + $response = $client->getService($formattedName); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/DeleteService', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/GetService', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteServiceExceptionTest() + public function getServiceExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedName = $client->serviceName('[PROJECT]', '[SERVICE]'); - try { - $client->deleteService($formattedName); + $client->getService($formattedName); // If the $client 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()); @@ -454,80 +404,66 @@ public function deleteServiceExceptionTest() /** * @test */ - public function createServiceLevelObjectiveTest() + public function getServiceLevelObjectiveTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; + $name2 = 'name2-1052831874'; $displayName = 'displayName1615086568'; $goal = 317825.0; $expectedResponse = new ServiceLevelObjective(); - $expectedResponse->setName($name); + $expectedResponse->setName($name2); $expectedResponse->setDisplayName($displayName); $expectedResponse->setGoal($goal); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->serviceName('[PROJECT]', '[SERVICE]'); - $serviceLevelObjective = new ServiceLevelObjective(); - - $response = $client->createServiceLevelObjective($formattedParent, $serviceLevelObjective); + $formattedName = $client->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); + $response = $client->getServiceLevelObjective($formattedName); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/CreateServiceLevelObjective', $actualFuncCall); - - $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getServiceLevelObjective(); - - $this->assertProtobufEquals($serviceLevelObjective, $actualValue); - + $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/GetServiceLevelObjective', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function createServiceLevelObjectiveExceptionTest() + public function getServiceLevelObjectiveExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->serviceName('[PROJECT]', '[SERVICE]'); - $serviceLevelObjective = new ServiceLevelObjective(); - + $formattedName = $client->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); try { - $client->createServiceLevelObjective($formattedParent, $serviceLevelObjective); + $client->getServiceLevelObjective($formattedName); // If the $client 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()); @@ -536,75 +472,70 @@ public function createServiceLevelObjectiveExceptionTest() /** * @test */ - public function getServiceLevelObjectiveTest() + public function listServiceLevelObjectivesTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $goal = 317825.0; - $expectedResponse = new ServiceLevelObjective(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setGoal($goal); + $nextPageToken = ''; + $serviceLevelObjectivesElement = new ServiceLevelObjective(); + $serviceLevelObjectives = [ + $serviceLevelObjectivesElement, + ]; + $expectedResponse = new ListServiceLevelObjectivesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setServiceLevelObjectives($serviceLevelObjectives); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); - - $response = $client->getServiceLevelObjective($formattedName); - $this->assertEquals($expectedResponse, $response); + $formattedParent = $client->serviceName('[PROJECT]', '[SERVICE]'); + $response = $client->listServiceLevelObjectives($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getServiceLevelObjectives()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/GetServiceLevelObjective', $actualFuncCall); - - $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/ListServiceLevelObjectives', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getServiceLevelObjectiveExceptionTest() + public function listServiceLevelObjectivesExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); - + $formattedParent = $client->serviceName('[PROJECT]', '[SERVICE]'); try { - $client->getServiceLevelObjective($formattedName); + $client->listServiceLevelObjectives($formattedParent); // If the $client 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()); @@ -613,77 +544,70 @@ public function getServiceLevelObjectiveExceptionTest() /** * @test */ - public function listServiceLevelObjectivesTest() + public function listServicesTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $nextPageToken = ''; - $serviceLevelObjectivesElement = new ServiceLevelObjective(); - $serviceLevelObjectives = [$serviceLevelObjectivesElement]; - $expectedResponse = new ListServiceLevelObjectivesResponse(); + $servicesElement = new Service(); + $services = [ + $servicesElement, + ]; + $expectedResponse = new ListServicesResponse(); $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setServiceLevelObjectives($serviceLevelObjectives); + $expectedResponse->setServices($services); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->serviceName('[PROJECT]', '[SERVICE]'); - - $response = $client->listServiceLevelObjectives($formattedParent); + $parent = 'parent-995424086'; + $response = $client->listServices($parent); $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); $resources = iterator_to_array($response->iterateAllElements()); $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getServiceLevelObjectives()[0], $resources[0]); - + $this->assertEquals($expectedResponse->getServices()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/ListServiceLevelObjectives', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/ListServices', $actualFuncCall); $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertProtobufEquals($parent, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listServiceLevelObjectivesExceptionTest() + public function listServicesExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->serviceName('[PROJECT]', '[SERVICE]'); - + $parent = 'parent-995424086'; try { - $client->listServiceLevelObjectives($formattedParent); + $client->listServices($parent); // If the $client 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()); @@ -692,75 +616,64 @@ public function listServiceLevelObjectivesExceptionTest() /** * @test */ - public function updateServiceLevelObjectiveTest() + public function updateServiceTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response $name = 'name3373707'; $displayName = 'displayName1615086568'; - $goal = 317825.0; - $expectedResponse = new ServiceLevelObjective(); + $expectedResponse = new Service(); $expectedResponse->setName($name); $expectedResponse->setDisplayName($displayName); - $expectedResponse->setGoal($goal); $transport->addResponse($expectedResponse); - // Mock request - $serviceLevelObjective = new ServiceLevelObjective(); - - $response = $client->updateServiceLevelObjective($serviceLevelObjective); + $service = new Service(); + $response = $client->updateService($service); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/UpdateServiceLevelObjective', $actualFuncCall); - - $actualValue = $actualRequestObject->getServiceLevelObjective(); - - $this->assertProtobufEquals($serviceLevelObjective, $actualValue); - + $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/UpdateService', $actualFuncCall); + $actualValue = $actualRequestObject->getService(); + $this->assertProtobufEquals($service, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function updateServiceLevelObjectiveExceptionTest() + public function updateServiceExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $serviceLevelObjective = new ServiceLevelObjective(); - + $service = new Service(); try { - $client->updateServiceLevelObjective($serviceLevelObjective); + $client->updateService($service); // If the $client 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()); @@ -769,68 +682,66 @@ public function updateServiceLevelObjectiveExceptionTest() /** * @test */ - public function deleteServiceLevelObjectiveTest() + public function updateServiceLevelObjectiveTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $goal = 317825.0; + $expectedResponse = new ServiceLevelObjective(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setGoal($goal); $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $client->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); - - $client->deleteServiceLevelObjective($formattedName); + $serviceLevelObjective = new ServiceLevelObjective(); + $response = $client->updateServiceLevelObjective($serviceLevelObjective); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/DeleteServiceLevelObjective', $actualFuncCall); - - $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertSame('/google.monitoring.v3.ServiceMonitoringService/UpdateServiceLevelObjective', $actualFuncCall); + $actualValue = $actualRequestObject->getServiceLevelObjective(); + $this->assertProtobufEquals($serviceLevelObjective, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteServiceLevelObjectiveExceptionTest() + public function updateServiceLevelObjectiveExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedName = $client->serviceLevelObjectiveName('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]'); - + $serviceLevelObjective = new ServiceLevelObjective(); try { - $client->deleteServiceLevelObjective($formattedName); + $client->updateServiceLevelObjective($serviceLevelObjective); // If the $client 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/Monitoring/tests/Unit/V3/UptimeCheckServiceClientTest.php b/Monitoring/tests/Unit/V3/UptimeCheckServiceClientTest.php index 201a782c673..07013066051 100644 --- a/Monitoring/tests/Unit/V3/UptimeCheckServiceClientTest.php +++ b/Monitoring/tests/Unit/V3/UptimeCheckServiceClientTest.php @@ -22,22 +22,24 @@ namespace Google\Cloud\Monitoring\Tests\Unit\V3; -use Google\Cloud\Monitoring\V3\UptimeCheckServiceClient; use Google\ApiCore\ApiException; + use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; + use Google\Cloud\Monitoring\V3\ListUptimeCheckConfigsResponse; use Google\Cloud\Monitoring\V3\ListUptimeCheckIpsResponse; use Google\Cloud\Monitoring\V3\UptimeCheckConfig; use Google\Cloud\Monitoring\V3\UptimeCheckIp; -use Google\Protobuf\Any; +use Google\Cloud\Monitoring\V3\UptimeCheckServiceClient; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; /** * @group monitoring + * * @group gapic */ class UptimeCheckServiceClientTest extends GeneratedTest @@ -55,9 +57,7 @@ private function createTransport($deserialize = null) */ private function createCredentials() { - return $this->getMockBuilder(CredentialsWrapper::class) - ->disableOriginalConstructor() - ->getMock(); + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } /** @@ -68,86 +68,76 @@ private function createClient(array $options = []) $options += [ 'credentials' => $this->createCredentials(), ]; - return new UptimeCheckServiceClient($options); } /** * @test */ - public function listUptimeCheckConfigsTest() + public function createUptimeCheckConfigTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $totalSize = 705419236; - $uptimeCheckConfigsElement = new UptimeCheckConfig(); - $uptimeCheckConfigs = [$uptimeCheckConfigsElement]; - $expectedResponse = new ListUptimeCheckConfigsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setTotalSize($totalSize); - $expectedResponse->setUptimeCheckConfigs($uptimeCheckConfigs); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $isInternal = true; + $expectedResponse = new UptimeCheckConfig(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setIsInternal($isInternal); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - - $response = $client->listUptimeCheckConfigs($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getUptimeCheckConfigs()[0], $resources[0]); - + $parent = 'parent-995424086'; + $uptimeCheckConfig = new UptimeCheckConfig(); + $response = $client->createUptimeCheckConfig($parent, $uptimeCheckConfig); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.UptimeCheckService/ListUptimeCheckConfigs', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.UptimeCheckService/CreateUptimeCheckConfig', $actualFuncCall); $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertProtobufEquals($parent, $actualValue); + $actualValue = $actualRequestObject->getUptimeCheckConfig(); + $this->assertProtobufEquals($uptimeCheckConfig, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listUptimeCheckConfigsExceptionTest() + public function createUptimeCheckConfigExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - + $parent = 'parent-995424086'; + $uptimeCheckConfig = new UptimeCheckConfig(); try { - $client->listUptimeCheckConfigs($formattedParent); + $client->createUptimeCheckConfig($parent, $uptimeCheckConfig); // If the $client 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()); @@ -156,75 +146,59 @@ public function listUptimeCheckConfigsExceptionTest() /** * @test */ - public function getUptimeCheckConfigTest() + public function deleteUptimeCheckConfigTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $isInternal = true; - $expectedResponse = new UptimeCheckConfig(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIsInternal($isInternal); + $expectedResponse = new GPBEmpty(); $transport->addResponse($expectedResponse); - // Mock request $formattedName = $client->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); - - $response = $client->getUptimeCheckConfig($formattedName); - $this->assertEquals($expectedResponse, $response); + $client->deleteUptimeCheckConfig($formattedName); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.UptimeCheckService/GetUptimeCheckConfig', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.UptimeCheckService/DeleteUptimeCheckConfig', $actualFuncCall); $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function getUptimeCheckConfigExceptionTest() + public function deleteUptimeCheckConfigExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request $formattedName = $client->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); - try { - $client->getUptimeCheckConfig($formattedName); + $client->deleteUptimeCheckConfig($formattedName); // If the $client 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()); @@ -233,80 +207,66 @@ public function getUptimeCheckConfigExceptionTest() /** * @test */ - public function createUptimeCheckConfigTest() + public function getUptimeCheckConfigTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; + $name2 = 'name2-1052831874'; $displayName = 'displayName1615086568'; $isInternal = true; $expectedResponse = new UptimeCheckConfig(); - $expectedResponse->setName($name); + $expectedResponse->setName($name2); $expectedResponse->setDisplayName($displayName); $expectedResponse->setIsInternal($isInternal); $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - $uptimeCheckConfig = new UptimeCheckConfig(); - - $response = $client->createUptimeCheckConfig($formattedParent, $uptimeCheckConfig); + $formattedName = $client->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); + $response = $client->getUptimeCheckConfig($formattedName); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.UptimeCheckService/CreateUptimeCheckConfig', $actualFuncCall); - - $actualValue = $actualRequestObject->getParent(); - - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getUptimeCheckConfig(); - - $this->assertProtobufEquals($uptimeCheckConfig, $actualValue); - + $this->assertSame('/google.monitoring.v3.UptimeCheckService/GetUptimeCheckConfig', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function createUptimeCheckConfigExceptionTest() + public function getUptimeCheckConfigExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $formattedParent = $client->projectName('[PROJECT]'); - $uptimeCheckConfig = new UptimeCheckConfig(); - + $formattedName = $client->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); try { - $client->createUptimeCheckConfig($formattedParent, $uptimeCheckConfig); + $client->getUptimeCheckConfig($formattedName); // If the $client 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()); @@ -315,75 +275,72 @@ public function createUptimeCheckConfigExceptionTest() /** * @test */ - public function updateUptimeCheckConfigTest() + public function listUptimeCheckConfigsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $isInternal = true; - $expectedResponse = new UptimeCheckConfig(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setIsInternal($isInternal); + $nextPageToken = ''; + $totalSize = 705419236; + $uptimeCheckConfigsElement = new UptimeCheckConfig(); + $uptimeCheckConfigs = [ + $uptimeCheckConfigsElement, + ]; + $expectedResponse = new ListUptimeCheckConfigsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setTotalSize($totalSize); + $expectedResponse->setUptimeCheckConfigs($uptimeCheckConfigs); $transport->addResponse($expectedResponse); - // Mock request - $uptimeCheckConfig = new UptimeCheckConfig(); - - $response = $client->updateUptimeCheckConfig($uptimeCheckConfig); - $this->assertEquals($expectedResponse, $response); + $parent = 'parent-995424086'; + $response = $client->listUptimeCheckConfigs($parent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getUptimeCheckConfigs()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.UptimeCheckService/UpdateUptimeCheckConfig', $actualFuncCall); - - $actualValue = $actualRequestObject->getUptimeCheckConfig(); - - $this->assertProtobufEquals($uptimeCheckConfig, $actualValue); - + $this->assertSame('/google.monitoring.v3.UptimeCheckService/ListUptimeCheckConfigs', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($parent, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function updateUptimeCheckConfigExceptionTest() + public function listUptimeCheckConfigsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - // Mock request - $uptimeCheckConfig = new UptimeCheckConfig(); - + $parent = 'parent-995424086'; try { - $client->updateUptimeCheckConfig($uptimeCheckConfig); + $client->listUptimeCheckConfigs($parent); // If the $client 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()); @@ -392,68 +349,64 @@ public function updateUptimeCheckConfigExceptionTest() /** * @test */ - public function deleteUptimeCheckConfigTest() + public function listUptimeCheckIpsTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); + $nextPageToken = ''; + $uptimeCheckIpsElement = new UptimeCheckIp(); + $uptimeCheckIps = [ + $uptimeCheckIpsElement, + ]; + $expectedResponse = new ListUptimeCheckIpsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setUptimeCheckIps($uptimeCheckIps); $transport->addResponse($expectedResponse); - - // Mock request - $formattedName = $client->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); - - $client->deleteUptimeCheckConfig($formattedName); + $response = $client->listUptimeCheckIps(); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getUptimeCheckIps()[0], $resources[0]); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.UptimeCheckService/DeleteUptimeCheckConfig', $actualFuncCall); - - $actualValue = $actualRequestObject->getName(); - - $this->assertProtobufEquals($formattedName, $actualValue); - + $this->assertSame('/google.monitoring.v3.UptimeCheckService/ListUptimeCheckIps', $actualFuncCall); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function deleteUptimeCheckConfigExceptionTest() + public function listUptimeCheckIpsExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - - // Mock request - $formattedName = $client->uptimeCheckConfigName('[PROJECT]', '[UPTIME_CHECK_CONFIG]'); - try { - $client->deleteUptimeCheckConfig($formattedName); + $client->listUptimeCheckIps(); // If the $client 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()); @@ -462,68 +415,66 @@ public function deleteUptimeCheckConfigExceptionTest() /** * @test */ - public function listUptimeCheckIpsTest() + public function updateUptimeCheckConfigTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $this->createClient([ + 'transport' => $transport, + ]); $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $uptimeCheckIpsElement = new UptimeCheckIp(); - $uptimeCheckIps = [$uptimeCheckIpsElement]; - $expectedResponse = new ListUptimeCheckIpsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setUptimeCheckIps($uptimeCheckIps); + $name = 'name3373707'; + $displayName = 'displayName1615086568'; + $isInternal = true; + $expectedResponse = new UptimeCheckConfig(); + $expectedResponse->setName($name); + $expectedResponse->setDisplayName($displayName); + $expectedResponse->setIsInternal($isInternal); $transport->addResponse($expectedResponse); - - $response = $client->listUptimeCheckIps(); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getUptimeCheckIps()[0], $resources[0]); - + // Mock request + $uptimeCheckConfig = new UptimeCheckConfig(); + $response = $client->updateUptimeCheckConfig($uptimeCheckConfig); + $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); $actualFuncCall = $actualRequests[0]->getFuncCall(); $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.monitoring.v3.UptimeCheckService/ListUptimeCheckIps', $actualFuncCall); - + $this->assertSame('/google.monitoring.v3.UptimeCheckService/UpdateUptimeCheckConfig', $actualFuncCall); + $actualValue = $actualRequestObject->getUptimeCheckConfig(); + $this->assertProtobufEquals($uptimeCheckConfig, $actualValue); $this->assertTrue($transport->isExhausted()); } /** * @test */ - public function listUptimeCheckIpsExceptionTest() + public function updateUptimeCheckConfigExceptionTest() { $transport = $this->createTransport(); - $client = $this->createClient(['transport' => $transport]); - + $client = $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' => [], + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], ], JSON_PRETTY_PRINT); $transport->addResponse(null, $status); - + // Mock request + $uptimeCheckConfig = new UptimeCheckConfig(); try { - $client->listUptimeCheckIps(); + $client->updateUptimeCheckConfig($uptimeCheckConfig); // If the $client 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());