Skip to content

Commit

Permalink
feat: [cloudbilling] added the MoveBillingAccount method, which allow…
Browse files Browse the repository at this point in the history
…s changing which organization a billing account belongs to (#10115)

* feat: added the MoveBillingAccount method, which allows changing which organization a billing account belongs to
feat: added field BillingAccount.parent
build: do not use common_resources.proto for Billing v1 API

The change to BUILD.bazel should not affect any library users.
We will define Project and Organization resources in the Billing proto
instead of the common proto file.

PiperOrigin-RevId: 588132546

Source-Link: googleapis/googleapis@3ab9a05

Source-Link: googleapis/googleapis-gen@6cdd705
Copy-Tag: eyJwIjoiamF2YS1iaWxsaW5nLy5Pd2xCb3QueWFtbCIsImgiOiI2Y2RkNzA1YzFkYTlkYTRjMzBmZTQ2MTk0YTAyNzljZWQ3MjJjYzU0In0=

* 🦉 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Jan 2, 2024
1 parent 003e683 commit 615854d
Show file tree
Hide file tree
Showing 60 changed files with 3,355 additions and 205 deletions.
2 changes: 1 addition & 1 deletion java-billing/README.md
Expand Up @@ -195,7 +195,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-billing.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-billing/2.30.0
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-billing/2.31.0
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -141,6 +141,11 @@ public UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings() {
return ((CloudBillingStubSettings) getStubSettings()).testIamPermissionsSettings();
}

/** Returns the object with the settings used for calls to moveBillingAccount. */
public UnaryCallSettings<MoveBillingAccountRequest, BillingAccount> moveBillingAccountSettings() {
return ((CloudBillingStubSettings) getStubSettings()).moveBillingAccountSettings();
}

public static final CloudBillingSettings create(CloudBillingStubSettings stub)
throws IOException {
return new CloudBillingSettings.Builder(stub.toBuilder()).build();
Expand Down Expand Up @@ -320,6 +325,12 @@ public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettin
return getStubSettingsBuilder().testIamPermissionsSettings();
}

/** Returns the builder for the settings used for calls to moveBillingAccount. */
public UnaryCallSettings.Builder<MoveBillingAccountRequest, BillingAccount>
moveBillingAccountSettings() {
return getStubSettingsBuilder().moveBillingAccountSettings();
}

@Override
public CloudBillingSettings build() throws IOException {
return new CloudBillingSettings(this);
Expand Down
Expand Up @@ -11,7 +11,7 @@
"libraryClient": "CloudBillingClient",
"rpcs": {
"CreateBillingAccount": {
"methods": ["createBillingAccount", "createBillingAccount", "createBillingAccountCallable"]
"methods": ["createBillingAccount", "createBillingAccount", "createBillingAccount", "createBillingAccountCallable"]
},
"GetBillingAccount": {
"methods": ["getBillingAccount", "getBillingAccount", "getBillingAccount", "getBillingAccountCallable"]
Expand All @@ -23,11 +23,14 @@
"methods": ["getProjectBillingInfo", "getProjectBillingInfo", "getProjectBillingInfo", "getProjectBillingInfoCallable"]
},
"ListBillingAccounts": {
"methods": ["listBillingAccounts", "listBillingAccounts", "listBillingAccountsPagedCallable", "listBillingAccountsCallable"]
"methods": ["listBillingAccounts", "listBillingAccounts", "listBillingAccounts", "listBillingAccountsPagedCallable", "listBillingAccountsCallable"]
},
"ListProjectBillingInfo": {
"methods": ["listProjectBillingInfo", "listProjectBillingInfo", "listProjectBillingInfo", "listProjectBillingInfoPagedCallable", "listProjectBillingInfoCallable"]
},
"MoveBillingAccount": {
"methods": ["moveBillingAccount", "moveBillingAccountCallable"]
},
"SetIamPolicy": {
"methods": ["setIamPolicy", "setIamPolicy", "setIamPolicy", "setIamPolicyCallable"]
},
Expand Down
Expand Up @@ -33,7 +33,7 @@
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
* BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]");
* BillingAccountName name = BillingAccountName.ofBillingAccountName("[BILLING_ACCOUNT]");
* BillingAccount response = cloudBillingClient.getBillingAccount(name);
* }
* }</pre>
Expand Down
Expand Up @@ -29,6 +29,7 @@
import com.google.cloud.billing.v1.ListBillingAccountsResponse;
import com.google.cloud.billing.v1.ListProjectBillingInfoRequest;
import com.google.cloud.billing.v1.ListProjectBillingInfoResponse;
import com.google.cloud.billing.v1.MoveBillingAccountRequest;
import com.google.cloud.billing.v1.ProjectBillingInfo;
import com.google.cloud.billing.v1.UpdateBillingAccountRequest;
import com.google.cloud.billing.v1.UpdateProjectBillingInfoRequest;
Expand Down Expand Up @@ -104,6 +105,10 @@ public UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
throw new UnsupportedOperationException("Not implemented: testIamPermissionsCallable()");
}

