Skip to content

Commit ab29b60

Browse files
feat: [recommender] Support cost_in_local_currency field in the cost projection (#10140)
* feat: Support cost_in_local_currency field in the cost projection docs: Fix typo for the comment of reliability_projection docs: Add comment for targetResources PiperOrigin-RevId: 589982370 Source-Link: googleapis/googleapis@b7abf5c Source-Link: https://github.com/googleapis/googleapis-gen/commit/1617d1ede2a05c13289cfea4883bcdf9116f564e Copy-Tag: eyJwIjoiamF2YS1yZWNvbW1lbmRlci8uT3dsQm90LnlhbWwiLCJoIjoiMTYxN2QxZWRlMmEwNWMxMzI4OWNmZWE0ODgzYmNkZjkxMTZmNTY0ZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 3ef3b0a commit ab29b60

15 files changed

Lines changed: 535 additions & 76 deletions

File tree

java-recommender/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
195195
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
196196
[stability-image]: https://img.shields.io/badge/stability-stable-green
197197
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-recommender.svg
198-
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-recommender/2.32.0
198+
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-recommender/2.34.0
199199
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
200200
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
201201
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles

java-recommender/google-cloud-recommender/src/main/java/com/google/cloud/recommender/v1/RecommenderClient.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,9 @@ public final ListRecommendationsPagedResponse listRecommendations(String parent)
846846
* <ul>
847847
* <li>`priority`
848848
* </ul>
849+
* <ul>
850+
* <li>`targetResources`
851+
* </ul>
849852
* <p>Examples:
850853
* <ul>
851854
* <li>`stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED`
@@ -857,8 +860,13 @@ public final ListRecommendationsPagedResponse listRecommendations(String parent)
857860
* <li>`priority = P1 OR priority = P2`
858861
* </ul>
859862
* <ul>
863+
* <li>`targetResources :
864+
* //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1`
865+
* </ul>
866+
* <ul>
860867
* <li>`stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)`
861868
* </ul>
869+
* <p>The max allowed filter length is 500 characters.
862870
* <p>(These expressions are based on the filter language described at
863871
* https://google.aip.dev/160)
864872
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
@@ -930,6 +938,9 @@ public final ListRecommendationsPagedResponse listRecommendations(
930938
* <ul>
931939
* <li>`priority`
932940
* </ul>
941+
* <ul>
942+
* <li>`targetResources`
943+
* </ul>
933944
* <p>Examples:
934945
* <ul>
935946
* <li>`stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED`
@@ -941,8 +952,13 @@ public final ListRecommendationsPagedResponse listRecommendations(
941952
* <li>`priority = P1 OR priority = P2`
942953
* </ul>
943954
* <ul>
955+
* <li>`targetResources :
956+
* //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1`
957+
* </ul>
958+
* <ul>
944959
* <li>`stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)`
945960
* </ul>
961+
* <p>The max allowed filter length is 500 characters.
946962
* <p>(These expressions are based on the filter language described at
947963
* https://google.aip.dev/160)
948964
* @throws com.google.api.gax.rpc.ApiException if the remote call fails

java-recommender/proto-google-cloud-recommender-v1/src/main/java/com/google/cloud/recommender/v1/CostProjection.java

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,56 @@ public com.google.protobuf.DurationOrBuilder getDurationOrBuilder() {
167167
return duration_ == null ? com.google.protobuf.Duration.getDefaultInstance() : duration_;
168168
}
169169

170+
public static final int COST_IN_LOCAL_CURRENCY_FIELD_NUMBER = 3;
171+
private com.google.type.Money costInLocalCurrency_;
172+
/**
173+
*
174+
*
175+
* <pre>
176+
* The approximate cost savings in the billing account's local currency.
177+
* </pre>
178+
*
179+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
180+
*
181+
* @return Whether the costInLocalCurrency field is set.
182+
*/
183+
@java.lang.Override
184+
public boolean hasCostInLocalCurrency() {
185+
return costInLocalCurrency_ != null;
186+
}
187+
/**
188+
*
189+
*
190+
* <pre>
191+
* The approximate cost savings in the billing account's local currency.
192+
* </pre>
193+
*
194+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
195+
*
196+
* @return The costInLocalCurrency.
197+
*/
198+
@java.lang.Override
199+
public com.google.type.Money getCostInLocalCurrency() {
200+
return costInLocalCurrency_ == null
201+
? com.google.type.Money.getDefaultInstance()
202+
: costInLocalCurrency_;
203+
}
204+
/**
205+
*
206+
*
207+
* <pre>
208+
* The approximate cost savings in the billing account's local currency.
209+
* </pre>
210+
*
211+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
212+
*/
213+
@java.lang.Override
214+
public com.google.type.MoneyOrBuilder getCostInLocalCurrencyOrBuilder() {
215+
return costInLocalCurrency_ == null
216+
? com.google.type.Money.getDefaultInstance()
217+
: costInLocalCurrency_;
218+
}
219+
170220
private byte memoizedIsInitialized = -1;
171221

172222
@java.lang.Override
@@ -187,6 +237,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io
187237
if (duration_ != null) {
188238
output.writeMessage(2, getDuration());
189239
}
240+
if (costInLocalCurrency_ != null) {
241+
output.writeMessage(3, getCostInLocalCurrency());
242+
}
190243
getUnknownFields().writeTo(output);
191244
}
192245

@@ -202,6 +255,9 @@ public int getSerializedSize() {
202255
if (duration_ != null) {
203256
size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getDuration());
204257
}
258+
if (costInLocalCurrency_ != null) {
259+
size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getCostInLocalCurrency());
260+
}
205261
size += getUnknownFields().getSerializedSize();
206262
memoizedSize = size;
207263
return size;
@@ -226,6 +282,10 @@ public boolean equals(final java.lang.Object obj) {
226282
if (hasDuration()) {
227283
if (!getDuration().equals(other.getDuration())) return false;
228284
}
285+
if (hasCostInLocalCurrency() != other.hasCostInLocalCurrency()) return false;
286+
if (hasCostInLocalCurrency()) {
287+
if (!getCostInLocalCurrency().equals(other.getCostInLocalCurrency())) return false;
288+
}
229289
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
230290
return true;
231291
}
@@ -245,6 +305,10 @@ public int hashCode() {
245305
hash = (37 * hash) + DURATION_FIELD_NUMBER;
246306
hash = (53 * hash) + getDuration().hashCode();
247307
}
308+
if (hasCostInLocalCurrency()) {
309+
hash = (37 * hash) + COST_IN_LOCAL_CURRENCY_FIELD_NUMBER;
310+
hash = (53 * hash) + getCostInLocalCurrency().hashCode();
311+
}
248312
hash = (29 * hash) + getUnknownFields().hashCode();
249313
memoizedHashCode = hash;
250314
return hash;
@@ -394,6 +458,11 @@ public Builder clear() {
394458
durationBuilder_.dispose();
395459
durationBuilder_ = null;
396460
}
461+
costInLocalCurrency_ = null;
462+
if (costInLocalCurrencyBuilder_ != null) {
463+
costInLocalCurrencyBuilder_.dispose();
464+
costInLocalCurrencyBuilder_ = null;
465+
}
397466
return this;
398467
}
399468

@@ -436,6 +505,12 @@ private void buildPartial0(com.google.cloud.recommender.v1.CostProjection result
436505
if (((from_bitField0_ & 0x00000002) != 0)) {
437506
result.duration_ = durationBuilder_ == null ? duration_ : durationBuilder_.build();
438507
}
508+
if (((from_bitField0_ & 0x00000004) != 0)) {
509+
result.costInLocalCurrency_ =
510+
costInLocalCurrencyBuilder_ == null
511+
? costInLocalCurrency_
512+
: costInLocalCurrencyBuilder_.build();
513+
}
439514
}
440515

441516
@java.lang.Override
@@ -489,6 +564,9 @@ public Builder mergeFrom(com.google.cloud.recommender.v1.CostProjection other) {
489564
if (other.hasDuration()) {
490565
mergeDuration(other.getDuration());
491566
}
567+
if (other.hasCostInLocalCurrency()) {
568+
mergeCostInLocalCurrency(other.getCostInLocalCurrency());
569+
}
492570
this.mergeUnknownFields(other.getUnknownFields());
493571
onChanged();
494572
return this;
@@ -527,6 +605,13 @@ public Builder mergeFrom(
527605
bitField0_ |= 0x00000002;
528606
break;
529607
} // case 18
608+
case 26:
609+
{
610+
input.readMessage(
611+
getCostInLocalCurrencyFieldBuilder().getBuilder(), extensionRegistry);
612+
bitField0_ |= 0x00000004;
613+
break;
614+
} // case 26
530615
default:
531616
{
532617
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
@@ -944,6 +1029,185 @@ public com.google.protobuf.DurationOrBuilder getDurationOrBuilder() {
9441029
return durationBuilder_;
9451030
}
9461031

1032+
private com.google.type.Money costInLocalCurrency_;
1033+
private com.google.protobuf.SingleFieldBuilderV3<
1034+
com.google.type.Money, com.google.type.Money.Builder, com.google.type.MoneyOrBuilder>
1035+
costInLocalCurrencyBuilder_;
1036+
/**
1037+
*
1038+
*
1039+
* <pre>
1040+
* The approximate cost savings in the billing account's local currency.
1041+
* </pre>
1042+
*
1043+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
1044+
*
1045+
* @return Whether the costInLocalCurrency field is set.
1046+
*/
1047+
public boolean hasCostInLocalCurrency() {
1048+
return ((bitField0_ & 0x00000004) != 0);
1049+
}
1050+
/**
1051+
*
1052+
*
1053+
* <pre>
1054+
* The approximate cost savings in the billing account's local currency.
1055+
* </pre>
1056+
*
1057+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
1058+
*
1059+
* @return The costInLocalCurrency.
1060+
*/
1061+
public com.google.type.Money getCostInLocalCurrency() {
1062+
if (costInLocalCurrencyBuilder_ == null) {
1063+
return costInLocalCurrency_ == null
1064+
? com.google.type.Money.getDefaultInstance()
1065+
: costInLocalCurrency_;
1066+
} else {
1067+
return costInLocalCurrencyBuilder_.getMessage();
1068+
}
1069+
}
1070+
/**
1071+
*
1072+
*
1073+
* <pre>
1074+
* The approximate cost savings in the billing account's local currency.
1075+
* </pre>
1076+
*
1077+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
1078+
*/
1079+
public Builder setCostInLocalCurrency(com.google.type.Money value) {
1080+
if (costInLocalCurrencyBuilder_ == null) {
1081+
if (value == null) {
1082+
throw new NullPointerException();
1083+
}
1084+
costInLocalCurrency_ = value;
1085+
} else {
1086+
costInLocalCurrencyBuilder_.setMessage(value);
1087+
}
1088+
bitField0_ |= 0x00000004;
1089+
onChanged();
1090+
return this;
1091+
}
1092+
/**
1093+
*
1094+
*
1095+
* <pre>
1096+
* The approximate cost savings in the billing account's local currency.
1097+
* </pre>
1098+
*
1099+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
1100+
*/
1101+
public Builder setCostInLocalCurrency(com.google.type.Money.Builder builderForValue) {
1102+
if (costInLocalCurrencyBuilder_ == null) {
1103+
costInLocalCurrency_ = builderForValue.build();
1104+
} else {
1105+
costInLocalCurrencyBuilder_.setMessage(builderForValue.build());
1106+
}
1107+
bitField0_ |= 0x00000004;
1108+
onChanged();
1109+
return this;
1110+
}
1111+
/**
1112+
*
1113+
*
1114+
* <pre>
1115+
* The approximate cost savings in the billing account's local currency.
1116+
* </pre>
1117+
*
1118+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
1119+
*/
1120+
public Builder mergeCostInLocalCurrency(com.google.type.Money value) {
1121+
if (costInLocalCurrencyBuilder_ == null) {
1122+
if (((bitField0_ & 0x00000004) != 0)
1123+
&& costInLocalCurrency_ != null
1124+
&& costInLocalCurrency_ != com.google.type.Money.getDefaultInstance()) {
1125+
getCostInLocalCurrencyBuilder().mergeFrom(value);
1126+
} else {
1127+
costInLocalCurrency_ = value;
1128+
}
1129+
} else {
1130+
costInLocalCurrencyBuilder_.mergeFrom(value);
1131+
}
1132+
bitField0_ |= 0x00000004;
1133+
onChanged();
1134+
return this;
1135+
}
1136+
/**
1137+
*
1138+
*
1139+
* <pre>
1140+
* The approximate cost savings in the billing account's local currency.
1141+
* </pre>
1142+
*
1143+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
1144+
*/
1145+
public Builder clearCostInLocalCurrency() {
1146+
bitField0_ = (bitField0_ & ~0x00000004);
1147+
costInLocalCurrency_ = null;
1148+
if (costInLocalCurrencyBuilder_ != null) {
1149+
costInLocalCurrencyBuilder_.dispose();
1150+
costInLocalCurrencyBuilder_ = null;
1151+
}
1152+
onChanged();
1153+
return this;
1154+
}
1155+
/**
1156+
*
1157+
*
1158+
* <pre>
1159+
* The approximate cost savings in the billing account's local currency.
1160+
* </pre>
1161+
*
1162+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
1163+
*/
1164+
public com.google.type.Money.Builder getCostInLocalCurrencyBuilder() {
1165+
bitField0_ |= 0x00000004;
1166+
onChanged();
1167+
return getCostInLocalCurrencyFieldBuilder().getBuilder();
1168+
}
1169+
/**
1170+
*
1171+
*
1172+
* <pre>
1173+
* The approximate cost savings in the billing account's local currency.
1174+
* </pre>
1175+
*
1176+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
1177+
*/
1178+
public com.google.type.MoneyOrBuilder getCostInLocalCurrencyOrBuilder() {
1179+
if (costInLocalCurrencyBuilder_ != null) {
1180+
return costInLocalCurrencyBuilder_.getMessageOrBuilder();
1181+
} else {
1182+
return costInLocalCurrency_ == null
1183+
? com.google.type.Money.getDefaultInstance()
1184+
: costInLocalCurrency_;
1185+
}
1186+
}
1187+
/**
1188+
*
1189+
*
1190+
* <pre>
1191+
* The approximate cost savings in the billing account's local currency.
1192+
* </pre>
1193+
*
1194+
* <code>.google.type.Money cost_in_local_currency = 3;</code>
1195+
*/
1196+
private com.google.protobuf.SingleFieldBuilderV3<
1197+
com.google.type.Money, com.google.type.Money.Builder, com.google.type.MoneyOrBuilder>
1198+
getCostInLocalCurrencyFieldBuilder() {
1199+
if (costInLocalCurrencyBuilder_ == null) {
1200+
costInLocalCurrencyBuilder_ =
1201+
new com.google.protobuf.SingleFieldBuilderV3<
1202+
com.google.type.Money,
1203+
com.google.type.Money.Builder,
1204+
com.google.type.MoneyOrBuilder>(
1205+
getCostInLocalCurrency(), getParentForChildren(), isClean());
1206+
costInLocalCurrency_ = null;
1207+
}
1208+
return costInLocalCurrencyBuilder_;
1209+
}
1210+
9471211
@java.lang.Override
9481212
public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
9491213
return super.setUnknownFields(unknownFields);

0 commit comments

Comments
 (0)