19
19
import com .google .api .gax .longrunning .OperationFuture ;
20
20
import com .google .api .gax .paging .Page ;
21
21
import com .google .cloud .Policy ;
22
+ import com .google .cloud .spanner .Options .CreateAdminApiOption ;
23
+ import com .google .cloud .spanner .Options .DeleteAdminApiOption ;
22
24
import com .google .cloud .spanner .Options .ListOption ;
25
+ import com .google .cloud .spanner .Options .UpdateAdminApiOption ;
23
26
import com .google .longrunning .Operation ;
27
+ import com .google .spanner .admin .instance .v1 .CreateInstanceConfigMetadata ;
24
28
import com .google .spanner .admin .instance .v1 .CreateInstanceMetadata ;
29
+ import com .google .spanner .admin .instance .v1 .UpdateInstanceConfigMetadata ;
25
30
import com .google .spanner .admin .instance .v1 .UpdateInstanceMetadata ;
26
31
27
32
/** Client to do admin operations on Cloud Spanner Instance and Instance Configs. */
28
33
public interface InstanceAdminClient {
29
34
35
+ /**
36
+ * Creates an instance config and begins preparing it to be used. The returned {@code Operation}
37
+ * can be used to track the progress of preparing the new instance config. The instance config
38
+ * name is assigned by the caller and must start with the string 'custom'. If the named instance
39
+ * config already exists, a SpannerException is thrown.
40
+ *
41
+ * <p>Immediately after the request returns:
42
+ *
43
+ * <ul>
44
+ * <li>The instance config is readable via the API, with all requested attributes.
45
+ * <li>The instance config's {@code reconciling} field is set to true. Its state is {@code
46
+ * CREATING}.
47
+ * </ul>
48
+ *
49
+ * While the operation is pending:
50
+ *
51
+ * <ul>
52
+ * <li>Cancelling the operation renders the instance config immediately unreadable via the API.
53
+ * <li>Except for deleting the creating resource, all other attempts to modify the instance
54
+ * config are rejected.
55
+ * </ul>
56
+ *
57
+ * Upon completion of the returned operation:
58
+ *
59
+ * <ul>
60
+ * <li>Instances can be created using the instance configuration.
61
+ * <li>The instance config's {@code reconciling} field becomes false.
62
+ * <li>Its state becomes {@code READY}.
63
+ * </ul>
64
+ *
65
+ * <!--SNIPPET instance_admin_client_create_instance_config-->
66
+ *
67
+ * <pre>{@code
68
+ * String projectId = "my-project";
69
+ * String baseInstanceConfig = "my-base-config";
70
+ * String instanceConfigId = "custom-user-config";
71
+ *
72
+ * final InstanceConfig baseConfig = instanceAdminClient.getInstanceConfig(baseInstanceConfig);
73
+ *
74
+ * List<ReplicaInfo> readOnlyReplicas = ImmutableList.of(baseConfig.getOptionalReplicas().get(0));
75
+ *
76
+ * InstanceConfigInfo instanceConfigInfo =
77
+ * InstanceConfigInfo.newBuilder(InstanceConfigId.of(projectId, instanceConfigId), baseConfig)
78
+ * .setDisplayName(instanceConfigId)
79
+ * .addReadOnlyReplicas(readOnlyReplicas)
80
+ * .build();
81
+ *
82
+ * final OperationFuture<InstanceConfig, CreateInstanceConfigMetadata> operation =
83
+ * instanceAdminClient.createInstanceConfig(instanceConfigInfo);
84
+ *
85
+ * InstanceConfig instanceConfig = op.get(5, TimeUnit.MINUTES)
86
+ * }</pre>
87
+ *
88
+ * <!--SNIPPET instance_admin_client_create_instance_config-->
89
+ */
90
+ default OperationFuture <InstanceConfig , CreateInstanceConfigMetadata > createInstanceConfig (
91
+ InstanceConfigInfo instanceConfig , CreateAdminApiOption ... options ) throws SpannerException {
92
+ throw new UnsupportedOperationException ("Not implemented" );
93
+ }
94
+
95
+ /**
96
+ * Updates a custom instance config. This can not be used to update a Google managed instance
97
+ * config. The returned {@code Operation} can be used to track the progress of updating the
98
+ * instance. If the named instance config does not exist, a SpannerException is thrown. The
99
+ * request must include at least one field to update.
100
+ *
101
+ * <p>Only user managed configurations can be updated.
102
+ *
103
+ * <p>Immediately after the request returns:
104
+ *
105
+ * <ul>
106
+ * <li>The instance config's {@code reconciling} field is set to true.
107
+ * </ul>
108
+ *
109
+ * While the operation is pending:
110
+ *
111
+ * <ul>
112
+ * <li>Cancelling the operation sets its metadata's cancel_time.
113
+ * <li>The operation is guaranteed to succeed at undoing all changes, after which point it
114
+ * terminates with a `CANCELLED` status.
115
+ * <li>All other attempts to modify the instance config are rejected.
116
+ * <li>Reading the instance config via the API continues to give the pre-request values.
117
+ * </ul>
118
+ *
119
+ * Upon completion of the returned operation:
120
+ *
121
+ * <ul>
122
+ * <li>Creating instances using the instance configuration uses the new values.
123
+ * <li>The instance config's new values are readable via the API.
124
+ * <li>The instance config's {@code reconciling} field becomes false.
125
+ * </ul>
126
+ *
127
+ * <!--SNIPPET instance_admin_client_update_instance_config-->
128
+ *
129
+ * <pre>{@code
130
+ * String projectId = "my-project";
131
+ * String instanceConfigId = "custom-user-config";
132
+ * String displayName = "my-display-name";
133
+ *
134
+ * InstanceConfigInfo instanceConfigInfo =
135
+ * InstanceConfigInfo.newBuilder(InstanceConfigId.of(projectId, instanceConfigId))
136
+ * .setDisplayName(displayName)
137
+ * .build();
138
+ *
139
+ * // Only update display name.
140
+ * final OperationFuture<InstanceConfig, UpdateInstanceConfigMetadata> operation =
141
+ * instanceAdminClient.updateInstanceConfig(
142
+ * instanceConfigInfo, ImmutableList.of(InstanceConfigField.DISPLAY_NAME));
143
+ *
144
+ * InstanceConfig instanceConfig = operation.get(5, TimeUnit.MINUTES);
145
+ * }</pre>
146
+ *
147
+ * <!--SNIPPET instance_admin_client_update_instance_config-->
148
+ */
149
+ default OperationFuture <InstanceConfig , UpdateInstanceConfigMetadata > updateInstanceConfig (
150
+ InstanceConfigInfo instanceConfig ,
151
+ Iterable <InstanceConfigInfo .InstanceConfigField > fieldsToUpdate ,
152
+ UpdateAdminApiOption ... options )
153
+ throws SpannerException {
154
+ throw new UnsupportedOperationException ("Not implemented" );
155
+ }
156
+
30
157
/** Gets an instance config. */
31
158
/* <!--SNIPPET instance_admin_client_get_instance_config-->
32
159
* <pre>{@code
@@ -37,6 +164,28 @@ public interface InstanceAdminClient {
37
164
*/
38
165
InstanceConfig getInstanceConfig (String configId ) throws SpannerException ;
39
166
167
+ /**
168
+ * Deletes a custom instance config. Deletion is only allowed for custom instance configs and when
169
+ * no instances are using the configuration. If any instances are using the config, a
170
+ * SpannerException is thrown.
171
+ *
172
+ * <p>Only user managed configurations can be deleted.
173
+ * <!--SNIPPET instance_admin_client_delete_instance_config-->
174
+ *
175
+ * <pre>{@code
176
+ * String projectId = "my-project";
177
+ * String instanceConfigId = "custom-user-config";
178
+ *
179
+ * instanceAdminClient.deleteInstanceConfig(instanceConfigId);
180
+ * }</pre>
181
+ *
182
+ * <!--SNIPPET instance_admin_client_delete_instance_config-->
183
+ */
184
+ default void deleteInstanceConfig (String instanceConfigId , DeleteAdminApiOption ... options )
185
+ throws SpannerException {
186
+ throw new UnsupportedOperationException ("Not implemented" );
187
+ }
188
+
40
189
/** Lists the supported instance configs for current project. */
41
190
/* <!--SNIPPET instance_admin_client_list_configs-->
42
191
* <pre>{@code
@@ -47,6 +196,11 @@ public interface InstanceAdminClient {
47
196
*/
48
197
Page <InstanceConfig > listInstanceConfigs (ListOption ... options ) throws SpannerException ;
49
198
199
+ /** Lists long-running instance config operations. */
200
+ default Page <Operation > listInstanceConfigOperations (ListOption ... options ) {
201
+ throw new UnsupportedOperationException ("Not implemented" );
202
+ }
203
+
50
204
/**
51
205
* Creates an instance and begins preparing it to begin serving. The returned {@code Operation}
52
206
* can be used to track the progress of preparing the new instance. The instance name is assigned
0 commit comments