Skip to content

Latest commit

 

History

History
517 lines (379 loc) · 18.2 KB

ConnectionApi.md

File metadata and controls

517 lines (379 loc) · 18.2 KB

airflow_client.client.ConnectionApi

All URIs are relative to /api/v1

Method HTTP request Description
delete_connection DELETE /connections/{connection_id} Delete a connection
get_connection GET /connections/{connection_id} Get a connection
get_connections GET /connections List connections
patch_connection PATCH /connections/{connection_id} Update a connection
post_connection POST /connections Create a connection
test_connection POST /connections/test Test a connection

delete_connection

delete_connection(connection_id)

Delete a connection

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import connection_api
from airflow_client.client.model.error import Error
from pprint import pprint
# Defining the host is optional and defaults to /api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = airflow_client.client.Configuration(
    host = "/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure HTTP basic authorization: Basic
configuration = airflow_client.client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)

# Enter a context with an instance of the API client
with airflow_client.client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = connection_api.ConnectionApi(api_client)
    connection_id = "connection_id_example" # str | The connection ID.

    # example passing only required values which don't have defaults set
    try:
        # Delete a connection
        api_instance.delete_connection(connection_id)
    except airflow_client.client.ApiException as e:
        print("Exception when calling ConnectionApi->delete_connection: %s\n" % e)

Parameters

Name Type Description Notes
connection_id str The connection ID.

Return type

void (empty response body)

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
204 Success. -
400 Client specified an invalid argument. -
401 Request not authenticated due to missing, invalid, authentication info. -
403 Client does not have sufficient permission. -
404 A specified resource is not found. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_connection

Connection get_connection(connection_id)

Get a connection

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import connection_api
from airflow_client.client.model.error import Error
from airflow_client.client.model.connection import Connection
from pprint import pprint
# Defining the host is optional and defaults to /api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = airflow_client.client.Configuration(
    host = "/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure HTTP basic authorization: Basic
configuration = airflow_client.client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)

# Enter a context with an instance of the API client
with airflow_client.client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = connection_api.ConnectionApi(api_client)
    connection_id = "connection_id_example" # str | The connection ID.

    # example passing only required values which don't have defaults set
    try:
        # Get a connection
        api_response = api_instance.get_connection(connection_id)
        pprint(api_response)
    except airflow_client.client.ApiException as e:
        print("Exception when calling ConnectionApi->get_connection: %s\n" % e)

Parameters

Name Type Description Notes
connection_id str The connection ID.

Return type

Connection

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success. -
401 Request not authenticated due to missing, invalid, authentication info. -
403 Client does not have sufficient permission. -
404 A specified resource is not found. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_connections

ConnectionCollection get_connections()

List connections

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import connection_api
from airflow_client.client.model.connection_collection import ConnectionCollection
from airflow_client.client.model.error import Error
from pprint import pprint
# Defining the host is optional and defaults to /api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = airflow_client.client.Configuration(
    host = "/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure HTTP basic authorization: Basic
configuration = airflow_client.client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)

# Enter a context with an instance of the API client
with airflow_client.client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = connection_api.ConnectionApi(api_client)
    limit = 100 # int | The numbers of items to return. (optional) if omitted the server will use the default value of 100
    offset = 0 # int | The number of items to skip before starting to collect the result set. (optional)
    order_by = "order_by_example" # str | The name of the field to order the results by. Prefix a field name with `-` to reverse the sort order.  *New in version 2.1.0*  (optional)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # List connections
        api_response = api_instance.get_connections(limit=limit, offset=offset, order_by=order_by)
        pprint(api_response)
    except airflow_client.client.ApiException as e:
        print("Exception when calling ConnectionApi->get_connections: %s\n" % e)

Parameters

Name Type Description Notes
limit int The numbers of items to return. [optional] if omitted the server will use the default value of 100
offset int The number of items to skip before starting to collect the result set. [optional]
order_by str The name of the field to order the results by. Prefix a field name with `-` to reverse the sort order. New in version 2.1.0 [optional]

Return type

ConnectionCollection

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success. -
401 Request not authenticated due to missing, invalid, authentication info. -
403 Client does not have sufficient permission. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

patch_connection

Connection patch_connection(connection_id, connection)

Update a connection

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import connection_api
from airflow_client.client.model.error import Error
from airflow_client.client.model.connection import Connection
from pprint import pprint
# Defining the host is optional and defaults to /api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = airflow_client.client.Configuration(
    host = "/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure HTTP basic authorization: Basic
