def _SchemaToMessage(schema): """Converts the given schema dict to the corresponding schema message. Args: schema: dict, The schema that has been processed. Returns: googleCloudDatacatalogV1betaSchema Raises: InvalidSchemaError: If the schema is invalid. """ messages = api_util.GetMessagesModule() try: schema_message = encoding.DictToMessage( {'columns': schema}, messages.GoogleCloudDatacatalogV1beta1Schema) except AttributeError: # TODO(b/77547931): Fix apitools bug related to unchecked iteritems() call. raise InvalidSchemaError( 'Invalid schema: expected list of column names along with their types, ' 'modes, descriptions, and/or nested subcolumns.') except _messages.ValidationError as e: # Unfortunately apitools doesn't provide a way to get the path to the # invalid field here. raise InvalidSchemaError('Invalid schema: [{}]'.format(e)) unrecognized_field_paths = _GetUnrecognizedFieldPaths(schema_message) if unrecognized_field_paths: error_msg_lines = ['Invalid schema, the following fields are unrecognized:'] error_msg_lines += unrecognized_field_paths raise InvalidSchemaError('\n'.join(error_msg_lines)) return schema_message
def ProcessTaxonomiesFromYAML(inline_source, version_label): """Converts the given inline source dict to the corresponding import request. Args: inline_source: dict, inlineSource part of the import taxonomy request. version_label: string, specifies the version for client. Returns: GoogleCloudDatacatalogV1beta1ImportTaxonomiesRequest Raises: InvalidInlineSourceError: If the inline source is invalid. """ messages = api_util.GetMessagesModule(version_label) if version_label == 'v1': request = messages.GoogleCloudDatacatalogV1ImportTaxonomiesRequest else: request = messages.GoogleCloudDatacatalogV1beta1ImportTaxonomiesRequest try: import_request_message = encoding.DictToMessage( {'inlineSource': inline_source}, request) except AttributeError: raise InvalidInlineSourceError('An error occurred while parsing the ' 'serialized taxonomy. Please check your ' 'input file.') unrecognized_field_paths = _GetUnrecognizedFieldPaths(import_request_message) if unrecognized_field_paths: error_msg_lines = ['Invalid inline source, the following fields are ' 'unrecognized:'] error_msg_lines += unrecognized_field_paths raise InvalidInlineSourceError('\n'.join(error_msg_lines)) return import_request_message
def __init__(self): self.client = util.GetClientInstance() self.messages = util.GetMessagesModule() self.service = self.client.entries
def __init__(self, version_label): self.version_label = version_label self.client = util.GetClientInstance(version_label) self.messages = util.GetMessagesModule(version_label) self.service = self.client.catalog
def __init__(self): self.client = util.GetClientInstance(api_version=_CRAWLER_API_VERSION) self.messages = util.GetMessagesModule( api_version=_CRAWLER_API_VERSION) self.service = self.client.projects_crawlers
def __init__(self): self.client = util.GetClientInstance(VERSION) self.messages = util.GetMessagesModule(VERSION) self.service = self.client.projects_locations_tagTemplates
def __init__(self, version_label): self.version_label = version_label self.client = util.GetClientInstance(version_label) self.messages = util.GetMessagesModule(version_label) self.service = self.client.projects_locations_taxonomies
def __init__(self): self.client = util.GetClientInstance() self.messages = util.GetMessagesModule() self.entry_lookup_service = self.client.entries self.entry_service = self.client.projects_locations_entryGroups_entries