public UnaryCallable<MoveBillingAccountRequest, BillingAccount> moveBillingAccountCallable() {
throw new UnsupportedOperationException("Not implemented: moveBillingAccountCallable()");
}

@Override
public abstract void close();
}
Expand Up @@ -52,6 +52,7 @@
import com.google.cloud.billing.v1.ListBillingAccountsResponse;
import com.google.cloud.billing.v1.ListProjectBillingInfoRequest;
import com.google.cloud.billing.v1.ListProjectBillingInfoResponse;
import com.google.cloud.billing.v1.MoveBillingAccountRequest;
import com.google.cloud.billing.v1.ProjectBillingInfo;
import com.google.cloud.billing.v1.UpdateBillingAccountRequest;
import com.google.cloud.billing.v1.UpdateProjectBillingInfoRequest;
Expand Down Expand Up @@ -138,6 +139,8 @@ public class CloudBillingStubSettings extends StubSettings<CloudBillingStubSetti
private final UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings;
private final UnaryCallSettings<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsSettings;
private final UnaryCallSettings<MoveBillingAccountRequest, BillingAccount>
moveBillingAccountSettings;

private static final PagedListDescriptor<
ListBillingAccountsRequest, ListBillingAccountsResponse, BillingAccount>
Expand Down Expand Up @@ -331,6 +334,11 @@ public UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings() {
return testIamPermissionsSettings;
}

/** Returns the object with the settings used for calls to moveBillingAccount. */
public UnaryCallSettings<MoveBillingAccountRequest, BillingAccount> moveBillingAccountSettings() {
return moveBillingAccountSettings;
}

public CloudBillingStub createStub() throws IOException {
if (getTransportChannelProvider()
.getTransportName()
Expand Down Expand Up @@ -447,6 +455,7 @@ protected CloudBillingStubSettings(Builder settingsBuilder) throws IOException {
getIamPolicySettings = settingsBuilder.getIamPolicySettings().build();
setIamPolicySettings = settingsBuilder.setIamPolicySettings().build();
testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build();
moveBillingAccountSettings = settingsBuilder.moveBillingAccountSettings().build();
}

/** Builder for CloudBillingStubSettings. */
Expand Down Expand Up @@ -476,6 +485,8 @@ public static class Builder extends StubSettings.Builder<CloudBillingStubSetting
private final UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettings;
private final UnaryCallSettings.Builder<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsSettings;
private final UnaryCallSettings.Builder<MoveBillingAccountRequest, BillingAccount>
moveBillingAccountSettings;
private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
RETRYABLE_CODE_DEFINITIONS;

Expand All @@ -489,6 +500,7 @@ public static class Builder extends StubSettings.Builder<CloudBillingStubSetting
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
definitions.put(
"no_retry_0_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}

Expand Down Expand Up @@ -516,6 +528,8 @@ public static class Builder extends StubSettings.Builder<CloudBillingStubSetting
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("no_retry_0_params", settings);
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
definitions.put("no_retry_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand All @@ -538,6 +552,7 @@ protected Builder(ClientContext clientContext) {
getIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
setIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
testIamPermissionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
moveBillingAccountSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
Expand All @@ -550,7 +565,8 @@ protected Builder(ClientContext clientContext) {
updateProjectBillingInfoSettings,
getIamPolicySettings,
setIamPolicySettings,
testIamPermissionsSettings);
testIamPermissionsSettings,
moveBillingAccountSettings);
initDefaults(this);
}

Expand All @@ -567,6 +583,7 @@ protected Builder(CloudBillingStubSettings settings) {
getIamPolicySettings = settings.getIamPolicySettings.toBuilder();
setIamPolicySettings = settings.setIamPolicySettings.toBuilder();
testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder();
moveBillingAccountSettings = settings.moveBillingAccountSettings.toBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
Expand All @@ -579,7 +596,8 @@ protected Builder(CloudBillingStubSettings settings) {
updateProjectBillingInfoSettings,
getIamPolicySettings,
setIamPolicySettings,
testIamPermissionsSettings);
testIamPermissionsSettings,
moveBillingAccountSettings);
}

private static Builder createDefault() {
Expand Down Expand Up @@ -659,6 +677,11 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.moveBillingAccountSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));

