diff --git a/docs/apache-airflow-providers-google/operators/cloud/financial_services.rst b/docs/apache-airflow-providers-google/operators/cloud/financial_services.rst index 367e5f3871de..4c1471bc82a9 100644 --- a/docs/apache-airflow-providers-google/operators/cloud/financial_services.rst +++ b/docs/apache-airflow-providers-google/operators/cloud/financial_services.rst @@ -127,40 +127,3 @@ More information See Google Cloud Financial Services API documentation to `delete an instance `_. - - - -Sensors -^^^^^^^ - -.. _howto/sensor:FinancialServicesOperationSensor: - -Check operation status ----------------------- - -Use the :class:`~airflow.providers.google.cloud.sensors.financial_services.FinancialServicesOperationSensor` -sensor to check the status of an operation in the Google Cloud Financial Services API. - -Using the sensor -"""""""""""""""""" - -.. exampleinclude:: /../../providers/tests/system/google/cloud/financial_services/example_financial_services.py - :language: python - :dedent: 4 - :start-after: [START howto_sensor_financial_services_operation] - :end-before: [END howto_sensor_financial_services_operation] - -Templating -"""""""""" - -.. literalinclude:: /../../providers/src/airflow/providers/google/cloud/sensors/financial_services.py - :language: python - :dedent: 4 - :start-after: [START howto_sensor_financial_services_operation_template_fields] - :end-before: [END howto_sensor_financial_services_operation_template_fields] - -More information -"""""""""""""""" - -See Google Cloud Financial Services API documentation to `get an operation -`_. diff --git a/providers/src/airflow/providers/google/cloud/hooks/financial_services.py b/providers/src/airflow/providers/google/cloud/hooks/financial_services.py index 2558e01a307b..b3b3963df7ca 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/financial_services.py +++ b/providers/src/airflow/providers/google/cloud/hooks/financial_services.py @@ -35,8 +35,6 @@ class FinancialServicesHook(GoogleBaseHook): """ Hook for interacting with the Google Financial Services API. - :param discovery_doc: Discovery document for building the Financial Services API - as described `here `__ :param gcp_conn_id: Identifier of connection to Google Cloud Platform. Defaults to "google_cloud_default". """ @@ -54,9 +52,19 @@ def __init__( ) def _get_developer_key(self) -> str | None: + """ + Get a developer key for accessing the Financial Services discovery API. + + :return: A developer key for discovery API access. + """ return Variable.get("financial_services_api_key", default_var=None) def _get_discovery_doc(self) -> dict | None: + """ + Get the Financial Services discovery document from local storage. + + :return: Financial Services discovery document. + """ discovery_doc_path = Variable.get("financial_services_discovery_doc_path", default_var=None) if not discovery_doc_path: discovery_doc = None @@ -89,14 +97,21 @@ def get_conn(self) -> Resource: else: raise AirflowException( "Connecting to financialservices.googleapis.com requires either 'financial_services_api_key' or " - "'financial_services_discovery_doc_path' to be set in Airflow variables. Use 'airflow variables set financial_services_api_key ' " - "to set the variable" + "'financial_services_discovery_doc_path' to be set in Airflow variables. Use 'airflow variables " + "set financial_services_api_key ' to set the variable" ) return self.connection def wait_for_operation(self, operation: Operation, timeout: float | None = None): - """Wait for long-lasting operation to complete.""" + """ + Wait for the completion of a long-running operation. + + :param operation: The long-running operation to wait for completion. + :param timeout: Timeout in seconds to wait for completion. + + :return: The result of the operation after completion. + """ try: return operation.result(timeout=timeout) except Exception: @@ -195,7 +210,7 @@ def _parse_operation_proto(self, json_response: dict) -> tuple[str, operations_p :param json_response: Required. Long-running operation data returned from the Financial Services API in JSON format. - :returns: Tuple containing the operation ID and a parsed operations_pb2.Operation. + :returns: The operation ID and a parsed pb2 operation. """ # Can not find message descriptor by type_url: type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata # replace operation metadata protobuf with Empty @@ -218,7 +233,7 @@ def _get_operation(self, project_id: str, region: str, operation_id: str) -> ope :param region: Required. The ID of the Google Cloud region that the service belongs to. :param operation_id: Required. The ID of the long-running operation. - :returns: The parsed operations_pb2.Operation. + :returns: The parsed pb2 operation. """ conn = self.get_conn() name = f"projects/{project_id}/locations/{region}/operations/{operation_id}" diff --git a/providers/src/airflow/providers/google/cloud/operators/financial_services.py b/providers/src/airflow/providers/google/cloud/operators/financial_services.py index f9593178e39a..ce0fb181223d 100644 --- a/providers/src/airflow/providers/google/cloud/operators/financial_services.py +++ b/providers/src/airflow/providers/google/cloud/operators/financial_services.py @@ -40,10 +40,9 @@ class FinancialServicesCreateInstanceOperator(GoogleCloudBaseOperator): :param kms_key_ring_id: Required. The ID of the Google Cloud KMS key ring containing the key to use for instance encryption :param kms_key_id: Required. The ID of the Google Cloud KMS key to use for instance encryption - :param discovery_doc: Discovery document for building the Financial Services API - as described `here `__ :param gcp_conn_id: Identifier of connection to Google Cloud Platform. Defaults to "google_cloud_default". + :param timeout: The maximum time to wait for a long-running operation to complete. """ # [START howto_operator_financial_services_create_instance_template_fields] @@ -104,12 +103,13 @@ class FinancialServicesDeleteInstanceOperator(GoogleCloudBaseOperator): For more information on how to use this operator, take a look at the guide: :ref:`howto/operator:FinancialServicesDeleteInstanceOperator` - :param instance_resource_uri: URI of the instance to delete (format: - 'projects//locations//instances/) - :param discovery_doc: Discovery document for building the Financial Services API - as described `here `__ + :param project_id: Required. The ID of the Google Cloud project that the service belongs to. + :param region: Required. The ID of the Google Cloud region that the service belongs to. + :param instance_id: Required. The ID of the instance, which is the final component of the + instances's name. :param gcp_conn_id: Identifier of connection to Google Cloud Platform. Defaults to "google_cloud_default". + :param timeout: The maximum time to wait for a long-running operation to complete. """ # [START howto_operator_financial_services_get_instance_template_fields] @@ -154,10 +154,10 @@ class FinancialServicesGetInstanceOperator(GoogleCloudBaseOperator): For more information on how to use this operator, take a look at the guide: :ref:`howto/operator:FinancialServicesGetInstanceOperator` - :param instance_resource_uri: URI of the instance to get (format: - 'projects//locations//instances/) - :param discovery_doc: Discovery document for building the Financial Services API - as described `here `__ + :param project_id: Required. The ID of the Google Cloud project that the service belongs to. + :param region: Required. The ID of the Google Cloud region that the service belongs to. + :param instance_id: Required. The ID of the instance, which is the final component of the + instances's name. :param gcp_conn_id: Identifier of connection to Google Cloud Platform. Defaults to "google_cloud_default". """ diff --git a/providers/src/airflow/providers/google/provider.yaml b/providers/src/airflow/providers/google/provider.yaml index ed7326796365..e3dc4d01f2fb 100644 --- a/providers/src/airflow/providers/google/provider.yaml +++ b/providers/src/airflow/providers/google/provider.yaml @@ -751,9 +751,6 @@ sensors: - integration-name: Google Dataproc Metastore python-modules: - airflow.providers.google.cloud.sensors.dataproc_metastore - - integration-name: Google Cloud Financial Services - python-modules: - - airflow.providers.google.cloud.sensors.financial_services - integration-name: Google Cloud Storage (GCS) python-modules: - airflow.providers.google.cloud.sensors.gcs