def GetIamPolicy(lake_ref):
    """Get Iam Policy request."""
    get_iam_policy_req = dataplex_api.GetMessageModule(
    ).DataplexProjectsLocationsLakesGetIamPolicyRequest(
        resource=lake_ref.RelativeName())
    return dataplex_api.GetClientInstance(
    ).projects_locations_lakes.GetIamPolicy(get_iam_policy_req)
    def Run(self, args):
        update_mask = environment.GenerateUpdateMask(args)
        if len(update_mask) < 1:
            raise exceptions.HttpException(
                'Update commands must specify at least one additional parameter to change.'
            )

        environment_ref = args.CONCEPTS.environment.Parse()
        dataplex_client = dataplex_util.GetClientInstance()
        message = dataplex_util.GetMessageModule()
        update_req_op = dataplex_client.projects_locations_lakes_environments.Patch(
            message.DataplexProjectsLocationsLakesEnvironmentsPatchRequest(
                name=environment_ref.RelativeName(),
                validateOnly=args.validate_only,
                updateMask=u','.join(update_mask),
                googleCloudDataplexV1Environment=environment.
                GenerateEnvironmentForUpdateRequest(args)))

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

        async_ = getattr(args, 'async_', False)
        if not async_:
            response = environment.WaitForOperation(update_req_op)
            log.UpdatedResource(environment_ref,
                                details='Operation was successful.')
            return response

        log.status.Print('Updating [{0}] with operation [{1}].'.format(
            environment_ref, update_req_op.name))
        return update_req_op
Beispiel #3
0
    def Run(self, args):
        environment_ref = args.CONCEPTS.environment.Parse()
        dataplex_client = dataplex_util.GetClientInstance()
        create_req_op = dataplex_client.projects_locations_lakes_environments.Create(
            dataplex_util.GetMessageModule(
            ).DataplexProjectsLocationsLakesEnvironmentsCreateRequest(
                environmentId=environment_ref.Name(),
                parent=environment_ref.Parent().RelativeName(),
                validateOnly=args.validate_only,
                googleCloudDataplexV1Environment=environment.
                GenerateEnvironmentForCreateRequest(args)))

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

        async_ = getattr(args, 'async_', False)
        if not async_:
            response = environment.WaitForOperation(create_req_op)
            log.CreatedResource(
                response.name,
                details=
                'Environment created in lake [{0}] in project [{1}] with location [{2}]'
                .format(environment_ref.lakesId, environment_ref.projectsId,
                        environment_ref.locationsId))
            return response

        log.status.Print(
            'Creating environment with path [{0}] and operation [{1}].'.format(
                environment_ref, create_req_op.name))
        return create_req_op
Beispiel #4
0
    def Run(self, args):
        asset_ref = args.CONCEPTS.asset.Parse()
        dataplex_client = dataplex_util.GetClientInstance()
        create_req_op = dataplex_client.projects_locations_lakes_zones_assets.Create(
            dataplex_util.GetMessageModule(
            ).DataplexProjectsLocationsLakesZonesAssetsCreateRequest(
                assetId=asset_ref.Name(),
                parent=asset_ref.Parent().RelativeName(),
                validateOnly=args.validate_only,
                googleCloudDataplexV1Asset=asset.GenerateAssetForCreateRequest(
                    args)))
        validate_only = getattr(args, 'validate_only', False)
        if validate_only:
            log.status.Print('Validation complete.')
            return

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

        log.status.Print('Creating [{0}] with operation [{1}].'.format(
            asset_ref, create_req_op.name))
    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))
    def Run(self, args):
        """Constructs and sends request.

    Args:
      args: argparse.Namespace, An object that contains the values for the
        arguments specified in the .Args() method.
    """
        # We extract lake reference, instead of content reference as content id
        # is not provided at the time of create content and is auto-generated
        # and returned in response.
        lake_ref = args.CONCEPTS.lake.Parse()
        dataplex_client = dataplex_util.GetClientInstance()
        content_response = dataplex_client.projects_locations_lakes_contentitems.Create(
            dataplex_util.GetMessageModule(
            ).DataplexProjectsLocationsLakesContentitemsCreateRequest(
                parent=lake_ref.RelativeName(),
                validateOnly=args.validate_only,
                googleCloudDataplexV1Content=content.
                GenerateContentForCreateRequest(args)))

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

        log.CreatedResource(
            content_response.name,
            details=
            'Content created in lake [{0}] in project [{1}] with location [{2}]'
            .format(lake_ref.lakesId, lake_ref.projectsId,
                    lake_ref.locationsId))
Beispiel #7
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 SetIamPolicy(lake_ref, policy):
    """Set Iam Policy request."""
    set_iam_policy_req = dataplex_api.GetMessageModule(
    ).DataplexProjectsLocationsLakesSetIamPolicyRequest(
        resource=lake_ref.RelativeName(),
        googleIamV1SetIamPolicyRequest=dataplex_api.GetMessageModule(
        ).GoogleIamV1SetIamPolicyRequest(policy=policy))
    return dataplex_api.GetClientInstance(
    ).projects_locations_lakes.SetIamPolicy(set_iam_policy_req)
    def Run(self, args):
        update_mask = content.GenerateUpdateMask(args)
        if len(update_mask) < 1:
            raise exceptions.HttpException(
                'Update commands must specify at least one additional parameter to change.'
            )

        content_ref = args.CONCEPTS.content.Parse()
        dataplex_client = dataplex_util.GetClientInstance()
        dataplex_client.projects_locations_lakes_contentitems.Patch(
            dataplex_util.GetMessageModule(
            ).DataplexProjectsLocationsLakesContentitemsPatchRequest(
                name=content_ref.RelativeName(),
                validateOnly=args.validate_only,
                updateMask=u','.join(update_mask),
                googleCloudDataplexV1Content=content.
                GenerateContentForUpdateRequest(args)))
        validate_only = getattr(args, 'validate_only', False)
        if validate_only:
            log.status.Print('Validation complete.')
            return

        log.UpdatedResource(content_ref)
def WaitForOperation(operation):
    """Waits for the given google.longrunning.Operation to complete."""
    return dataplex_api.WaitForOperation(
        operation,
        dataplex_api.GetClientInstance().projects_locations_lakes)