Debian Codegraph @

stripe/sigma/_scheduled_query_run.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._list_object import ListObject
4 from stripe._listable_api_resource import ListableAPIResource
5 from stripe._stripe_object import StripeObject
6 from typing import ClassVar, Optional
7 from typing_extensions import Literal, Unpack, TYPE_CHECKING
8
9 if TYPE_CHECKING:
10 from stripe._file import File
11 from stripe.params.sigma._scheduled_query_run_list_params import (
12 ScheduledQueryRunListParams,
13 )
14 from stripe.params.sigma._scheduled_query_run_retrieve_params import (
15 ScheduledQueryRunRetrieveParams,
16 )
17
18
19 class ScheduledQueryRun(ListableAPIResource["ScheduledQueryRun"]):
20 """
21 If you have [scheduled a Sigma query](https://docs.stripe.com/sigma/scheduled-queries), you'll
22 receive a `sigma.scheduled_query_run.created` webhook each time the query
23 runs. The webhook contains a `ScheduledQueryRun` object, which you can use to
24 retrieve the query results.
25 """
26
27 OBJECT_NAME: ClassVar[Literal["scheduled_query_run"]] = (
28 "scheduled_query_run"
29 )
30
31 class Error(StripeObject):
32 message: str
33 """
34 Information about the run failure.
35 """
36
37 created: int
38 """
39 Time at which the object was created. Measured in seconds since the Unix epoch.
40 """
41 data_load_time: int
42 """
43 When the query was run, Sigma contained a snapshot of your Stripe data at this time.
44 """
45 error: Optional[Error]
46 file: Optional["File"]
47 """
48 The file object representing the results of the query.
49 """
50 id: str
51 """
52 Unique identifier for the object.
53 """
54 livemode: bool
55 """
56 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
57 """
58 object: Literal["scheduled_query_run"]
59 """
60 String representing the object's type. Objects of the same type share the same value.
61 """
62 result_available_until: int
63 """
64 Time at which the result expires and is no longer available for download.
65 """
66 sql: str
67 """
68 SQL for the query.
69 """
70 status: str
71 """
72 The query's execution status, which will be `completed` for successful runs, and `canceled`, `failed`, or `timed_out` otherwise.
73 """
74 title: str
75 """
76 Title of the query.
77 """
78
79 @classmethod
80 def list(
81 cls, **params: Unpack["ScheduledQueryRunListParams"]
82 ) -> ListObject["ScheduledQueryRun"]:
83 """
84 Returns a list of scheduled query runs.
85 """
86 result = cls._static_request(
87 "get",
88 cls.class_url(),
89 params=params,
90 )
91 if not isinstance(result, ListObject):
92 raise TypeError(
93 "Expected list object from API, got %s"
94 % (type(result).__name__)
95 )
96
97 return result
98
99 @classmethod
100 async def list_async(
101 cls, **params: Unpack["ScheduledQueryRunListParams"]
102 ) -> ListObject["ScheduledQueryRun"]:
103 """
104 Returns a list of scheduled query runs.
105 """
106 result = await cls._static_request_async(
107 "get",
108 cls.class_url(),
109 params=params,
110 )
111 if not isinstance(result, ListObject):
112 raise TypeError(
113 "Expected list object from API, got %s"
114 % (type(result).__name__)
115 )
116
117 return result
118
119 @classmethod
120 def retrieve(
121 cls, id: str, **params: Unpack["ScheduledQueryRunRetrieveParams"]
122 ) -> "ScheduledQueryRun":
123 """
124 Retrieves the details of an scheduled query run.
125 """
126 instance = cls(id, **params)
127 instance.refresh()
128 return instance
129
130 @classmethod
131 async def retrieve_async(
132 cls, id: str, **params: Unpack["ScheduledQueryRunRetrieveParams"]
133 ) -> "ScheduledQueryRun":
134 """
135 Retrieves the details of an scheduled query run.
136 """
137 instance = cls(id, **params)
138 await instance.refresh_async()
139 return instance
140
141 @classmethod
142 def class_url(cls):
143 return "/v1/sigma/scheduled_query_runs"
144
145 _inner_class_types = {"error": Error}