Skip to content

Commit 002c6c5

Browse files
committed
fix endpoints
1 parent edd7538 commit 002c6c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2312
-65
lines changed

airflow_python_sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"""
1212

1313

14-
__version__ = "0.4.12"
14+
__version__ = "0.14.13"
1515

1616
# import ApiClient
1717
from airflow_python_sdk.api_client import ApiClient

airflow_python_sdk/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
7777
self.default_headers[header_name] = header_value
7878
self.cookie = cookie
7979
# Set default User-Agent.
80-
self.user_agent = 'OpenAPI-Generator/0.4.12/python'
80+
self.user_agent = 'OpenAPI-Generator/0.14.13/python'
8181

8282
def __enter__(self):
8383
return self

airflow_python_sdk/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def to_debug_report(self):
400400
"OS: {env}\n"\
401401
"Python Version: {pyversion}\n"\
402402
"Version of the API: 1.0.0\n"\
403-
"SDK Package Version: 0.4.12".\
403+
"SDK Package Version: 0.14.13".\
404404
format(env=sys.platform, pyversion=sys.version)
405405

406406
def get_host_settings(self):

airflow_python_sdk/model/connection_collection.py

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@
3030
)
3131

3232
def lazy_import():
33+
from airflow_python_sdk.model.collection_info import CollectionInfo
34+
from airflow_python_sdk.model.connection_collection_all_of import ConnectionCollectionAllOf
3335
from airflow_python_sdk.model.connection_collection_item import ConnectionCollectionItem
36+
globals()['CollectionInfo'] = CollectionInfo
37+
globals()['ConnectionCollectionAllOf'] = ConnectionCollectionAllOf
3438
globals()['ConnectionCollectionItem'] = ConnectionCollectionItem
3539

3640

37-
class ConnectionCollection(ModelNormal):
41+
class ConnectionCollection(ModelComposed):
3842
"""NOTE: This class is auto generated by OpenAPI Generator.
3943
Ref: https://openapi-generator.tech
4044
@@ -64,7 +68,14 @@ class ConnectionCollection(ModelNormal):
6468
validations = {
6569
}
6670

67-
additional_properties_type = None
71+
@cached_property
72+
def additional_properties_type():
73+
"""
74+
This must be a method because a model may have properties that are
75+
of type self, this must run after the class is loaded
76+
"""
77+
lazy_import()
78+
return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501
6879

6980
_nullable = False
7081

@@ -94,15 +105,16 @@ def discriminator():
94105
'total_entries': 'total_entries', # noqa: E501
95106
}
96107

97-
_composed_schemas = {}
98-
99108
required_properties = set([
100109
'_data_store',
101110
'_check_type',
102111
'_spec_property_naming',
103112
'_path_to_item',
104113
'_configuration',
105114
'_visited_composed_classes',
115+
'_composed_instances',
116+
'_var_name_to_model_instances',
117+
'_additional_properties_model_instances',
106118
])
107119

