forked from tableau/server-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflow_task_endpoint.py
More file actions
29 lines (23 loc) · 1.05 KB
/
flow_task_endpoint.py
File metadata and controls
29 lines (23 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import logging
from typing import TYPE_CHECKING
from tableauserverclient.server.endpoint.endpoint import Endpoint, api
from tableauserverclient.server.endpoint.exceptions import MissingRequiredFieldError
from tableauserverclient.models import TaskItem, PaginationItem
from tableauserverclient.server import RequestFactory
from tableauserverclient.helpers.logging import logger
if TYPE_CHECKING:
from tableauserverclient.server.request_options import RequestOptions
class FlowTasks(Endpoint):
@property
def baseurl(self) -> str:
return f"{self.parent_srv.baseurl}/sites/{self.parent_srv.site_id}/tasks/flows"
@api(version="3.22")
def create(self, flow_item: TaskItem) -> bytes:
if not flow_item:
error = "No flow provided"
raise ValueError(error)
logger.info("Creating an flow task %s", flow_item)
url = self.baseurl
create_req = RequestFactory.FlowTask.create_flow_task_req(flow_item)
server_response = self.post_request(url, create_req)
return server_response.content