-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate jira provider in favor of atlassian.jira provider (#25930)
* Deprecate jira provider in favor of atlassian.jira provider
- Loading branch information
Showing
46 changed files
with
1,078 additions
and
653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.. 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. | ||
.. NOTE TO CONTRIBUTORS: | ||
Please, only add notes to the Changelog just below the "Changelog" header when there are some breaking changes | ||
and you want to add an explanation to the users on how they are supposed to deal with them. | ||
The changelog is updated and maintained semi-automatically by release manager. | ||
Changelog | ||
--------- | ||
|
||
1.0.0 | ||
..... | ||
|
||
Initial version of the provider. |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# | ||
# 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. | ||
"""Hook for JIRA""" | ||
from typing import Any, Optional | ||
|
||
from jira import JIRA | ||
from jira.exceptions import JIRAError | ||
|
||
from airflow.exceptions import AirflowException | ||
from airflow.hooks.base import BaseHook | ||
|
||
|
||
class JiraHook(BaseHook): | ||
""" | ||
Jira interaction hook, a Wrapper around JIRA Python SDK. | ||
:param jira_conn_id: reference to a pre-defined Jira Connection | ||
""" | ||
|
||
default_conn_name = 'jira_default' | ||
conn_type = "jira" | ||
conn_name_attr = "jira_conn_id" | ||
hook_name = "JIRA" | ||
|
||
def __init__(self, jira_conn_id: str = default_conn_name, proxies: Optional[Any] = None) -> None: | ||
super().__init__() | ||
self.jira_conn_id = jira_conn_id | ||
self.proxies = proxies | ||
self.client: Optional[JIRA] = None | ||
self.get_conn() | ||
|
||
def get_conn(self) -> JIRA: | ||
if not self.client: | ||
self.log.debug('Creating Jira client for conn_id: %s', self.jira_conn_id) | ||
|
||
get_server_info = True | ||
validate = True | ||
extra_options = {} | ||
if not self.jira_conn_id: | ||
raise AirflowException('Failed to create jira client. no jira_conn_id provided') | ||
|
||
conn = self.get_connection(self.jira_conn_id) | ||
if conn.extra is not None: | ||
extra_options = conn.extra_dejson | ||
# only required attributes are taken for now, | ||
# more can be added ex: async, logging, max_retries | ||
|
||
# verify | ||
if 'verify' in extra_options and extra_options['verify'].lower() == 'false': | ||
extra_options['verify'] = False | ||
|
||
# validate | ||
if 'validate' in extra_options and extra_options['validate'].lower() == 'false': | ||
validate = False | ||
|
||
if 'get_server_info' in extra_options and extra_options['get_server_info'].lower() == 'false': | ||
get_server_info = False | ||
|
||
try: | ||
self.client = JIRA( | ||
conn.host, | ||
options=extra_options, | ||
basic_auth=(conn.login, conn.password), | ||
get_server_info=get_server_info, | ||
validate=validate, | ||
proxies=self.proxies, | ||
) | ||
except JIRAError as jira_error: | ||
raise AirflowException(f'Failed to create jira client, jira error: {str(jira_error)}') | ||
except Exception as e: | ||
raise AirflowException(f'Failed to create jira client, error: {str(e)}') | ||
|
||
return self.client |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# | ||
# 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. | ||
|
||
from typing import TYPE_CHECKING, Any, Callable, Optional, Sequence | ||
|
||
from airflow.exceptions import AirflowException | ||
from airflow.models import BaseOperator | ||
from airflow.providers.atlassian.jira.hooks.jira import JIRAError, JiraHook | ||
|
||
if TYPE_CHECKING: | ||
from airflow.utils.context import Context | ||
|
||
|
||
class JiraOperator(BaseOperator): | ||
""" | ||
JiraOperator to interact and perform action on Jira issue tracking system. | ||
This operator is designed to use Jira Python SDK: http://jira.readthedocs.io | ||
:param jira_conn_id: reference to a pre-defined Jira Connection | ||
:param jira_method: method name from Jira Python SDK to be called | ||
:param jira_method_args: required method parameters for the jira_method. (templated) | ||
:param result_processor: function to further process the response from Jira | ||
:param get_jira_resource_method: function or operator to get jira resource | ||
on which the provided jira_method will be executed | ||
""" | ||
|
||
template_fields: Sequence[str] = ("jira_method_args",) | ||
|
||
def __init__( | ||
self, | ||
*, | ||
jira_method: str, | ||
jira_conn_id: str = 'jira_default', | ||
jira_method_args: Optional[dict] = None, | ||
result_processor: Optional[Callable] = None, | ||
get_jira_resource_method: Optional[Callable] = None, | ||
**kwargs, | ||
) -> None: | ||
super().__init__(**kwargs) | ||
self.jira_conn_id = jira_conn_id | ||
self.method_name = jira_method | ||
self.jira_method_args = jira_method_args | ||
self.result_processor = result_processor | ||
self.get_jira_resource_method = get_jira_resource_method | ||
|
||
def execute(self, context: 'Context') -> Any: | ||
try: | ||
if self.get_jira_resource_method is not None: | ||
# if get_jira_resource_method is provided, jira_method will be executed on | ||
# resource returned by executing the get_jira_resource_method. | ||
# This makes all the provided methods of JIRA sdk accessible and usable | ||
# directly at the JiraOperator without additional wrappers. | ||
# ref: http://jira.readthedocs.io/en/latest/api.html | ||
if isinstance(self.get_jira_resource_method, JiraOperator): | ||
resource = self.get_jira_resource_method.execute(**context) | ||
else: | ||
resource = self.get_jira_resource_method(**context) | ||
else: | ||
# Default method execution is on the top level jira client resource | ||
hook = JiraHook(jira_conn_id=self.jira_conn_id) | ||
resource = hook.client | ||
|
||
# Current Jira-Python SDK (1.0.7) has issue with pickling the jira response. | ||
# ex: self.xcom_push(context, key='operator_response', value=jira_response) | ||
# This could potentially throw error if jira_result is not picklable | ||
jira_result = getattr(resource, self.method_name)(**self.jira_method_args) | ||
if self.result_processor: | ||
return self.result_processor(context, jira_result) | ||
|
||
return jira_result | ||
|
||
except JIRAError as jira_error: | ||
raise AirflowException(f"Failed to execute jiraOperator, error: {str(jira_error)}") | ||
except Exception as e: | ||
raise AirflowException(f"Jira operator error: {str(e)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# 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. | ||
|
||
--- | ||
package-name: apache-airflow-providers-atlassian-jira | ||
name: Atlassian Jira | ||
description: | | ||
`Atlassian Jira <https://www.atlassian.com/>`__ | ||
versions: | ||
- 1.0.0 | ||
|
||
dependencies: | ||
- apache-airflow>=2.2.0 | ||
- JIRA>1.0.7 | ||
|
||
integrations: | ||
- integration-name: Atlassian Jira | ||
external-doc-url: https://www.atlassian.com/pl/software/jira | ||
logo: /integration-logos/jira/Jira.png | ||
tags: [software] | ||
|
||
operators: | ||
- integration-name: Atlassian Jira | ||
python-modules: | ||
- airflow.providers.atlassian.jira.operators.jira | ||
|
||
sensors: | ||
- integration-name: Atlassian Jira | ||
python-modules: | ||
- airflow.providers.atlassian.jira.sensors.jira | ||
|
||
hooks: | ||
- integration-name: Atlassian Jira | ||
python-modules: | ||
- airflow.providers.atlassian.jira.hooks.jira | ||
|
||
connection-types: | ||
- hook-class-name: airflow.providers.atlassian.jira.hooks.jira.JiraHook | ||
connection-type: jira |
Oops, something went wrong.