Source code for airflow.providers.alibaba.cloud.operators.oss
## Licensed to the Apache Software Foundation (ASF) under one# or more contributor license agreements. See the NOTICE file# distributed with this work for additional information# regarding copyright ownership. The ASF licenses this file# to you under the Apache License, Version 2.0 (the# "License"); you may not use this file except in compliance# with the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing,# software distributed under the License is distributed on an# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License."""This module contains Alibaba Cloud OSS operators."""from__future__importannotationsfromtypingimportTYPE_CHECKINGfromairflow.modelsimportBaseOperatorfromairflow.providers.alibaba.cloud.hooks.ossimportOSSHookifTYPE_CHECKING:fromairflow.utils.contextimportContext
[docs]classOSSCreateBucketOperator(BaseOperator):""" This operator creates an OSS bucket. :param region: OSS region you want to create bucket :param bucket_name: This is bucket name you want to create :param oss_conn_id: The Airflow connection used for OSS credentials. """def__init__(self,region:str,bucket_name:str|None=None,oss_conn_id:str="oss_default",**kwargs,)->None:super().__init__(**kwargs)
[docs]classOSSDeleteBucketOperator(BaseOperator):""" This operator to delete an OSS bucket. :param region: OSS region you want to create bucket :param bucket_name: This is bucket name you want to delete :param oss_conn_id: The Airflow connection used for OSS credentials. """def__init__(self,region:str,bucket_name:str|None=None,oss_conn_id:str="oss_default",**kwargs,)->None:super().__init__(**kwargs)
[docs]classOSSUploadObjectOperator(BaseOperator):""" This operator to upload an file-like object. :param key: the OSS path of the object :param file: local file to upload. :param region: OSS region you want to create bucket :param bucket_name: This is bucket name you want to create :param oss_conn_id: The Airflow connection used for OSS credentials. """def__init__(self,key:str,file:str,region:str,bucket_name:str|None=None,oss_conn_id:str="oss_default",**kwargs,)->None:super().__init__(**kwargs)
[docs]classOSSDownloadObjectOperator(BaseOperator):""" This operator to Download an OSS object. :param key: key of the object to download. :param local_file: local path + file name to save. :param region: OSS region :param bucket_name: OSS bucket name :param oss_conn_id: The Airflow connection used for OSS credentials. """def__init__(self,key:str,file:str,region:str,bucket_name:str|None=None,oss_conn_id:str="oss_default",**kwargs,)->None:super().__init__(**kwargs)
[docs]classOSSDeleteBatchObjectOperator(BaseOperator):""" This operator to delete OSS objects. :param key: key list of the objects to delete. :param region: OSS region :param bucket_name: OSS bucket name :param oss_conn_id: The Airflow connection used for OSS credentials. """def__init__(self,keys:list,region:str,bucket_name:str|None=None,oss_conn_id:str="oss_default",**kwargs,)->None:super().__init__(**kwargs)
[docs]classOSSDeleteObjectOperator(BaseOperator):""" This operator to delete an OSS object. :param key: key of the object to delete. :param region: OSS region :param bucket_name: OSS bucket name :param oss_conn_id: The Airflow connection used for OSS credentials. """def__init__(self,key:str,region:str,bucket_name:str|None=None,oss_conn_id:str="oss_default",**kwargs,)->None:super().__init__(**kwargs)