Exemplo n.º 1
0
 def insert(self):
     if not self.test_uid:
         self.test_uid = str(uuid4())
     #
     super().insert()
     #
     project = Project.query.get_or_404(self.project_id)
     minio_client = MinioClient(project=project)
     minio_client.create_bucket(bucket="dast")
Exemplo n.º 2
0
    def post(self, project_id: int, bucket: str):
        args = self._parser_post.parse_args()
        expiration_measure = args["expiration_measure"]
        expiration_value = args["expiration_value"]

        project = Project.get_or_404(project_id)
        data_retention_limit = project.get_data_retention_limit()
        minio_client = MinioClient(project=project)
        days = data_retention_limit or None

        if expiration_value and expiration_measure:
            today_date = datetime.today().date()
            expiration_date = today_date + relativedelta(**{expiration_measure: expiration_value})
            time_delta = expiration_date - today_date
            days = time_delta.days
            if data_retention_limit != -1 and days > data_retention_limit:
                raise Forbidden(description="The data retention limit allowed in the project has been exceeded")

        created = minio_client.create_bucket(bucket)
        if created and days:
            minio_client.configure_bucket_lifecycle(bucket=bucket, days=days)
        return {"message": "Created", "code": 200}