eladkal commented on a change in pull request #16915:
URL: https://github.com/apache/airflow/pull/16915#discussion_r668675076
##########
File path: airflow/providers/tableau/operators/tableau_refresh_workbook.py
##########
@@ -67,18 +68,16 @@ def execute(self, context: dict) -> str:
with TableauHook(self.site_id, self.tableau_conn_id) as tableau_hook:
workbook = self._get_workbook_by_name(tableau_hook)
- job_id = self._refresh_workbook(tableau_hook, workbook.id)
- if self.blocking:
- from airflow.providers.tableau.sensors.tableau_job_status
import TableauJobStatusSensor
+ job_id = TableauOperator(
+ resource='workbooks',
+ method='refresh',
+ resource_id=workbook.id,
+ site_id=self.site_id,
+ tableau_conn_id=self.tableau_conn_id,
+ task_id='refresh_workbook',
+ dag=None,
+ ).execute(context={})
Review comment:
do we actually actually need a `TableauRefreshWorkbookOperator`?
Your code suggestion means that `TableauRefreshWorkbookOperator` is actually
equal to just doing:
```
TableauOperator(resource='workbooks',
method='refresh',
resource_id='my_workbook_id',
site_id='site_id',
tableau_conn_id='tableau_default',
task_id='refresh_workbook')
```
So maybe a better way is to deprecate `TableauRefreshWorkbookOperator` ?
##########
File path: airflow/providers/tableau/operators/tableau.py
##########
@@ -0,0 +1,124 @@
+# 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.
+from typing import Optional
+
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.providers.tableau.hooks.tableau import TableauHook
+from airflow.providers.tableau.sensors.tableau_job_status import
TableauJobStatusSensor
+
+RESOURCES_METHODS = {
+ 'datasources': ['delete', 'download', 'refresh'],
+ 'groups': ['delete'],
+ 'projects': ['delete'],
+ 'schedule': ['delete'],
+ 'sites': ['delete'],
+ 'subscriptions': ['delete'],
+ 'tasks': ['delete', 'run'],
+ 'users': ['remove'],
+ 'workbooks': ['delete', 'download', 'refresh'],
+}
+
+
+class TableauOperator(BaseOperator):
+ """
+ Exectues a Tableau API Resource
+
+ .. seealso:: https://tableau.github.io/server-client-python/docs/api-ref
+
+ :param resource: The name of the resource to use.
+ :type resource: str
+ :param method: The name of the resource's method to execute.
+ :type method: str
+ :param resource_id: The id of resource wich will recive the action.
+ :type resource_id: str
+ :param site_id: The id of the site where the workbook belongs to.
+ :type site_id: Optional[str]
+ :param blocking: By default the extract refresh will be blocking means it
will wait until it has finished.
+ :type blocking: bool
Review comment:
There is no `blocking` parameter in the init. Did you mean
`blocking_refresh` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]