<commit_before>.. This file is automatically generated. Do not edit this file directly.

Google Cloud Composer Python Samples
===============================================================================

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
   :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=composer/rest/README.rst


This directory contains samples for Google Cloud Composer. `Google Cloud Composer`_ is a managed Apache Airflow service that helps you create, schedule, monitor and manage workflows. Cloud Composer automation helps you create Airflow environments quickly and use Airflow-native tools, such as the powerful Airflow web interface and command line tools, so you can focus on your workflows and not your infrastructure.




.. _Google Cloud Composer: https://cloud.google.com/composer/docs

Setup
-------------------------------------------------------------------------------


Authentication
++++++++++++++

This sample requires you to have authentication setup. Refer to the
`Authentication Getting Started Guide`_ for instructions on setting up
credentials for applications.

.. _Authentication Getting Started Guide:
    https://cloud.google.com/docs/authentication/getting-started

Install Dependencies
++++++++++++++++++++

#. Clone python-docs-samples and change directory to the sample directory you want to use.

    .. code-block:: bash

        $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git

#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.

   .. _Python Development Environment Setup Guide:
       https://cloud.google.com/python/setup

#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

    .. code-block:: bash

        $ virtualenv env
        $ source env/bin/activate

#. Install the dependencies needed to run the samples.

    .. code-block:: bash

        $ pip install -r requirements.txt

.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/

Samples
-------------------------------------------------------------------------------

Determine Cloud Storage path for DAGs
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
   :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=composer/rest/get_dag_prefix.py,composer/rest/README.rst




To run this sample:

.. code-block:: bash

    $ python get_dag_prefix.py

    usage: get_dag_prefix.py [-h] project_id location composer_environment

    Get a Cloud Composer environment via the REST API.

    This code sample gets a Cloud Composer environment resource and prints the
    Cloud Storage path used to store Apache Airflow DAGs.

    positional arguments:
      project_id            Your Project ID.
      location              Region of the Cloud Composer environent.
      composer_environment  Name of the Cloud Composer environent.

    optional arguments:
      -h, --help            show this help message and exit





.. _Google Cloud SDK: https://cloud.google.com/sdk/<commit_msg>Add documentation on command-line function to get client ID (#5712)<commit_after>.. This file is automatically generated. Do not edit this file directly.

Google Cloud Composer Python Samples
===============================================================================

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
   :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=composer/rest/README.rst


This directory contains samples for Google Cloud Composer. `Google Cloud Composer`_ is a managed Apache Airflow service that helps you create, schedule, monitor and manage workflows. Cloud Composer automation helps you create Airflow environments quickly and use Airflow-native tools, such as the powerful Airflow web interface and command line tools, so you can focus on your workflows and not your infrastructure.




.. _Google Cloud Composer: https://cloud.google.com/composer/docs

Setup
-------------------------------------------------------------------------------


Authentication
++++++++++++++

This sample requires you to have authentication setup. Refer to the
`Authentication Getting Started Guide`_ for instructions on setting up
credentials for applications.

.. _Authentication Getting Started Guide:
    https://cloud.google.com/docs/authentication/getting-started

Install Dependencies
++++++++++++++++++++

#. Clone python-docs-samples and change directory to the sample directory you want to use.

    .. code-block:: bash

        $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git

#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.

   .. _Python Development Environment Setup Guide:
       https://cloud.google.com/python/setup

#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

    .. code-block:: bash

        $ virtualenv env
        $ source env/bin/activate

#. Install the dependencies needed to run the samples.

    .. code-block:: bash

        $ pip install -r requirements.txt

.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/

Samples
-------------------------------------------------------------------------------

Determine client ID associated with a Cloud Composer environment
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

To run this sample:

.. code-block:: bash

    $ python get_client_id.py
    usage: get_client_id.py [-h] project_id location composer_environment

    Get the client ID associated with a Cloud Composer environment.

    positional arguments:
      project_id            Your Project ID.
      location              Region of the Cloud Composer environment.
      composer_environment  Name of the Cloud Composer environment.

    optional arguments:
      -h, --help            show this help message and exit

In case of any issue with `get_client_id.py`, you can also get the client ID using the following command, where `AIRFLOW_URL` would be the URL of your Airflow webserver (ex. `https://*****************-tp.appspot.com`_):

.. code-block:: bash

    $ curl -v AIRFLOW_URL 2>&1 >/dev/null | grep -o "client_id\=[A-Za-z0-9-]*\.apps\.googleusercontent\.com"

Determine Cloud Storage path for DAGs
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
   :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=composer/rest/get_dag_prefix.py,composer/rest/README.rst

To run this sample:

.. code-block:: bash

    $ python get_dag_prefix.py

    usage: get_dag_prefix.py [-h] project_id location composer_environment

    Get a Cloud Composer environment via the REST API.

    This code sample gets a Cloud Composer environment resource and prints the
    Cloud Storage path used to store Apache Airflow DAGs.

    positional arguments:
      project_id            Your Project ID.
      location              Region of the Cloud Composer environent.
      composer_environment  Name of the Cloud Composer environent.

    optional arguments:
      -h, --help            show this help message and exit

.. _Google Cloud SDK: https://cloud.google.com/sdk/
{'fraction_non_alphanumeric': 0.1730476673427992, 'fraction_numerical': 0.002028397565922921, 'mean_word_length': 3.098181818181818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 27, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4519186', 'n_tokens_mistral': 2087, 'n_tokens_neox': 1936, 'n_words': 701}