configuration = airflow_client.client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)

# Enter a context with an instance of the API client
with airflow_client.client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = connection_api.ConnectionApi(api_client)
    connection_id = "connection_id_example" # str | The connection ID.
    connection = Connection(None) # Connection | 
    update_mask = [
        "update_mask_example",
    ] # [str] | The fields to update on the resource. If absent or empty, all modifiable fields are updated. A comma-separated list of fully qualified names of fields.  (optional)

    # example passing only required values which don't have defaults set
    try:
        # Update a connection
        api_response = api_instance.patch_connection(connection_id, connection)
        pprint(api_response)
    except airflow_client.client.ApiException as e:
        print("Exception when calling ConnectionApi->patch_connection: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Update a connection
        api_response = api_instance.patch_connection(connection_id, connection, update_mask=update_mask)
        pprint(api_response)
    except airflow_client.client.ApiException as e:
        print("Exception when calling ConnectionApi->patch_connection: %s\n" % e)

Parameters

Name Type Description Notes
connection_id str The connection ID.
connection Connection
update_mask [str] The fields to update on the resource. If absent or empty, all modifiable fields are updated. A comma-separated list of fully qualified names of fields. [optional]

Return type

Connection

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success. -
400 Client specified an invalid argument. -
401 Request not authenticated due to missing, invalid, authentication info. -
403 Client does not have sufficient permission. -
404 A specified resource is not found. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

post_connection

Connection post_connection(connection)

Create a connection

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import connection_api
from airflow_client.client.model.error import Error
from airflow_client.client.model.connection import Connection
from pprint import pprint
# Defining the host is optional and defaults to /api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = airflow_client.client.Configuration(
    host = "/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure HTTP basic authorization: Basic
configuration = airflow_client.client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)

# Enter a context with an instance of the API client
with airflow_client.client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = connection_api.ConnectionApi(api_client)
    connection = Connection(None) # Connection | 

    # example passing only required values which don't have defaults set
    try:
        # Create a connection
        api_response = api_instance.post_connection(connection)
        pprint(api_response)
    except airflow_client.client.ApiException as e:
        print("Exception when calling ConnectionApi->post_connection: %s\n" % e)

Parameters

Name Type Description Notes
connection Connection

Return type

Connection

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success. -
400 Client specified an invalid argument. -
401 Request not authenticated due to missing, invalid, authentication info. -
403 Client does not have sufficient permission. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

test_connection

ConnectionTest test_connection(connection)

Test a connection

Test a connection. For security reasons, the test connection functionality is disabled by default across Airflow UI, API and CLI. For more information on capabilities of users, see the documentation: https://airflow.apache.org/docs/apache-airflow/stable/security/security_model.html#capabilities-of-authenticated-ui-users. It is strongly advised to not enable the feature until you make sure that only highly trusted UI/API users have "edit connection" permissions. Set the "test_connection" flag to "Enabled" in the "core" section of Airflow configuration (airflow.cfg) to enable testing of collections. It can also be controlled by the environment variable AIRFLOW__CORE__TEST_CONNECTION. New in version 2.2.0

Example

  • Basic Authentication (Basic):
import time
import airflow_client.client
from airflow_client.client.api import connection_api
from airflow_client.client.model.error import Error
from airflow_client.client.model.connection_test import ConnectionTest
from airflow_client.client.model.connection import Connection
from pprint import pprint
# Defining the host is optional and defaults to /api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = airflow_client.client.Configuration(
    host = "/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure HTTP basic authorization: Basic
configuration = airflow_client.client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)

# Enter a context with an instance of the API client
with airflow_client.client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = connection_api.ConnectionApi(api_client)
    connection = Connection(None) # Connection | 

    # example passing only required values which don't have defaults set
    try:
        # Test a connection
        api_response = api_instance.test_connection(connection)
        pprint(api_response)
    except airflow_client.client.ApiException as e:
        print("Exception when calling ConnectionApi->test_connection: %s\n" % e)

Parameters

Name Type Description Notes
connection Connection

Return type

ConnectionTest

Authorization

Basic, Kerberos

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success. -
400 Client specified an invalid argument. -
401 Request not authenticated due to missing, invalid, authentication info. -
403 Client does not have sufficient permission. -
404 A specified resource is not found. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]