You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/04/11 10:00:20 UTC

[airflow-client-python] branch update-test-code-with-appropriate-instructions created (now e158cd5)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a change to branch update-test-code-with-appropriate-instructions
in repository https://gitbox.apache.org/repos/asf/airflow-client-python.git.


      at e158cd5  Updated test code with appropriate instructions

This branch includes the following new commits:

     new e158cd5  Updated test code with appropriate instructions

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[airflow-client-python] 01/01: Updated test code with appropriate instructions

Posted by po...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch update-test-code-with-appropriate-instructions
in repository https://gitbox.apache.org/repos/asf/airflow-client-python.git

commit e158cd508d7898d273a4c70068e9925516ff8773
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Sun Apr 11 11:50:39 2021 +0200

    Updated test code with appropriate instructions
    
    Also extracted the test code to make it easier to use
---
 README.md                 | 26 +++++++++++-------------
 dev/test_python_client.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md
index 8f18f1b..f154b98 100644
--- a/README.md
+++ b/README.md
@@ -54,29 +54,27 @@ import airflow_client.client
 Please follow the [installation procedure](#installation--usage) and then run the following:
 
 ```python
-
-import time
 import airflow_client.client
 from pprint import pprint
 from airflow_client.client.api import config_api
-from airflow_client.client.model.config import Config
-from airflow_client.client.model.error import Error
-# Defining the host is optional and defaults to http://localhost/api/v1
-# See configuration.py for a list of all supported configuration parameters.
-configuration = airflow_client.client.Configuration(
-    host = "http://localhost/api/v1"
-)
 
-# The client must configure the authentication and authorization parameters
+# The client must use 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.
+#
+# In case of the basic authentication below, make sure that Airflow is
+# configured with the basic_auth as backend:
+#
+# auth_backend = airflow.api.auth.backend.basic_auth
+#
+# Make sure that your user/name are configured properly
 
 # Configure HTTP basic authorization: Basic
 configuration = airflow_client.client.Configuration(
-    host = "http://localhost/api/v1",
-    username = 'YOUR_USERNAME',
-    password = 'YOUR_PASSWORD'
+    host="http://localhost/api/v1",
+    username='admin',
+    password='admin'
 )
 
 
@@ -84,7 +82,7 @@ configuration = airflow_client.client.Configuration(
 with airflow_client.client.ApiClient(configuration) as api_client:
     # Create an instance of the API class
     api_instance = config_api.ConfigApi(api_client)
-    
+
     try:
         # Get current configuration
         api_response = api_instance.get_config()
diff --git a/dev/test_python_client.py b/dev/test_python_client.py
new file mode 100644
index 0000000..2f8785f
--- /dev/null
+++ b/dev/test_python_client.py
@@ -0,0 +1,51 @@
+# 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.
+import airflow_client.client
+from pprint import pprint
+from airflow_client.client.api import config_api
+
+# The client must use 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.
+#
+# In case of the basic authentication below, make sure that Airflow is
+# configured with the basic_auth as backend:
+#
+# auth_backend = airflow.api.auth.backend.basic_auth
+#
+# Make sure that your user/name are configured properly
+
+# Configure HTTP basic authorization: Basic
+configuration = airflow_client.client.Configuration(
+    host="http://localhost/api/v1",
+    username='admin',
+    password='admin'
+)
+
+
+# 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 = config_api.ConfigApi(api_client)
+
+    try:
+        # Get current configuration
+        api_response = api_instance.get_config()
+        pprint(api_response)
+    except airflow_client.client.ApiException as e:
+        print("Exception when calling ConfigApi->get_config: %s\n" % e)