108120
@convert_js_args_to_python_args
@@ -141,7 +153,7 @@ def __init__(self, *args, **kwargs): # noqa: E501
141153
through its discriminator because we passed in
142154
_visited_composed_classes = (Animal,)
143155
connections ([ConnectionCollectionItem]): [optional] # noqa: E501
144-
total_entries (int): [optional] # noqa: E501
156+
total_entries (int): Count of objects in the current result set.. [optional] # noqa: E501
145157
"""
146158

147159
_check_type = kwargs.pop('_check_type', True)
@@ -167,11 +179,58 @@ def __init__(self, *args, **kwargs): # noqa: E501
167179
self._configuration = _configuration
168180
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
169181

182+
constant_args = {
183+
'_check_type': _check_type,
184+
'_path_to_item': _path_to_item,
185+
'_spec_property_naming': _spec_property_naming,
186+
'_configuration': _configuration,
187+
'_visited_composed_classes': self._visited_composed_classes,
188+
}
189+
required_args = {
190+
}
191+
# remove args whose value is Null because they are unset
192+
required_arg_names = list(required_args.keys())
193+
for required_arg_name in required_arg_names:
194+
if required_args[required_arg_name] is nulltype.Null:
195+
del required_args[required_arg_name]
196+
model_args = {}
197+
model_args.update(required_args)
198+
model_args.update(kwargs)
199+
composed_info = validate_get_composed_info(
200+
constant_args, model_args, self)
201+
self._composed_instances = composed_info[0]
202+
self._var_name_to_model_instances = composed_info[1]
203+
self._additional_properties_model_instances = composed_info[2]
204+
unused_args = composed_info[3]
205+
206+
for var_name, var_value in required_args.items():
207+
setattr(self, var_name, var_value)
170208
for var_name, var_value in kwargs.items():
171-
if var_name not in self.attribute_map and \
209+
if var_name in unused_args and \
172210
self._configuration is not None and \
173211
self._configuration.discard_unknown_keys and \
174-
self.additional_properties_type is None:
212+
not self._additional_properties_model_instances:
175213
# discard variable.
176214
continue
177215
setattr(self, var_name, var_value)
216+
217+
@cached_property
218+
def _composed_schemas():
219+
# we need this here to make our import statements work
220+
# we must store _composed_schemas in here so the code is only run
221+
# when we invoke this method. If we kept this at the class
222+
# level we would get an error beause the class level
223+
# code would be run when this module is imported, and these composed
224+
# classes don't exist yet because their module has not finished
225+
# loading
226+
lazy_import()
227+
return {
228+
'anyOf': [
229+
],
230+
'allOf': [
231+
CollectionInfo,
232+
ConnectionCollectionAllOf,
233+
],
234+
'oneOf': [
235+
],
236+
}
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
"""
2+
Airflow API (Stable)
3+
4+
# Overview To facilitate management, Apache Airflow supports a range of REST API endpoints across its objects. This section provides an overview of the API design, methods, and supported use cases. Most of the endpoints accept `JSON` as input and return `JSON` responses. This means that you must usually add the following headers to your request: ``` Content-type: application/json Accept: application/json ``` ## Resources The term `resource` refers to a single type of object in the Airflow metadata. An API is broken up by its endpoint's corresponding resource. The name of a resource is typically plural and expressed in camelCase. Example: `dagRuns`. Resource names are used as part of endpoint URLs, as well as in API parameters and responses. ## CRUD Operations The platform supports **C**reate, **R**ead, **U**pdate, and **D**elete operations on most resources. You can review the standards for these operations and their standard parameters below. Some endpoints have special behavior as exceptions. ### Create To create a resource, you typically submit an HTTP `POST` request with the resource's required metadata in the request body. The response returns a `201 Created` response code upon success with the resource's metadata, including its internal `id`, in the response body. ### Read The HTTP `GET` request can be used to read a resource or to list a number of resources. A resource's `id` can be submitted in the request parameters to read a specific resource. The response usually returns a `200 OK` response code upon success, with the resource's metadata in the response body. If a `GET` request does not include a specific resource `id`, it is treated as a list request. The response usually returns a `200 OK` response code upon success, with an object containing a list of resources' metadata in the response body. When reading resources, some common query parameters are usually available. e.g.: ``` v1/connections?limit=25&offset=25 ``` |Query Parameter|Type|Description| |---------------|----|-----------| |limit|integer|Maximum number of objects to fetch. Usually 25 by default| |offset|integer|Offset after which to start returning objects. For use with limit query parameter.| ### Update Updating a resource requires the resource `id`, and is typically done using an HTTP `PATCH` request, with the fields to modify in the request body. The response usually returns a `200 OK` response code upon success, with information about the modified resource in the response body. ### Delete Deleting a resource requires the resource `id` and is typically executing via an HTTP `DELETE` request. The response usually returns a `204 No Content` response code upon success. ## Conventions - Resource names are plural and expressed in camelCase. - Names are consistent between URL parameter name and field name. - Field names are in snake_case. ```json { \"name\": \"string\", \"slots\": 0, \"occupied_slots\": 0, \"used_slots\": 0, \"queued_slots\": 0, \"open_slots\": 0 } ``` ### Update Mask Update mask is available as a query parameter in patch endpoints. It is used to notify the API which fields you want to update. Using `update_mask` makes it easier to update objects by helping the server know which fields to update in an object instead of updating all fields. The update request ignores any fields that aren't specified in the field mask, leaving them with their current values. Example: ``` resource = request.get('/resource/my-id').json() resource['my_field'] = 'new-value' request.patch('/resource/my-id?update_mask=my_field', data=json.dumps(resource)) ``` ## Versioning and Endpoint Lifecycle - API versioning is not synchronized to specific releases of the Apache Airflow. - APIs are designed to be backward compatible. - Any changes to the API will first go through a deprecation phase. # Summary of Changes | Airflow version | Description | |-|-| | v2.0 | Initial release | # Trying the API You can use a third party client, such as [curl](https://curl.haxx.se/), [HTTPie](https://httpie.org/), [Postman](https://www.postman.com/) or [the Insomnia rest client](https://insomnia.rest/) to test the Apache Airflow API. Note that you will need to pass credentials data. For e.g., here is how to pause a DAG with [curl](https://curl.haxx.se/), when basic authorization is used: ```bash curl -X POST 'https://example.com/api/v1/dags/{dag_id}?update_mask=is_paused' \\ -H 'Content-Type: application/json' \\ --user \"username:password\" \\ -d '{ \"is_paused\": true }' ``` Using a graphical tool such as [Postman](https://www.postman.com/) or [Insomnia](https://insomnia.rest/), it is possible to import the API specifications directly: 1. Download the API specification by clicking the **Download** button at top of this document 2. Import the JSON specification in the graphical tool of your choice. - In *Postman*, you can click the **import** button at the top - With *Insomnia*, you can just drag-and-drop the file on the UI Note that with *Postman*, you can also generate code snippets by selecting a request and clicking on the **Code** button. # Authentication To be able to meet the requirements of many organizations, Airflow supports many authentication methods, and it is even possible to add your own method. If you want to check which auth backend is currently set, you can use `airflow config get-value api auth_backend` command as in the example below. ```bash $ airflow config get-value api auth_backend airflow.api.auth.backend.basic_auth ``` The default is to deny all requests. For details on configuring the authentication, see [API Authorization](https://airflow.apache.org/docs/apache-airflow/stable/security/api.html). # Errors We follow the error response format proposed in [RFC 7807](https://tools.ietf.org/html/rfc7807) also known as Problem Details for HTTP APIs. As with our normal API responses, your client must be prepared to gracefully handle additional members of the response. ## Unauthenticated This indicates that the request has not been applied because it lacks valid authentication credentials for the target resource. Please check that you have valid credentials. ## PermissionDenied This response means that the server understood the request but refuses to authorize it because it lacks sufficient rights to the resource. It happens when you do not have the necessary permission to execute the action you performed. You need to get the appropriate permissions in other to resolve this error. ## BadRequest This response means that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). To resolve this, please ensure that your syntax is correct. ## NotFound This client error response indicates that the server cannot find the requested resource. ## MethodNotAllowed Indicates that the request method is known by the server but is not supported by the target resource. ## NotAcceptable The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation. ## AlreadyExists The request could not be completed due to a conflict with the current state of the target resource, meaning that the resource already exists ## Unknown This means that the server encountered an unexpected condition that prevented it from fulfilling the request. # noqa: E501
5+
6+
The version of the OpenAPI document: 1.0.0
7+
8+
Generated by: https://openapi-generator.tech
9+
"""
10+
11+
12+
import re # noqa: F401
13+
import sys # noqa: F401
14+
15+
import nulltype # noqa: F401
16+
17+
from airflow_python_sdk.model_utils import ( # noqa: F401
18+
ApiTypeError,
19+
ModelComposed,
20+
ModelNormal,
21+
ModelSimple,
22+
cached_property,
23+
change_keys_js_to_python,
24+
convert_js_args_to_python_args,
25+
date,
26+
datetime,
27+
file_type,
28+
none_type,
29+
validate_get_composed_info,
30+
)
31+
32+
def lazy_import():
33+
from airflow_python_sdk.model.connection_collection_item import ConnectionCollectionItem
34+
globals()['ConnectionCollectionItem'] = ConnectionCollectionItem
35+
36+
37+
class ConnectionCollectionAllOf(ModelNormal):
38+
"""NOTE: This class is auto generated by OpenAPI Generator.
39+
Ref: https://openapi-generator.tech
40+
41+
Do not edit the class manually.
42+
43+
Attributes:
44+
allowed_values (dict): The key is the tuple path to the attribute
45+
and the for var_name this is (var_name,). The value is a dict
46+
with a capitalized key describing the allowed value and an allowed
47+
value. These dicts store the allowed enum values.
48+
attribute_map (dict): The key is attribute name
49+
and the value is json key in definition.
50+
discriminator_value_class_map (dict): A dict to go from the discriminator
51+
variable value to the discriminator class name.
52+
validations (dict): The key is the tuple path to the attribute
53+
and the for var_name this is (var_name,). The value is a dict
54+
that stores validations for max_length, min_length, max_items,
55+
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
56+
inclusive_minimum, and regex.
57+
additional_properties_type (tuple): A tuple of classes accepted
58+
as additional properties values.
59+
"""
60+
61+
allowed_values = {
62+
}
63+
64+
validations = {
65+
}
66+
67+
additional_properties_type = None
68+
69+
_nullable = False
70+
71+
@cached_property
72+
def openapi_types():
73+
"""
74+
This must be a method because a model may have properties that are
75+
of type self, this must run after the class is loaded
76+
77+
Returns
78+
openapi_types (dict): The key is attribute name
79+
and the value is attribute type.
80+
"""
81+
lazy_import()
82+
return {
83+
'connections': ([ConnectionCollectionItem],), # noqa: E501
84+
}
85+
86+
@cached_property
87+
def discriminator():
88+
return None
89+
90+
91+
attribute_map = {
92+
'connections': 'connections', # noqa: E501
93+
}
94+
95+
_composed_schemas = {}
96+
97+
required_properties = set([
98+
'_data_store',
99+
'_check_type',
100+
'_spec_property_naming',
101+
'_path_to_item',
102+
'_configuration',
103+
'_visited_composed_classes',
104+
])
105+
106+
@convert_js_args_to_python_args
107+
def __init__(self, *args, **kwargs): # noqa: E501
108+
"""ConnectionCollectionAllOf - a model defined in OpenAPI
109+
110+
Keyword Args:
111+
_check_type (bool): if True, values for parameters in openapi_types
112+
will be type checked and a TypeError will be
113+
raised if the wrong type is input.
114+
Defaults to True
115+
_path_to_item (tuple/list): This is a list of keys or values to
116+
drill down to the model in received_data
117+
when deserializing a response
118+
_spec_property_naming (bool): True if the variable names in the input data
119+
are serialized names, as specified in the OpenAPI document.
120+
False if the variable names in the input data
121+
are pythonic names, e.g. snake case (default)
122+
_configuration (Configuration): the instance to use when
123+
deserializing a file_type parameter.
124+
If passed, type conversion is attempted
125+
If omitted no type conversion is done.
126+
_visited_composed_classes (tuple): This stores a tuple of
127+
classes that we have traveled through so that
128+
if we see that class again we will not use its
129+
discriminator again.
130+
When traveling through a discriminator, the
131+
composed schema that is
132+
is traveled through is added to this set.
133+
For example if Animal has a discriminator
134+
petType and we pass in "Dog", and the class Dog
135+
allOf includes Animal, we move through Animal
136+
once using the discriminator, and pick Dog.
137+
Then in Dog, we will make an instance of the
138+
Animal class but this time we won't travel
139+
through its discriminator because we passed in
140+
_visited_composed_classes = (Animal,)
141+
connections ([ConnectionCollectionItem]): [optional] # noqa: E501
142+
"""
143+
144+
_check_type = kwargs.pop('_check_type', True)
145+
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
146+
_path_to_item = kwargs.pop('_path_to_item', ())
147+
_configuration = kwargs.pop('_configuration', None)
148+
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
149+
150+
if args:
151+
raise ApiTypeError(
152+
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
153+
args,
154+
self.__class__.__name__,
155+
),
156+
path_to_item=_path_to_item,
157+
valid_classes=(self.__class__,),
158+
)
159+
160+
self._data_store = {}
161+
self._check_type = _check_type
162+
self._spec_property_naming = _spec_property_naming
163+
self._path_to_item = _path_to_item
164+
self._configuration = _configuration
165+
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
166+
167+
for var_name, var_value in kwargs.items():
168+
if var_name not in self.attribute_map and \
169+
self._configuration is not None and \
170+
self._configuration.discard_unknown_keys and \
171+
self.additional_properties_type is None:
172+
# discard variable.
173+
continue
174+
setattr(self, var_name, var_value)

0 commit comments

Comments
 (0)