return builder;
}

Expand Down Expand Up @@ -741,6 +764,12 @@ public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettin
return testIamPermissionsSettings;
}

/** Returns the builder for the settings used for calls to moveBillingAccount. */
public UnaryCallSettings.Builder<MoveBillingAccountRequest, BillingAccount>
moveBillingAccountSettings() {
return moveBillingAccountSettings;
}

@Override
public CloudBillingStubSettings build() throws IOException {
return new CloudBillingStubSettings(this);
Expand Down
Expand Up @@ -34,6 +34,7 @@
import com.google.cloud.billing.v1.ListBillingAccountsResponse;
import com.google.cloud.billing.v1.ListProjectBillingInfoRequest;
import com.google.cloud.billing.v1.ListProjectBillingInfoResponse;
import com.google.cloud.billing.v1.MoveBillingAccountRequest;
import com.google.cloud.billing.v1.ProjectBillingInfo;
import com.google.cloud.billing.v1.UpdateBillingAccountRequest;
import com.google.cloud.billing.v1.UpdateProjectBillingInfoRequest;
Expand Down Expand Up @@ -158,6 +159,16 @@ public class GrpcCloudBillingStub extends CloudBillingStub {
ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<MoveBillingAccountRequest, BillingAccount>
moveBillingAccountMethodDescriptor =
MethodDescriptor.<MoveBillingAccountRequest, BillingAccount>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.billing.v1.CloudBilling/MoveBillingAccount")
.setRequestMarshaller(
ProtoUtils.marshaller(MoveBillingAccountRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(BillingAccount.getDefaultInstance()))
.build();

private final UnaryCallable<GetBillingAccountRequest, BillingAccount> getBillingAccountCallable;
private final UnaryCallable<ListBillingAccountsRequest, ListBillingAccountsResponse>
listBillingAccountsCallable;
Expand All @@ -179,6 +190,7 @@ public class GrpcCloudBillingStub extends CloudBillingStub {
private final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable;
private final UnaryCallable<TestIamPermissionsRequest, TestIamPermissionsResponse>
testIamPermissionsCallable;
private final UnaryCallable<MoveBillingAccountRequest, BillingAccount> moveBillingAccountCallable;

private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
Expand Down Expand Up @@ -236,6 +248,12 @@ protected GrpcCloudBillingStub(
listBillingAccountsTransportSettings =
GrpcCallSettings.<ListBillingAccountsRequest, ListBillingAccountsResponse>newBuilder()
.setMethodDescriptor(listBillingAccountsMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings<UpdateBillingAccountRequest, BillingAccount>
updateBillingAccountTransportSettings =
Expand All @@ -252,6 +270,12 @@ protected GrpcCloudBillingStub(
createBillingAccountTransportSettings =
GrpcCallSettings.<CreateBillingAccountRequest, BillingAccount>newBuilder()
.setMethodDescriptor(createBillingAccountMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
GrpcCallSettings<ListProjectBillingInfoRequest, ListProjectBillingInfoResponse>
listProjectBillingInfoTransportSettings =
Expand Down Expand Up @@ -318,6 +342,19 @@ protected GrpcCloudBillingStub(
return builder.build();
})
.build();
GrpcCallSettings<MoveBillingAccountRequest, BillingAccount>
moveBillingAccountTransportSettings =
GrpcCallSettings.<MoveBillingAccountRequest, BillingAccount>newBuilder()
.setMethodDescriptor(moveBillingAccountMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"destination_parent", String.valueOf(request.getDestinationParent()));
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();

this.getBillingAccountCallable =
callableFactory.createUnaryCallable(
Expand Down Expand Up @@ -375,6 +412,11 @@ protected GrpcCloudBillingStub(
testIamPermissionsTransportSettings,
settings.testIamPermissionsSettings(),
clientContext);
this.moveBillingAccountCallable =
callableFactory.createUnaryCallable(
moveBillingAccountTransportSettings,
settings.moveBillingAccountSettings(),
clientContext);

this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
Expand Down Expand Up @@ -451,6 +493,11 @@ public UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
return testIamPermissionsCallable;
}

@Override
public UnaryCallable<MoveBillingAccountRequest, BillingAccount> moveBillingAccountCallable() {
return moveBillingAccountCallable;
}

@Override
public final void close() {
try {
Expand Down

0 comments on commit 615854d

Please sign in to comment.