def get_realm(project_id, location, realm_id): """Gets a realm.""" client = gaming.RealmsServiceClient() request = realms.GetRealmRequest( name=f"projects/{project_id}/locations/{location}/realms/{realm_id}", ) response = client.get_realm(request) print(f"Get realm response:\n{response}") return response
def delete_realm(project_id, location, realm_id): """Deletes a realm.""" client = gaming.RealmsServiceClient() request = realms.DeleteRealmRequest( name=f"projects/{project_id}/locations/{location}/realms/{realm_id}", ) operation = client.delete_realm(request) print(f"Delete realm operation: {operation.operation.name}") operation.result(timeout=120)
def list_realms(project_id, location): """Lists the existing realms.""" client = gaming.RealmsServiceClient() response = client.list_realms( parent=f"projects/{project_id}/locations/{location}") for realm in response.realms: print(f"Name: {realm.name}") return response.realms
def update_realm(project_id, location, realm_id): """Updates a realm.""" client = gaming.RealmsServiceClient() request = realms.UpdateRealmRequest( realm=realms.Realm( name=f"projects/{project_id}/locations/{location}/realms/{realm_id}", labels={"label-key-1": "label-value-1", "label-key-2": "label-value-2"}, ), update_mask=field_mask.FieldMask(paths=["labels"]), ) operation = client.update_realm(request) print(f"Update realm operation: {operation.operation.name}") operation.result(timeout=120)
def create_realm(project_id, location, realm_id): """Creates a realm.""" client = gaming.RealmsServiceClient() request = realms.CreateRealmRequest( parent=f"projects/{project_id}/locations/{location}", realm_id=realm_id, realm=realms.Realm( description="My Realm", time_zone="US/Pacific", ), ) operation = client.create_realm(request) print(f"Create realm operation: {operation.operation.name}") operation.result(timeout=120)