Skip to content

Commit

Permalink
Deprecate jira provider in favor of atlassian.jira provider (#25930)
Browse files Browse the repository at this point in the history
* Deprecate jira provider in favor of atlassian.jira provider
  • Loading branch information
eladkal committed Aug 31, 2022
1 parent 02010e8 commit 836fe8a
Show file tree
Hide file tree
Showing 46 changed files with 1,078 additions and 653 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/airflow_providers_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ body:
- apache-sqoop
- arangodb
- asana
- atlassian-jira
- celery
- cloudant
- cncf-kubernetes
Expand All @@ -63,7 +64,6 @@ body:
- influxdb
- jdbc
- jenkins
- jira
- microsoft-azure
- microsoft-mssql
- microsoft-psrp
Expand Down
20 changes: 10 additions & 10 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -619,16 +619,16 @@ This is the full list of those extras:
.. START EXTRAS HERE
airbyte, alibaba, all, all_dbs, amazon, apache.atlas, apache.beam, apache.cassandra, apache.drill,
apache.druid, apache.hdfs, apache.hive, apache.kylin, apache.livy, apache.pig, apache.pinot,
apache.spark, apache.sqoop, apache.webhdfs, arangodb, asana, async, atlas, aws, azure, cassandra,
celery, cgroups, cloudant, cncf.kubernetes, common.sql, crypto, dask, databricks, datadog,
dbt.cloud, deprecated_api, devel, devel_all, devel_ci, devel_hadoop, dingding, discord, doc, docker,
druid, elasticsearch, exasol, facebook, ftp, gcp, gcp_api, github, github_enterprise, google,
google_auth, grpc, hashicorp, hdfs, hive, http, imap, influxdb, jdbc, jenkins, jira, kerberos,
kubernetes, ldap, leveldb, microsoft.azure, microsoft.mssql, microsoft.psrp, microsoft.winrm, mongo,
mssql, mysql, neo4j, odbc, openfaas, opsgenie, oracle, pagerduty, pandas, papermill, password,
pinot, plexus, postgres, presto, qds, qubole, rabbitmq, redis, s3, salesforce, samba, segment,
sendgrid, sentry, sftp, singularity, slack, snowflake, spark, sqlite, ssh, statsd, tableau, tabular,
telegram, trino, vertica, virtualenv, webhdfs, winrm, yandex, zendesk
apache.spark, apache.sqoop, apache.webhdfs, arangodb, asana, async, atlas, atlassian.jira, aws,
azure, cassandra, celery, cgroups, cloudant, cncf.kubernetes, common.sql, crypto, dask, databricks,
datadog, dbt.cloud, deprecated_api, devel, devel_all, devel_ci, devel_hadoop, dingding, discord,
doc, docker, druid, elasticsearch, exasol, facebook, ftp, gcp, gcp_api, github, github_enterprise,
google, google_auth, grpc, hashicorp, hdfs, hive, http, imap, influxdb, jdbc, jenkins, jira,
kerberos, kubernetes, ldap, leveldb, microsoft.azure, microsoft.mssql, microsoft.psrp,
microsoft.winrm, mongo, mssql, mysql, neo4j, odbc, openfaas, opsgenie, oracle, pagerduty, pandas,
papermill, password, pinot, plexus, postgres, presto, qds, qubole, rabbitmq, redis, s3, salesforce,
samba, segment, sendgrid, sentry, sftp, singularity, slack, snowflake, spark, sqlite, ssh, statsd,
tableau, tabular, telegram, trino, vertica, virtualenv, webhdfs, winrm, yandex, zendesk
.. END EXTRAS HERE
Provider packages
Expand Down
20 changes: 10 additions & 10 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ The list of available extras:
# START EXTRAS HERE
airbyte, alibaba, all, all_dbs, amazon, apache.atlas, apache.beam, apache.cassandra, apache.drill,
apache.druid, apache.hdfs, apache.hive, apache.kylin, apache.livy, apache.pig, apache.pinot,
apache.spark, apache.sqoop, apache.webhdfs, arangodb, asana, async, atlas, aws, azure, cassandra,
celery, cgroups, cloudant, cncf.kubernetes, common.sql, crypto, dask, databricks, datadog,
dbt.cloud, deprecated_api, devel, devel_all, devel_ci, devel_hadoop, dingding, discord, doc, docker,
druid, elasticsearch, exasol, facebook, ftp, gcp, gcp_api, github, github_enterprise, google,
google_auth, grpc, hashicorp, hdfs, hive, http, imap, influxdb, jdbc, jenkins, jira, kerberos,
kubernetes, ldap, leveldb, microsoft.azure, microsoft.mssql, microsoft.psrp, microsoft.winrm, mongo,
mssql, mysql, neo4j, odbc, openfaas, opsgenie, oracle, pagerduty, pandas, papermill, password,
pinot, plexus, postgres, presto, qds, qubole, rabbitmq, redis, s3, salesforce, samba, segment,
sendgrid, sentry, sftp, singularity, slack, snowflake, spark, sqlite, ssh, statsd, tableau, tabular,
telegram, trino, vertica, virtualenv, webhdfs, winrm, yandex, zendesk
apache.spark, apache.sqoop, apache.webhdfs, arangodb, asana, async, atlas, atlassian.jira, aws,
azure, cassandra, celery, cgroups, cloudant, cncf.kubernetes, common.sql, crypto, dask, databricks,
datadog, dbt.cloud, deprecated_api, devel, devel_all, devel_ci, devel_hadoop, dingding, discord,
doc, docker, druid, elasticsearch, exasol, facebook, ftp, gcp, gcp_api, github, github_enterprise,
google, google_auth, grpc, hashicorp, hdfs, hive, http, imap, influxdb, jdbc, jenkins, jira,
kerberos, kubernetes, ldap, leveldb, microsoft.azure, microsoft.mssql, microsoft.psrp,
microsoft.winrm, mongo, mssql, mysql, neo4j, odbc, openfaas, opsgenie, oracle, pagerduty, pandas,
papermill, password, pinot, plexus, postgres, presto, qds, qubole, rabbitmq, redis, s3, salesforce,
samba, segment, sendgrid, sentry, sftp, singularity, slack, snowflake, spark, sqlite, ssh, statsd,
tableau, tabular, telegram, trino, vertica, virtualenv, webhdfs, winrm, yandex, zendesk
# END EXTRAS HERE

# For installing Airflow in development environments - see CONTRIBUTING.rst
Expand Down
6 changes: 3 additions & 3 deletions airflow/contrib/hooks/jira_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
# specific language governing permissions and limitations
# under the License.

"""This module is deprecated. Please use :mod:`airflow.providers.jira.hooks.jira`."""
"""This module is deprecated. Please use :mod:`airflow.providers.atlassian.jira.hooks.jira`."""

import warnings

from airflow.providers.jira.hooks.jira import JiraHook # noqa
from airflow.providers.atlassian.jira.hooks.jira import JiraHook # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.jira.hooks.jira`.",
"This module is deprecated. Please use `airflow.providers.atlassian.jira.hooks.jira`.",
DeprecationWarning,
stacklevel=2,
)
6 changes: 3 additions & 3 deletions airflow/contrib/operators/jira_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""This module is deprecated. Please use :mod:`airflow.providers.jira.operators.jira`."""
"""This module is deprecated. Please use :mod:`airflow.providers.atlassian.jira.operators.jira`."""

import warnings

from airflow.providers.jira.operators.jira import JiraOperator # noqa
from airflow.providers.atlassian.jira.operators.jira import JiraOperator # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.jira.operators.jira`.",
"This module is deprecated. Please use `airflow.providers.atlassian.jira.operators.jira`.",
DeprecationWarning,
stacklevel=2,
)
6 changes: 3 additions & 3 deletions airflow/contrib/sensors/jira_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
# specific language governing permissions and limitations
# under the License.

"""This module is deprecated. Please use :mod:`airflow.providers.jira.sensors.jira`."""
"""This module is deprecated. Please use :mod:`airflow.providers.atlassian.jira.sensors.jira`."""

import warnings

from airflow.providers.jira.sensors.jira import JiraSensor, JiraTicketSensor # noqa
from airflow.providers.atlassian.jira.sensors.jira import JiraSensor, JiraTicketSensor # noqa

warnings.warn(
"This module is deprecated. Please use `airflow.providers.jira.sensors.jira`.",
"This module is deprecated. Please use `airflow.providers.atlassian.jira.sensors.jira`.",
DeprecationWarning,
stacklevel=2,
)
File renamed without changes.
30 changes: 30 additions & 0 deletions airflow/providers/atlassian/jira/CHANGELOG.rst
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.
88 changes: 88 additions & 0 deletions airflow/providers/atlassian/jira/hooks/jira.py
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.
90 changes: 90 additions & 0 deletions airflow/providers/atlassian/jira/operators/jira.py
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)}")
54 changes: 54 additions & 0 deletions airflow/providers/atlassian/jira/provider.yaml
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
Loading

0 comments on commit 836fe8a

Please sign in to comment.