/** * Helper method to construct the table name in format: * projects/{project}/instances/{instance}/tables/{tableId} */ private String getTableName(String tableId) { return NameUtil.formatTableName(projectId, instanceId, tableId); }
public static String formatAppProfileName( String projectId, String instanceId, String appProfileId) { return formatInstanceName(projectId, instanceId) + "/appProfiles/" + appProfileId; } }
public static String formatInstanceName(String projectId, String instanceId) { return formatProjectName(projectId) + "/instances/" + instanceId; }
/** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. */ @InternalApi public com.google.bigtable.admin.v2.CreateClusterRequest toProto(String projectId) { proto.setParent(NameUtil.formatInstanceName(projectId, instanceId)); proto.getClusterBuilder().setLocation(NameUtil.formatLocationName(projectId, zone)); return proto.build(); }
/** * Creates the request protobuf to be used in {@link CreateInstanceRequest}. This method is * considered an internal implementation detail and not meant to be used by applications. * * <p>This method is considered an internal implementation detail and not meant to be used by * applications. */ @InternalApi com.google.bigtable.admin.v2.Cluster toEmbeddedProto(String projectId) { proto.getClusterBuilder().setLocation(NameUtil.formatLocationName(projectId, zone)); return proto.getClusterBuilder().build(); } }
/** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. */ @InternalApi public com.google.bigtable.admin.v2.UpdateAppProfileRequest toProto(String projectId) { String name = NameUtil.formatAppProfileName(projectId, instanceId, appProfileId); proto.getAppProfileBuilder().setName(name); return proto.build(); }
public static void checkDeprecatedArtifactUse() { if (isDeprecationMarkerPresent()) { LOGGER.warning( "google-cloud-bigtable-admin has been merged into google-cloud-bigtable." + " Please update your build file to stop depending on google-cloud-bigtable-admin" + " and use google-cloud-bigtable directly."); } }
@Override public List<String> apply(List<com.google.bigtable.admin.v2.Table> protos) { List<String> results = Lists.newArrayListWithCapacity(protos.size()); for (com.google.bigtable.admin.v2.Table proto : protos) { results.add(NameUtil.extractTableIdFromTableName(proto.getName())); } return results; } },
@Override public List<Instance> apply(com.google.bigtable.admin.v2.ListInstancesResponse proto) { // NOTE: pagination is intentionally ignored. The server does not implement it and never // will. Verify.verify( proto.getNextPageToken().isEmpty(), "Server returned an unexpected paginated response"); ImmutableList.Builder<Instance> instances = ImmutableList.builder(); for (com.google.bigtable.admin.v2.Instance protoInstance : proto.getInstancesList()) { instances.add(Instance.fromProto(protoInstance)); } ImmutableList.Builder<String> failedZones = ImmutableList.builder(); for (String locationStr : proto.getFailedLocationsList()) { failedZones.add(NameUtil.extractZoneIdFromLocationName(locationStr)); } if (!failedZones.build().isEmpty()) { throw new PartialListInstancesException(failedZones.build(), instances.build()); } return instances.build(); } },
/** * Asynchronously gets the cluster representation by ID. * * <p>Sample code: * * <pre>{@code * ApiFuture<Cluster> clusterFuture = client.getClusterAsync("my-instance", "my-cluster"); * Cluster cluster = clusterFuture.get(); * }</pre> */ @SuppressWarnings("WeakerAccess") public ApiFuture<Cluster> getClusterAsync(String instanceId, String clusterId) { String name = NameUtil.formatClusterName(projectId, instanceId, clusterId); com.google.bigtable.admin.v2.GetClusterRequest request = com.google.bigtable.admin.v2.GetClusterRequest.newBuilder().setName(name).build(); return ApiFutures.transform( stub.getClusterCallable().futureCall(request), new ApiFunction<com.google.bigtable.admin.v2.Cluster, Cluster>() { @Override public Cluster apply(com.google.bigtable.admin.v2.Cluster proto) { return Cluster.fromProto(proto); } }, MoreExecutors.directExecutor()); }
public static String formatTableName(String projectId, String instanceId, String tableId) { return formatInstanceName(projectId, instanceId) + "/tables/" + tableId; }
public static String formatLocationName(String projectId, String zone) { return formatProjectName(projectId) + "/locations/" + zone; }
@InternalApi public com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest toProto( @Nonnull String projectId, @Nonnull String instanceId) { Preconditions.checkNotNull(projectId, "Project id can't be null"); Preconditions.checkNotNull(instanceId, "Instance id can't be null"); String tableName = NameUtil.formatTableName(projectId, instanceId, tableId); return modFamilyRequest.setName(tableName).build(); } }
/** * Asynchronously deletes the specified app profile. * * <p>Sample code: * * <pre>{@code * ApiFuture<Void> deleteFuture = client.deleteAppProfileAsync("my-instance", "my-app-profile"); * * deleteFuture.get(); * }</pre> */ @SuppressWarnings("WeakerAccess") public ApiFuture<Void> deleteAppProfileAsync(String instanceId, String appProfileId) { String name = NameUtil.formatAppProfileName(projectId, instanceId, appProfileId); DeleteAppProfileRequest request = DeleteAppProfileRequest.newBuilder().setName(name).build(); return ApiFutures.transform( stub.deleteAppProfileCallable().futureCall(request), new ApiFunction<Empty, Void>() { @Override public Void apply(Empty input) { return null; } }, MoreExecutors.directExecutor()); }
public static String formatClusterName(String projectId, String instanceId, String clusterId) { return formatInstanceName(projectId, instanceId) + "/clusters/" + clusterId; }
/** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. */ @InternalApi public com.google.bigtable.admin.v2.CreateInstanceRequest toProto(String projectId) { builder.setParent(NameUtil.formatProjectName(projectId)).clearClusters(); for (CreateClusterRequest clusterRequest : clusterRequests) { builder.putClusters(clusterRequest.getClusterId(), clusterRequest.toEmbeddedProto(projectId)); } return builder.build(); } }
/** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. */ @InternalApi public com.google.bigtable.admin.v2.CreateAppProfileRequest toProto(String projectId) { String name = NameUtil.formatInstanceName(projectId, instanceId); return proto.setParent(name).build(); } }
@InternalApi public com.google.bigtable.admin.v2.CreateTableRequest toProto( @Nonnull String projectId, @Nonnull String instanceId) { Preconditions.checkNotNull(projectId); Preconditions.checkNotNull(instanceId); return createTableRequest .setParent(NameUtil.formatInstanceName(projectId, instanceId)) .setTable(tableRequest.build()) .build(); } }
/** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. */ @InternalApi public PartialUpdateInstanceRequest toProto(String projectId) { // Empty field mask implies full resource replacement, which would clear all fields in an empty // update request. Preconditions.checkState( !builder.getUpdateMask().getPathsList().isEmpty(), "Update request is empty"); builder.getInstanceBuilder().setName(NameUtil.formatInstanceName(projectId, instanceId)); return builder.build(); } }
/** * Asynchronously gets the instance representation by ID wrapped in a future. * * <p>Sample code: * * <pre>{@code * ApiFuture<Instance> instanceFuture = client.getInstanceAsync("my-instance"); * Instance instance = instanceFuture.get(); * }</pre> */ @SuppressWarnings("WeakerAccess") public ApiFuture<Instance> getInstanceAsync(String instanceId) { String name = NameUtil.formatInstanceName(projectId, instanceId); com.google.bigtable.admin.v2.GetInstanceRequest request = com.google.bigtable.admin.v2.GetInstanceRequest.newBuilder().setName(name).build(); return ApiFutures.transform( stub.getInstanceCallable().futureCall(request), new ApiFunction<com.google.bigtable.admin.v2.Instance, Instance>() { @Override public Instance apply(com.google.bigtable.admin.v2.Instance proto) { return Instance.fromProto(proto); } }, MoreExecutors.directExecutor()); }