0
# Service Management
1
2
Comprehensive lifecycle management for Dataproc Metastore services including creation, configuration, updates, and deletion. Supports multiple service tiers, Hive metastore versions, advanced networking options, security configurations, and scaling parameters.
3
4
## Capabilities
5
6
### List Services
7
8
Retrieve all metastore services in a specified location with optional filtering and pagination support.
9
10
```python { .api }
11
def list_services(
12
self,
13
request: Optional[ListServicesRequest] = None,
14
*,
15
parent: Optional[str] = None,
16
retry: OptionalRetry = gapic_v1.method.DEFAULT,
17
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
18
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
19
) -> pagers.ListServicesPager:
20
"""
21
Lists services in a project and location.
22
23
Args:
24
request: The request object containing list parameters
25
parent: Required. The relative resource name of the location
26
Format: projects/{project_id}/locations/{location_id}
27
retry: Retry configuration for the request
28
timeout: Request timeout in seconds
29
metadata: Additional metadata for the request
30
31
Returns:
32
ListServicesPager: Pageable list of services
33
34
Raises:
35
google.api_core.exceptions.GoogleAPICallError: If the request fails
36
"""
37
```
38
39
Usage example:
40
41
```python
42
from google.cloud import metastore
43
44
client = metastore.DataprocMetastoreClient()
45
parent = "projects/my-project/locations/us-central1"
46
47
# List all services
48
for service in client.list_services(parent=parent):
49
print(f"Service: {service.name}")
50
print(f"State: {service.state.name}")
51
print(f"Tier: {service.tier.name}")
52
53
# With pagination control
54
request = metastore.ListServicesRequest(
55
parent=parent,
56
page_size=10,
57
filter="state=ACTIVE"
58
)
59
page_result = client.list_services(request=request)
60
```
61
62
### Get Service
63
64
Retrieve detailed information about a specific metastore service including configuration, state, and endpoint details.
65
66
```python { .api }
67
def get_service(
68
self,
69
request: Optional[GetServiceRequest] = None,
70
*,
71
name: Optional[str] = None,
72
retry: OptionalRetry = gapic_v1.method.DEFAULT,
73
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
74
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
75
) -> Service:
76
"""
77
Gets the details of a single service.
78
79
Args:
80
request: The request object
81
name: Required. The relative resource name of the metastore service
82
Format: projects/{project_id}/locations/{location_id}/services/{service_id}
83
retry: Retry configuration
84
timeout: Request timeout in seconds
85
metadata: Additional metadata
86
87
Returns:
88
Service: The service resource
89
90
Raises:
91
google.api_core.exceptions.NotFound: If the service doesn't exist
92
"""
93
```
94
95
### Create Service
96
97
Create a new metastore service with comprehensive configuration options including networking, security, and Hive metastore settings.
98
99
```python { .api }
100
def create_service(
101
self,
102
request: Optional[CreateServiceRequest] = None,
103
*,
104
parent: Optional[str] = None,
105
service: Optional[Service] = None,
106
service_id: Optional[str] = None,
107
retry: OptionalRetry = gapic_v1.method.DEFAULT,
108
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
109
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
110
) -> operation.Operation:
111
"""
112
Creates a metastore service in a project and location.
113
114
Args:
115
request: The request object
116
parent: Required. The relative resource name of the location
117
service: Required. The service configuration
118
service_id: Required. The ID to use for the service
119
retry: Retry configuration
120
timeout: Request timeout in seconds
121
metadata: Additional metadata
122
123
Returns:
124
Operation: Long-running operation for service creation
125
126
Raises:
127
google.api_core.exceptions.AlreadyExists: If service_id already exists
128
google.api_core.exceptions.InvalidArgument: If configuration is invalid
129
"""
130
```
131
132
Usage example:
133
134
```python
135
from google.cloud import metastore
136
137
client = metastore.DataprocMetastoreClient()
138
139
# Configure the service
140
service_config = metastore.Service(
141
tier=metastore.Service.Tier.ENTERPRISE,
142
hive_metastore_config=metastore.HiveMetastoreConfig(
143
version="3.1.0",
144
config_overrides={
145
"javax.jdo.option.ConnectionURL": "jdbc:mysql://...",
146
"hive.metastore.uris": "thrift://metastore:9083"
147
}
148
),
149
network_config=metastore.NetworkConfig(
150
consumers=[
151
metastore.NetworkConfig.Consumer(
152
subnetwork="projects/my-project/regions/us-central1/subnetworks/default"
153
)
154
]
155
),
156
encryption_config=metastore.EncryptionConfig(
157
kms_key="projects/my-project/locations/us-central1/keyRings/my-ring/cryptoKeys/my-key"
158
),
159
maintenance_window=metastore.MaintenanceWindow(
160
hour_of_day=2,
161
day_of_week=dayofweek_pb2.DayOfWeek.SUNDAY
162
)
163
)
164
165
# Create the service
166
operation = client.create_service(
167
parent="projects/my-project/locations/us-central1",
168
service_id="my-metastore",
169
service=service_config
170
)
171
172
# Wait for completion (can take 20-30 minutes)
173
service = operation.result(timeout=1800)
174
print(f"Service created: {service.name}")
175
print(f"Endpoint URI: {service.endpoint_uri}")
176
```
177
178
### Update Service
179
180
Update an existing metastore service configuration including scaling, network settings, and maintenance windows.
181
182
```python { .api }
183
def update_service(
184
self,
185
request: Optional[UpdateServiceRequest] = None,
186
*,
187
service: Optional[Service] = None,
188
update_mask: Optional[field_mask_pb2.FieldMask] = None,
189
retry: OptionalRetry = gapic_v1.method.DEFAULT,
190
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
191
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
192
) -> operation.Operation:
193
"""
194
Updates the parameters of a single service.
195
196
Args:
197
request: The request object
198
service: Required. The service to update
199
update_mask: Required. Field mask specifying which fields to update
200
retry: Retry configuration
201
timeout: Request timeout in seconds
202
metadata: Additional metadata
203
204
Returns:
205
Operation: Long-running operation for service update
206
207
Raises:
208
google.api_core.exceptions.NotFound: If the service doesn't exist
209
google.api_core.exceptions.InvalidArgument: If update is invalid
210
"""
211
```
212
213
### Delete Service
214
215
Delete a metastore service and all associated data including backups and metadata.
216
217
```python { .api }
218
def delete_service(
219
self,
220
request: Optional[DeleteServiceRequest] = None,
221
*,
222
name: Optional[str] = None,
223
retry: OptionalRetry = gapic_v1.method.DEFAULT,
224
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
225
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
226
) -> operation.Operation:
227
"""
228
Deletes a single service.
229
230
Args:
231
request: The request object
232
name: Required. The relative resource name of the service to delete
233
retry: Retry configuration
234
timeout: Request timeout in seconds
235
metadata: Additional metadata
236
237
Returns:
238
Operation: Long-running operation for service deletion
239
240
Raises:
241
google.api_core.exceptions.NotFound: If the service doesn't exist
242
google.api_core.exceptions.FailedPrecondition: If service cannot be deleted
243
"""
244
```
245
246
## Core Types
247
248
### Service Configuration
249
250
```python { .api }
251
class Service:
252
name: str
253
create_time: timestamp_pb2.Timestamp
254
update_time: timestamp_pb2.Timestamp
255
labels: Dict[str, str]
256
hive_metastore_config: HiveMetastoreConfig
257
network: str
258
endpoint_uri: str
259
port: int
260
state: State
261
state_message: str
262
artifact_gcs_uri: str
263
tier: Tier
264
maintenance_window: Optional[MaintenanceWindow]
265
uid: str
266
metadata_management_activity: Optional[MetadataManagementActivity]
267
release_channel: ReleaseChannel
268
encryption_config: Optional[EncryptionConfig]
269
network_config: Optional[NetworkConfig]
270
database_type: DatabaseType
271
telemetry_config: Optional[TelemetryConfig]
272
scaling_config: Optional[ScalingConfig]
273
274
class State(enum.Enum):
275
STATE_UNSPECIFIED = 0
276
CREATING = 1
277
ACTIVE = 2
278
SUSPENDING = 3
279
SUSPENDED = 4
280
UPDATING = 5
281
DELETING = 6
282
ERROR = 7
283
284
class Tier(enum.Enum):
285
TIER_UNSPECIFIED = 0
286
DEVELOPER = 1
287
ENTERPRISE = 3
288
289
class ReleaseChannel(enum.Enum):
290
RELEASE_CHANNEL_UNSPECIFIED = 0
291
CANARY = 1
292
STABLE = 2
293
294
class DatabaseType(enum.Enum):
295
DATABASE_TYPE_UNSPECIFIED = 0
296
MYSQL = 1
297
SPANNER = 2
298
```
299
300
### Hive Metastore Configuration
301
302
```python { .api }
303
class HiveMetastoreConfig:
304
version: str
305
config_overrides: Dict[str, str]
306
kerberos_config: Optional[KerberosConfig]
307
auxiliary_versions: MutableMapping[str, AuxiliaryVersionConfig]
308
endpoint_protocol: EndpointProtocol
309
310
class EndpointProtocol(enum.Enum):
311
ENDPOINT_PROTOCOL_UNSPECIFIED = 0
312
THRIFT = 1
313
GRPC = 2
314
315
class KerberosConfig:
316
keytab: Secret
317
principal: str
318
krb5_config_gcs_uri: str
319
320
class Secret:
321
cloud_secret: str
322
323
class AuxiliaryVersionConfig:
324
version: str
325
config_overrides: Dict[str, str]
326
network_config: Optional[NetworkConfig]
327
```
328
329
### Network Configuration
330
331
```python { .api }
332
class NetworkConfig:
333
consumers: List[Consumer]
334
335
class Consumer:
336
subnetwork: str
337
endpoint_uri: str
338
endpoint_location: str
339
```
340
341
### Other Configuration Types
342
343
```python { .api }
344
class EncryptionConfig:
345
kms_key: str
346
347
class MaintenanceWindow:
348
hour_of_day: wrappers_pb2.Int32Value
349
day_of_week: DayOfWeek
350
351
class DayOfWeek(enum.Enum):
352
DAY_OF_WEEK_UNSPECIFIED = 0
353
MONDAY = 1
354
TUESDAY = 2
355
WEDNESDAY = 3
356
THURSDAY = 4
357
FRIDAY = 5
358
SATURDAY = 6
359
SUNDAY = 7
360
361
class TelemetryConfig:
362
log_format: LogFormat
363
364
class LogFormat(enum.Enum):
365
LOG_FORMAT_UNSPECIFIED = 0
366
LEGACY = 1
367
JSON = 2
368
369
class ScalingConfig:
370
instance_size: InstanceSize
371
scaling_factor: Optional[float]
372
373
class InstanceSize(enum.Enum):
374
INSTANCE_SIZE_UNSPECIFIED = 0
375
EXTRA_SMALL = 1
376
SMALL = 2
377
MEDIUM = 3
378
LARGE = 4
379
EXTRA_LARGE = 5
380
```
381
382
### Request/Response Types
383
384
```python { .api }
385
class ListServicesRequest:
386
parent: str
387
page_size: int
388
page_token: str
389
filter: str
390
order_by: str
391
392
class ListServicesResponse:
393
services: List[Service]
394
next_page_token: str
395
unreachable: List[str]
396
397
class GetServiceRequest:
398
name: str
399
400
class CreateServiceRequest:
401
parent: str
402
service_id: str
403
service: Service
404
request_id: str
405
406
class UpdateServiceRequest:
407
update_mask: field_mask_pb2.FieldMask
408
service: Service
409
request_id: str
410
411
class DeleteServiceRequest:
412
name: str
413
request_id: str
414
```