def Run(self, args):
        update_mask = lake.GenerateUpdateMask(args)
        if len(update_mask) < 1:
            raise exceptions.HttpException(
                'Update commands must specify at least one additional parameter to change.'
            )

        lake_ref = args.CONCEPTS.lake.Parse()
        dataplex_client = dataplex_util.GetClientInstance()
        message = dataplex_util.GetMessageModule()
        update_req_op = dataplex_client.projects_locations_lakes.Patch(
            message.DataplexProjectsLocationsLakesPatchRequest(
                name=lake_ref.RelativeName(),
                validateOnly=args.validate_only,
                updateMask=u','.join(update_mask),
                googleCloudDataplexV1Lake=message.GoogleCloudDataplexV1Lake(
                    description=args.description,
                    displayName=args.display_name,
                    metastore=message.GoogleCloudDataplexV1LakeMetastore(
                        service=args.metastore_service),
                    labels=dataplex_util.CreateLabels(
                        message.GoogleCloudDataplexV1Lake, args))))
        validate_only = getattr(args, 'validate_only', False)
        if validate_only:
            log.status.Print('Validation complete with errors:')
            return update_req_op

        async_ = getattr(args, 'async_', False)
        if not async_:
            lake.WaitForOperation(update_req_op)
            log.UpdatedResource(lake_ref, details='Operation was sucessful.')
            return

        log.status.Print('Updating [{0}] with operation [{1}].'.format(
            lake_ref, update_req_op.name))
예제 #2
0
    def Run(self, args):
        lake_ref = args.CONCEPTS.lake.Parse()
        dataplex_client = dataplex_util.GetClientInstance()
        message = dataplex_util.GetMessageModule()
        create_req_op = dataplex_client.projects_locations_lakes.Create(
            message.DataplexProjectsLocationsLakesCreateRequest(
                lakeId=lake_ref.Name(),
                parent=lake_ref.Parent().RelativeName(),
                validateOnly=args.validate_only,
                googleCloudDataplexV1Lake=message.GoogleCloudDataplexV1Lake(
                    description=args.description,
                    displayName=args.display_name,
                    labels=dataplex_util.CreateLabels(
                        message.GoogleCloudDataplexV1Lake, args),
                    metastore=message.GoogleCloudDataplexV1LakeMetastore(
                        service=args.metastore_service))))

        validate_only = getattr(args, 'validate_only', False)
        if validate_only:
            log.status.Print('Validation complete.')
            return

        async_ = getattr(args, 'async_', False)
        if not async_:
            lake.WaitForOperation(create_req_op)
            log.CreatedResource(lake_ref.Name(),
                                details='Lake created in [{0}]'.format(
                                    lake_ref.Parent().RelativeName()))
            return

        log.status.Print('Creating [{0}] with operation [{1}].'.format(
            lake_ref, create_req_op.name))
def GenerateZoneForUpdateRequest(args):
    """Create Zone for Message Update Requests."""
    module = dataplex_api.GetMessageModule()
    return module.GoogleCloudDataplexV1Zone(
        description=args.description,
        displayName=args.display_name,
        labels=dataplex_api.CreateLabels(module.GoogleCloudDataplexV1Zone,
                                         args),
        discoverySpec=GenerateDiscoverySpec(args))
def GenerateEnvironmentForUpdateRequest(args):
    """Create Environment for Message Update Requests."""
    module = dataplex_api.GetMessageModule()
    return module.GoogleCloudDataplexV1Environment(
        description=args.description,
        displayName=args.display_name,
        labels=dataplex_api.CreateLabels(
            module.GoogleCloudDataplexV1Environment, args),
        infrastructureSpec=GenerateInfrastructureSpec(args),
        sessionSpec=GenerateSessionSpec(args))
def GenerateZoneForCreateRequest(args):
    """Create Zone for Message Create Requests."""
    module = dataplex_api.GetMessageModule()
    return module.GoogleCloudDataplexV1Zone(
        description=args.description,
        displayName=args.display_name,
        labels=dataplex_api.CreateLabels(module.GoogleCloudDataplexV1Zone,
                                         args),
        type=module.GoogleCloudDataplexV1Zone.TypeValueValuesEnum(args.type),
        discoverySpec=GenerateDiscoverySpec(args),
        resourceSpec=module.GoogleCloudDataplexV1ZoneResourceSpec(
            locationType=module.GoogleCloudDataplexV1ZoneResourceSpec.
            LocationTypeValueValuesEnum(args.resource_location_type)))
예제 #6
0
def GenerateContentForUpdateRequest(args):
    """Creates Content for Message Update Requests."""
    module = dataplex_api.GetMessageModule()
    content = module.GoogleCloudDataplexV1Content(
        dataText=args.data_text,
        description=args.description,
        labels=dataplex_api.CreateLabels(module.GoogleCloudDataplexV1Content,
                                         args),
        path=args.path)
    if args.kernel_type:
        content.notebook = GenerateNotebook(args)
    if args.query_engine:
        content.sqlScript = GenerateSqlScript(args)
    return content
예제 #7
0
def GenerateAssetForCreateRequest(args):
    """Create Asset for Message Create Requests."""
    module = dataplex_api.GetMessageModule()
    resource_spec_field = module.GoogleCloudDataplexV1AssetResourceSpec
    resource_spec = module.GoogleCloudDataplexV1AssetResourceSpec(
        name=args.resource_name,
        type=resource_spec_field.TypeValueValuesEnum(args.resource_type))
    request = module.GoogleCloudDataplexV1Asset(
        description=args.description,
        displayName=args.display_name,
        labels=dataplex_api.CreateLabels(module.GoogleCloudDataplexV1Asset,
                                         args),
        resourceSpec=resource_spec)
    discovery = GenerateDiscoverySpec(args)
    if discovery != module.GoogleCloudDataplexV1AssetDiscoverySpec():
        setattr(request, 'discoverySpec', discovery)
    return request