http://git-wip-us.apache.org/repos/asf/incubator-airflow-site/blob/11437c14/_modules/airflow/contrib/operators/gcs_to_bq.html ---------------------------------------------------------------------- diff --git a/_modules/airflow/contrib/operators/gcs_to_bq.html b/_modules/airflow/contrib/operators/gcs_to_bq.html index 1d61268..db2b756 100644 --- a/_modules/airflow/contrib/operators/gcs_to_bq.html +++ b/_modules/airflow/contrib/operators/gcs_to_bq.html @@ -91,7 +91,7 @@ <li class="toctree-l1"><a class="reference internal" href="../../../../start.html">Quick Start</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../installation.html">Installation</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../tutorial.html">Tutorial</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../../configuration.html">Configuration</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../howto/index.html">How-to Guides</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../ui.html">UI / Screenshots</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../concepts.html">Concepts</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../profiling.html">Data Profiling</a></li> @@ -99,8 +99,10 @@ <li class="toctree-l1"><a class="reference internal" href="../../../../scheduler.html">Scheduling & Triggers</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../plugins.html">Plugins</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../security.html">Security</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../timezone.html">Time zones</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../api.html">Experimental Rest API</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../integration.html">Integration</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../lineage.html">Lineage</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../faq.html">FAQ</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../code.html">API Reference</a></li> </ul> @@ -169,17 +171,22 @@ <h1>Source code for airflow.contrib.operators.gcs_to_bq</h1><div class="highlight"><pre> <span></span><span class="c1"># -*- coding: utf-8 -*-</span> <span class="c1">#</span> -<span class="c1"># Licensed under the Apache License, Version 2.0 (the "License");</span> -<span class="c1"># you may not use this file except in compliance with the License.</span> -<span class="c1"># You may obtain a copy of the License at</span> -<span class="c1">#</span> -<span class="c1"># http://www.apache.org/licenses/LICENSE-2.0</span> -<span class="c1">#</span> -<span class="c1"># Unless required by applicable law or agreed to in writing, software</span> -<span class="c1"># distributed under the License is distributed on an "AS IS" BASIS,</span> -<span class="c1"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span> -<span class="c1"># See the License for the specific language governing permissions and</span> -<span class="c1"># limitations under the License.</span> +<span class="c1"># Licensed to the Apache Software Foundation (ASF) under one</span> +<span class="c1"># or more contributor license agreements. See the NOTICE file</span> +<span class="c1"># distributed with this work for additional information</span> +<span class="c1"># regarding copyright ownership. The ASF licenses this file</span> +<span class="c1"># to you under the Apache License, Version 2.0 (the</span> +<span class="c1"># "License"); you may not use this file except in compliance</span> +<span class="c1"># with the License. You may obtain a copy of the License at</span> +<span class="c1"># </span> +<span class="c1"># http://www.apache.org/licenses/LICENSE-2.0</span> +<span class="c1"># </span> +<span class="c1"># Unless required by applicable law or agreed to in writing,</span> +<span class="c1"># software distributed under the License is distributed on an</span> +<span class="c1"># "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</span> +<span class="c1"># KIND, either express or implied. See the License for the</span> +<span class="c1"># specific language governing permissions and limitations</span> +<span class="c1"># under the License.</span> <span class="kn">import</span> <span class="nn">json</span> @@ -192,6 +199,92 @@ <div class="viewcode-block" id="GoogleCloudStorageToBigQueryOperator"><a class="viewcode-back" href="../../../../integration.html#airflow.contrib.operators.gcs_to_bq.GoogleCloudStorageToBigQueryOperator">[docs]</a><span class="k">class</span> <span class="nc">GoogleCloudStorageToBigQueryOperator</span><span class="p">(</span><span class="n">BaseOperator</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Loads files from Google cloud storage into BigQuery.</span> + +<span class="sd"> The schema to be used for the BigQuery table may be specified in one of</span> +<span class="sd"> two ways. You may either directly pass the schema fields in, or you may</span> +<span class="sd"> point the operator to a Google cloud storage object name. The object in</span> +<span class="sd"> Google cloud storage must be a JSON file with the schema fields in it.</span> + +<span class="sd"> :param bucket: The bucket to load from.</span> +<span class="sd"> :type bucket: string</span> +<span class="sd"> :param source_objects: List of Google cloud storage URIs to load from.</span> +<span class="sd"> If source_format is 'DATASTORE_BACKUP', the list must only contain a single URI.</span> +<span class="sd"> :type object: list</span> +<span class="sd"> :param destination_project_dataset_table: The dotted (<project>.)<dataset>.<table></span> +<span class="sd"> BigQuery table to load data into. If <project> is not included, project will</span> +<span class="sd"> be the project defined in the connection json.</span> +<span class="sd"> :type destination_project_dataset_table: string</span> +<span class="sd"> :param schema_fields: If set, the schema field list as defined here:</span> +<span class="sd"> https://cloud.google.com/bigquery/docs/reference/v2/jobs#configuration.load</span> +<span class="sd"> Should not be set when source_format is 'DATASTORE_BACKUP'.</span> +<span class="sd"> :type schema_fields: list</span> +<span class="sd"> :param schema_object: If set, a GCS object path pointing to a .json file that</span> +<span class="sd"> contains the schema for the table.</span> +<span class="sd"> :param schema_object: string</span> +<span class="sd"> :param source_format: File format to export.</span> +<span class="sd"> :type source_format: string</span> +<span class="sd"> :param compression: [Optional] The compression type of the data source.</span> +<span class="sd"> Possible values include GZIP and NONE.</span> +<span class="sd"> The default value is NONE.</span> +<span class="sd"> This setting is ignored for Google Cloud Bigtable,</span> +<span class="sd"> Google Cloud Datastore backups and Avro formats.</span> +<span class="sd"> :type compression: string</span> +<span class="sd"> :param create_disposition: The create disposition if the table doesn't exist.</span> +<span class="sd"> :type create_disposition: string</span> +<span class="sd"> :param skip_leading_rows: Number of rows to skip when loading from a CSV.</span> +<span class="sd"> :type skip_leading_rows: int</span> +<span class="sd"> :param write_disposition: The write disposition if the table already exists.</span> +<span class="sd"> :type write_disposition: string</span> +<span class="sd"> :param field_delimiter: The delimiter to use when loading from a CSV.</span> +<span class="sd"> :type field_delimiter: string</span> +<span class="sd"> :param max_bad_records: The maximum number of bad records that BigQuery can</span> +<span class="sd"> ignore when running the job.</span> +<span class="sd"> :type max_bad_records: int</span> +<span class="sd"> :param quote_character: The value that is used to quote data sections in a CSV file.</span> +<span class="sd"> :type quote_character: string</span> +<span class="sd"> :param ignore_unknown_values: [Optional] Indicates if BigQuery should allow</span> +<span class="sd"> extra values that are not represented in the table schema.</span> +<span class="sd"> If true, the extra values are ignored. If false, records with extra columns</span> +<span class="sd"> are treated as bad records, and if there are too many bad records, an</span> +<span class="sd"> invalid error is returned in the job result.</span> +<span class="sd"> :type ignore_unknown_values: bool</span> +<span class="sd"> :param allow_quoted_newlines: Whether to allow quoted newlines (true) or not (false).</span> +<span class="sd"> :type allow_quoted_newlines: boolean</span> +<span class="sd"> :param allow_jagged_rows: Accept rows that are missing trailing optional columns.</span> +<span class="sd"> The missing values are treated as nulls. If false, records with missing trailing</span> +<span class="sd"> columns are treated as bad records, and if there are too many bad records, an</span> +<span class="sd"> invalid error is returned in the job result. Only applicable to CSV, ignored</span> +<span class="sd"> for other formats.</span> +<span class="sd"> :type allow_jagged_rows: bool</span> +<span class="sd"> :param max_id_key: If set, the name of a column in the BigQuery table</span> +<span class="sd"> that's to be loaded. Thsi will be used to select the MAX value from</span> +<span class="sd"> BigQuery after the load occurs. The results will be returned by the</span> +<span class="sd"> execute() command, which in turn gets stored in XCom for future</span> +<span class="sd"> operators to use. This can be helpful with incremental loads--during</span> +<span class="sd"> future executions, you can pick up from the max ID.</span> +<span class="sd"> :type max_id_key: string</span> +<span class="sd"> :param bigquery_conn_id: Reference to a specific BigQuery hook.</span> +<span class="sd"> :type bigquery_conn_id: string</span> +<span class="sd"> :param google_cloud_storage_conn_id: Reference to a specific Google</span> +<span class="sd"> cloud storage hook.</span> +<span class="sd"> :type google_cloud_storage_conn_id: string</span> +<span class="sd"> :param delegate_to: The account to impersonate, if any. For this to</span> +<span class="sd"> work, the service account making the request must have domain-wide</span> +<span class="sd"> delegation enabled.</span> +<span class="sd"> :type delegate_to: string</span> +<span class="sd"> :param schema_update_options: Allows the schema of the destination</span> +<span class="sd"> table to be updated as a side effect of the load job.</span> +<span class="sd"> :type schema_update_options: list</span> +<span class="sd"> :param src_fmt_configs: configure optional fields specific to the source format</span> +<span class="sd"> :type src_fmt_configs: dict</span> +<span class="sd"> :param external_table: Flag to specify if the destination table should be</span> +<span class="sd"> a BigQuery external table. Default Value is False.</span> +<span class="sd"> :type external_table: bool</span> +<span class="sd"> :param time_partitioning: configure optional time partitioning fields i.e.</span> +<span class="sd"> partition by field, type and expiration as per API specifications.</span> +<span class="sd"> Note that 'field' is not available in concurrency with</span> +<span class="sd"> dataset.table$partition.</span> +<span class="sd"> :type time_partitioning: dict</span> <span class="sd"> """</span> <span class="n">template_fields</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'bucket'</span><span class="p">,</span> <span class="s1">'source_objects'</span><span class="p">,</span> <span class="s1">'schema_object'</span><span class="p">,</span> <span class="s1">'destination_project_dataset_table'</span><span class="p">)</span> @@ -199,96 +292,33 @@ <span class="n">ui_color</span> <span class="o">=</span> <span class="s1">'#f0eee4'</span> <span class="nd">@apply_defaults</span> - <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span> - <span class="bp">self</span><span class="p">,</span> - <span class="n">bucket</span><span class="p">,</span> - <span class="n">source_objects</span><span class="p">,</span> - <span class="n">destination_project_dataset_table</span><span class="p">,</span> - <span class="n">schema_fields</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> - <span class="n">schema_object</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> - <span class="n">source_format</span><span class="o">=</span><span class="s1">'CSV'</span><span class="p">,</span> - <span class="n">create_disposition</span><span class="o">=</span><span class="s1">'CREATE_IF_NEEDED'</span><span class="p">,</span> - <span class="n">skip_leading_rows</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> - <span class="n">write_disposition</span><span class="o">=</span><span class="s1">'WRITE_EMPTY'</span><span class="p">,</span> - <span class="n">field_delimiter</span><span class="o">=</span><span class="s1">','</span><span class="p">,</span> - <span class="n">max_bad_records</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> - <span class="n">quote_character</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> - <span class="n">allow_quoted_newlines</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> - <span class="n">allow_jagged_rows</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> - <span class="n">max_id_key</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> - <span class="n">bigquery_conn_id</span><span class="o">=</span><span class="s1">'bigquery_default'</span><span class="p">,</span> - <span class="n">google_cloud_storage_conn_id</span><span class="o">=</span><span class="s1">'google_cloud_storage_default'</span><span class="p">,</span> - <span class="n">delegate_to</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> - <span class="n">schema_update_options</span><span class="o">=</span><span class="p">(),</span> - <span class="n">src_fmt_configs</span><span class="o">=</span><span class="p">{},</span> - <span class="o">*</span><span class="n">args</span><span class="p">,</span> - <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> - <span class="sd">"""</span> -<span class="sd"> The schema to be used for the BigQuery table may be specified in one of</span> -<span class="sd"> two ways. You may either directly pass the schema fields in, or you may</span> -<span class="sd"> point the operator to a Google cloud storage object name. The object in</span> -<span class="sd"> Google cloud storage must be a JSON file with the schema fields in it.</span> - -<span class="sd"> :param bucket: The bucket to load from.</span> -<span class="sd"> :type bucket: string</span> -<span class="sd"> :param source_objects: List of Google cloud storage URIs to load from.</span> -<span class="sd"> If source_format is 'DATASTORE_BACKUP', the list must only contain a single URI.</span> -<span class="sd"> :type object: list</span> -<span class="sd"> :param destination_project_dataset_table: The dotted (<project>.)<dataset>.<table></span> -<span class="sd"> BigQuery table to load data into. If <project> is not included, project will</span> -<span class="sd"> be the project defined in the connection json.</span> -<span class="sd"> :type destination_project_dataset_table: string</span> -<span class="sd"> :param schema_fields: If set, the schema field list as defined here:</span> -<span class="sd"> https://cloud.google.com/bigquery/docs/reference/v2/jobs#configuration.load</span> -<span class="sd"> Should not be set when source_format is 'DATASTORE_BACKUP'.</span> -<span class="sd"> :type schema_fields: list</span> -<span class="sd"> :param schema_object: If set, a GCS object path pointing to a .json file that</span> -<span class="sd"> contains the schema for the table.</span> -<span class="sd"> :param schema_object: string</span> -<span class="sd"> :param source_format: File format to export.</span> -<span class="sd"> :type source_format: string</span> -<span class="sd"> :param create_disposition: The create disposition if the table doesn't exist.</span> -<span class="sd"> :type create_disposition: string</span> -<span class="sd"> :param skip_leading_rows: Number of rows to skip when loading from a CSV.</span> -<span class="sd"> :type skip_leading_rows: int</span> -<span class="sd"> :param write_disposition: The write disposition if the table already exists.</span> -<span class="sd"> :type write_disposition: string</span> -<span class="sd"> :param field_delimiter: The delimiter to use when loading from a CSV.</span> -<span class="sd"> :type field_delimiter: string</span> -<span class="sd"> :param max_bad_records: The maximum number of bad records that BigQuery can</span> -<span class="sd"> ignore when running the job.</span> -<span class="sd"> :type max_bad_records: int</span> -<span class="sd"> :param quote_character: The value that is used to quote data sections in a CSV file.</span> -<span class="sd"> :type quote_character: string</span> -<span class="sd"> :param allow_quoted_newlines: Whether to allow quoted newlines (true) or not (false).</span> -<span class="sd"> :type allow_quoted_newlines: boolean</span> -<span class="sd"> :param allow_jagged_rows: Accept rows that are missing trailing optional columns.</span> -<span class="sd"> The missing values are treated as nulls. If false, records with missing trailing columns</span> -<span class="sd"> are treated as bad records, and if there are too many bad records, an invalid error is</span> -<span class="sd"> returned in the job result. Only applicable to CSV, ignored for other formats.</span> -<span class="sd"> :type allow_jagged_rows: bool</span> -<span class="sd"> :param max_id_key: If set, the name of a column in the BigQuery table</span> -<span class="sd"> that's to be loaded. Thsi will be used to select the MAX value from</span> -<span class="sd"> BigQuery after the load occurs. The results will be returned by the</span> -<span class="sd"> execute() command, which in turn gets stored in XCom for future</span> -<span class="sd"> operators to use. This can be helpful with incremental loads--during</span> -<span class="sd"> future executions, you can pick up from the max ID.</span> -<span class="sd"> :type max_id_key: string</span> -<span class="sd"> :param bigquery_conn_id: Reference to a specific BigQuery hook.</span> -<span class="sd"> :type bigquery_conn_id: string</span> -<span class="sd"> :param google_cloud_storage_conn_id: Reference to a specific Google</span> -<span class="sd"> cloud storage hook.</span> -<span class="sd"> :type google_cloud_storage_conn_id: string</span> -<span class="sd"> :param delegate_to: The account to impersonate, if any. For this to</span> -<span class="sd"> work, the service account making the request must have domain-wide</span> -<span class="sd"> delegation enabled.</span> -<span class="sd"> :type delegate_to: string</span> -<span class="sd"> :param schema_update_options: Allows the schema of the desitination</span> -<span class="sd"> table to be updated as a side effect of the load job.</span> -<span class="sd"> :type schema_update_options: list</span> -<span class="sd"> :param src_fmt_configs: configure optional fields specific to the source format</span> -<span class="sd"> :type src_fmt_configs: dict</span> -<span class="sd"> """</span> + <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> + <span class="n">bucket</span><span class="p">,</span> + <span class="n">source_objects</span><span class="p">,</span> + <span class="n">destination_project_dataset_table</span><span class="p">,</span> + <span class="n">schema_fields</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">schema_object</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">source_format</span><span class="o">=</span><span class="s1">'CSV'</span><span class="p">,</span> + <span class="n">compression</span><span class="o">=</span><span class="s1">'NONE'</span><span class="p">,</span> + <span class="n">create_disposition</span><span class="o">=</span><span class="s1">'CREATE_IF_NEEDED'</span><span class="p">,</span> + <span class="n">skip_leading_rows</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> + <span class="n">write_disposition</span><span class="o">=</span><span class="s1">'WRITE_EMPTY'</span><span class="p">,</span> + <span class="n">field_delimiter</span><span class="o">=</span><span class="s1">','</span><span class="p">,</span> + <span class="n">max_bad_records</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> + <span class="n">quote_character</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">ignore_unknown_values</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">allow_quoted_newlines</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">allow_jagged_rows</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">max_id_key</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">bigquery_conn_id</span><span class="o">=</span><span class="s1">'bigquery_default'</span><span class="p">,</span> + <span class="n">google_cloud_storage_conn_id</span><span class="o">=</span><span class="s1">'google_cloud_default'</span><span class="p">,</span> + <span class="n">delegate_to</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">schema_update_options</span><span class="o">=</span><span class="p">(),</span> + <span class="n">src_fmt_configs</span><span class="o">=</span><span class="p">{},</span> + <span class="n">external_table</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">time_partitioning</span><span class="o">=</span><span class="p">{},</span> + <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="nb">super</span><span class="p">(</span><span class="n">GoogleCloudStorageToBigQueryOperator</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># GCS config</span> @@ -300,14 +330,17 @@ <span class="bp">self</span><span class="o">.</span><span class="n">destination_project_dataset_table</span> <span class="o">=</span> <span class="n">destination_project_dataset_table</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_fields</span> <span class="o">=</span> <span class="n">schema_fields</span> <span class="bp">self</span><span class="o">.</span><span class="n">source_format</span> <span class="o">=</span> <span class="n">source_format</span> + <span class="bp">self</span><span class="o">.</span><span class="n">compression</span> <span class="o">=</span> <span class="n">compression</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_disposition</span> <span class="o">=</span> <span class="n">create_disposition</span> <span class="bp">self</span><span class="o">.</span><span class="n">skip_leading_rows</span> <span class="o">=</span> <span class="n">skip_leading_rows</span> <span class="bp">self</span><span class="o">.</span><span class="n">write_disposition</span> <span class="o">=</span> <span class="n">write_disposition</span> <span class="bp">self</span><span class="o">.</span><span class="n">field_delimiter</span> <span class="o">=</span> <span class="n">field_delimiter</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_bad_records</span> <span class="o">=</span> <span class="n">max_bad_records</span> <span class="bp">self</span><span class="o">.</span><span class="n">quote_character</span> <span class="o">=</span> <span class="n">quote_character</span> + <span class="bp">self</span><span class="o">.</span><span class="n">ignore_unknown_values</span> <span class="o">=</span> <span class="n">ignore_unknown_values</span> <span class="bp">self</span><span class="o">.</span><span class="n">allow_quoted_newlines</span> <span class="o">=</span> <span class="n">allow_quoted_newlines</span> <span class="bp">self</span><span class="o">.</span><span class="n">allow_jagged_rows</span> <span class="o">=</span> <span class="n">allow_jagged_rows</span> + <span class="bp">self</span><span class="o">.</span><span class="n">external_table</span> <span class="o">=</span> <span class="n">external_table</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_id_key</span> <span class="o">=</span> <span class="n">max_id_key</span> <span class="bp">self</span><span class="o">.</span><span class="n">bigquery_conn_id</span> <span class="o">=</span> <span class="n">bigquery_conn_id</span> @@ -316,6 +349,7 @@ <span class="bp">self</span><span class="o">.</span><span class="n">schema_update_options</span> <span class="o">=</span> <span class="n">schema_update_options</span> <span class="bp">self</span><span class="o">.</span><span class="n">src_fmt_configs</span> <span class="o">=</span> <span class="n">src_fmt_configs</span> + <span class="bp">self</span><span class="o">.</span><span class="n">time_partitioning</span> <span class="o">=</span> <span class="n">time_partitioning</span> <span class="k">def</span> <span class="nf">execute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">context</span><span class="p">):</span> <span class="n">bq_hook</span> <span class="o">=</span> <span class="n">BigQueryHook</span><span class="p">(</span><span class="n">bigquery_conn_id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">bigquery_conn_id</span><span class="p">,</span> @@ -336,21 +370,41 @@ <span class="k">for</span> <span class="n">source_object</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">source_objects</span><span class="p">]</span> <span class="n">conn</span> <span class="o">=</span> <span class="n">bq_hook</span><span class="o">.</span><span class="n">get_conn</span><span class="p">()</span> <span class="n">cursor</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">cursor</span><span class="p">()</span> - <span class="n">cursor</span><span class="o">.</span><span class="n">run_load</span><span class="p">(</span> - <span class="n">destination_project_dataset_table</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">destination_project_dataset_table</span><span class="p">,</span> - <span class="n">schema_fields</span><span class="o">=</span><span class="n">schema_fields</span><span class="p">,</span> - <span class="n">source_uris</span><span class="o">=</span><span class="n">source_uris</span><span class="p">,</span> - <span class="n">source_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">source_format</span><span class="p">,</span> - <span class="n">create_disposition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">create_disposition</span><span class="p">,</span> - <span class="n">skip_leading_rows</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">skip_leading_rows</span><span class="p">,</span> - <span class="n">write_disposition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">write_disposition</span><span class="p">,</span> - <span class="n">field_delimiter</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">field_delimiter</span><span class="p">,</span> - <span class="n">max_bad_records</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">max_bad_records</span><span class="p">,</span> - <span class="n">quote_character</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">quote_character</span><span class="p">,</span> - <span class="n">allow_quoted_newlines</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">allow_quoted_newlines</span><span class="p">,</span> - <span class="n">allow_jagged_rows</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">allow_jagged_rows</span><span class="p">,</span> - <span class="n">schema_update_options</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">schema_update_options</span><span class="p">,</span> - <span class="n">src_fmt_configs</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">src_fmt_configs</span><span class="p">)</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">external_table</span><span class="p">:</span> + <span class="n">cursor</span><span class="o">.</span><span class="n">create_external_table</span><span class="p">(</span> + <span class="n">external_project_dataset_table</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">destination_project_dataset_table</span><span class="p">,</span> + <span class="n">schema_fields</span><span class="o">=</span><span class="n">schema_fields</span><span class="p">,</span> + <span class="n">source_uris</span><span class="o">=</span><span class="n">source_uris</span><span class="p">,</span> + <span class="n">source_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">source_format</span><span class="p">,</span> + <span class="n">compression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">compression</span><span class="p">,</span> + <span class="n">skip_leading_rows</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">skip_leading_rows</span><span class="p">,</span> + <span class="n">field_delimiter</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">field_delimiter</span><span class="p">,</span> + <span class="n">max_bad_records</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">max_bad_records</span><span class="p">,</span> + <span class="n">quote_character</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">quote_character</span><span class="p">,</span> + <span class="n">ignore_unknown_values</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ignore_unknown_values</span><span class="p">,</span> + <span class="n">allow_quoted_newlines</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">allow_quoted_newlines</span><span class="p">,</span> + <span class="n">allow_jagged_rows</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">allow_jagged_rows</span><span class="p">,</span> + <span class="n">src_fmt_configs</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">src_fmt_configs</span> + <span class="p">)</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">cursor</span><span class="o">.</span><span class="n">run_load</span><span class="p">(</span> + <span class="n">destination_project_dataset_table</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">destination_project_dataset_table</span><span class="p">,</span> + <span class="n">schema_fields</span><span class="o">=</span><span class="n">schema_fields</span><span class="p">,</span> + <span class="n">source_uris</span><span class="o">=</span><span class="n">source_uris</span><span class="p">,</span> + <span class="n">source_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">source_format</span><span class="p">,</span> + <span class="n">create_disposition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">create_disposition</span><span class="p">,</span> + <span class="n">skip_leading_rows</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">skip_leading_rows</span><span class="p">,</span> + <span class="n">write_disposition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">write_disposition</span><span class="p">,</span> + <span class="n">field_delimiter</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">field_delimiter</span><span class="p">,</span> + <span class="n">max_bad_records</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">max_bad_records</span><span class="p">,</span> + <span class="n">quote_character</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">quote_character</span><span class="p">,</span> + <span class="n">ignore_unknown_values</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ignore_unknown_values</span><span class="p">,</span> + <span class="n">allow_quoted_newlines</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">allow_quoted_newlines</span><span class="p">,</span> + <span class="n">allow_jagged_rows</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">allow_jagged_rows</span><span class="p">,</span> + <span class="n">schema_update_options</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">schema_update_options</span><span class="p">,</span> + <span class="n">src_fmt_configs</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">src_fmt_configs</span><span class="p">,</span> + <span class="n">time_partitioning</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">time_partitioning</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_id_key</span><span class="p">:</span> <span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s1">'SELECT MAX(</span><span class="si">{}</span><span class="s1">) FROM </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
http://git-wip-us.apache.org/repos/asf/incubator-airflow-site/blob/11437c14/_modules/airflow/contrib/operators/gcs_to_gcs.html ---------------------------------------------------------------------- diff --git a/_modules/airflow/contrib/operators/gcs_to_gcs.html b/_modules/airflow/contrib/operators/gcs_to_gcs.html new file mode 100644 index 0000000..7379d8a --- /dev/null +++ b/_modules/airflow/contrib/operators/gcs_to_gcs.html @@ -0,0 +1,365 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>airflow.contrib.operators.gcs_to_gcs — Airflow Documentation</title> + + + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + + + + + + <link rel="index" title="Index" + href="../../../../genindex.html"/> + <link rel="search" title="Search" href="../../../../search.html"/> + <link rel="top" title="Airflow Documentation" href="../../../../index.html"/> + <link rel="up" title="Module code" href="../../../index.html"/> + + + <script src="../../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../../index.html" class="icon icon-home"> Airflow + + + + </a> + + + + + + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../project.html">Project</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../license.html">License</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../start.html">Quick Start</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../installation.html">Installation</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../tutorial.html">Tutorial</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../howto/index.html">How-to Guides</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../ui.html">UI / Screenshots</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../concepts.html">Concepts</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../profiling.html">Data Profiling</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../cli.html">Command Line Interface</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../scheduler.html">Scheduling & Triggers</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../plugins.html">Plugins</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../security.html">Security</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../timezone.html">Time zones</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../api.html">Experimental Rest API</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../integration.html">Integration</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../lineage.html">Lineage</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../faq.html">FAQ</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../code.html">API Reference</a></li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">Airflow</a> + + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + + + + + + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + + <ul class="wy-breadcrumbs"> + + <li><a href="../../../../index.html">Docs</a> »</li> + + <li><a href="../../../index.html">Module code</a> »</li> + + <li>airflow.contrib.operators.gcs_to_gcs</li> + + + <li class="wy-breadcrumbs-aside"> + + + + </li> + + </ul> + + + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for airflow.contrib.operators.gcs_to_gcs</h1><div class="highlight"><pre> +<span></span><span class="c1"># -*- coding: utf-8 -*-</span> +<span class="c1">#</span> +<span class="c1"># Licensed to the Apache Software Foundation (ASF) under one</span> +<span class="c1"># or more contributor license agreements. See the NOTICE file</span> +<span class="c1"># distributed with this work for additional information</span> +<span class="c1"># regarding copyright ownership. The ASF licenses this file</span> +<span class="c1"># to you under the Apache License, Version 2.0 (the</span> +<span class="c1"># "License"); you may not use this file except in compliance</span> +<span class="c1"># with the License. You may obtain a copy of the License at</span> +<span class="c1">#</span> +<span class="c1"># http://www.apache.org/licenses/LICENSE-2.0</span> +<span class="c1">#</span> +<span class="c1"># Unless required by applicable law or agreed to in writing,</span> +<span class="c1"># software distributed under the License is distributed on an</span> +<span class="c1"># "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</span> +<span class="c1"># KIND, either express or implied. See the License for the</span> +<span class="c1"># specific language governing permissions and limitations</span> +<span class="c1"># under the License.</span> + +<span class="kn">from</span> <span class="nn">airflow.contrib.hooks.gcs_hook</span> <span class="k">import</span> <span class="n">GoogleCloudStorageHook</span> +<span class="kn">from</span> <span class="nn">airflow.models</span> <span class="k">import</span> <span class="n">BaseOperator</span> +<span class="kn">from</span> <span class="nn">airflow.utils.decorators</span> <span class="k">import</span> <span class="n">apply_defaults</span> + + +<div class="viewcode-block" id="GoogleCloudStorageToGoogleCloudStorageOperator"><a class="viewcode-back" href="../../../../integration.html#airflow.contrib.operators.gcs_to_gcs.GoogleCloudStorageToGoogleCloudStorageOperator">[docs]</a><span class="k">class</span> <span class="nc">GoogleCloudStorageToGoogleCloudStorageOperator</span><span class="p">(</span><span class="n">BaseOperator</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Copies objects from a bucket to another, with renaming if requested.</span> + +<span class="sd"> :param source_bucket: The source Google cloud storage bucket where the object is.</span> +<span class="sd"> :type source_bucket: string</span> +<span class="sd"> :param source_object: The source name of the object to copy in the Google cloud</span> +<span class="sd"> storage bucket.</span> +<span class="sd"> If wildcards are used in this argument:</span> +<span class="sd"> You can use only one wildcard for objects (filenames) within your</span> +<span class="sd"> bucket. The wildcard can appear inside the object name or at the</span> +<span class="sd"> end of the object name. Appending a wildcard to the bucket name is</span> +<span class="sd"> unsupported.</span> +<span class="sd"> :type source_object: string</span> +<span class="sd"> :param destination_bucket: The destination Google cloud storage bucket</span> +<span class="sd"> where the object should be.</span> +<span class="sd"> :type destination_bucket: string</span> +<span class="sd"> :param destination_object: The destination name of the object in the</span> +<span class="sd"> destination Google cloud</span> +<span class="sd"> storage bucket.</span> +<span class="sd"> If a wildcard is supplied in the source_object argument, this is the</span> +<span class="sd"> prefix that will be prepended to the final destination objects' paths.</span> +<span class="sd"> :type destination_object: string</span> +<span class="sd"> :param move_object: When move object is True, the object is moved instead</span> +<span class="sd"> of copied to the new location.</span> +<span class="sd"> This is the equivalent of a mv command as opposed to a</span> +<span class="sd"> cp command.</span> +<span class="sd"> :type move_object: bool</span> +<span class="sd"> :param google_cloud_storage_conn_id: The connection ID to use when</span> +<span class="sd"> connecting to Google cloud storage.</span> +<span class="sd"> :type google_cloud_storage_conn_id: string</span> +<span class="sd"> :param delegate_to: The account to impersonate, if any.</span> +<span class="sd"> For this to work, the service account making the request must have</span> +<span class="sd"> domain-wide delegation enabled.</span> +<span class="sd"> :type delegate_to: string</span> +<span class="sd"> """</span> + <span class="n">template_fields</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'source_bucket'</span><span class="p">,</span> <span class="s1">'source_object'</span><span class="p">,</span> <span class="s1">'destination_bucket'</span><span class="p">,</span> + <span class="s1">'destination_object'</span><span class="p">,)</span> + <span class="n">ui_color</span> <span class="o">=</span> <span class="s1">'#f0eee4'</span> + + <span class="nd">@apply_defaults</span> + <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> + <span class="n">source_bucket</span><span class="p">,</span> + <span class="n">source_object</span><span class="p">,</span> + <span class="n">destination_bucket</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">destination_object</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">move_object</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="n">google_cloud_storage_conn_id</span><span class="o">=</span><span class="s1">'google_cloud_default'</span><span class="p">,</span> + <span class="n">delegate_to</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="o">*</span><span class="n">args</span><span class="p">,</span> + <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + <span class="nb">super</span><span class="p">(</span><span class="n">GoogleCloudStorageToGoogleCloudStorageOperator</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span> + <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">source_bucket</span> <span class="o">=</span> <span class="n">source_bucket</span> + <span class="bp">self</span><span class="o">.</span><span class="n">source_object</span> <span class="o">=</span> <span class="n">source_object</span> + <span class="bp">self</span><span class="o">.</span><span class="n">destination_bucket</span> <span class="o">=</span> <span class="n">destination_bucket</span> + <span class="bp">self</span><span class="o">.</span><span class="n">destination_object</span> <span class="o">=</span> <span class="n">destination_object</span> + <span class="bp">self</span><span class="o">.</span><span class="n">move_object</span> <span class="o">=</span> <span class="n">move_object</span> + <span class="bp">self</span><span class="o">.</span><span class="n">google_cloud_storage_conn_id</span> <span class="o">=</span> <span class="n">google_cloud_storage_conn_id</span> + <span class="bp">self</span><span class="o">.</span><span class="n">delegate_to</span> <span class="o">=</span> <span class="n">delegate_to</span> + + <span class="k">def</span> <span class="nf">execute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">context</span><span class="p">):</span> + + <span class="n">hook</span> <span class="o">=</span> <span class="n">GoogleCloudStorageHook</span><span class="p">(</span> + <span class="n">google_cloud_storage_conn_id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">google_cloud_storage_conn_id</span><span class="p">,</span> + <span class="n">delegate_to</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">delegate_to</span> + <span class="p">)</span> + + <span class="k">if</span> <span class="s1">'*'</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">source_object</span><span class="p">:</span> + <span class="n">wildcard_position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">source_object</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s1">'*'</span><span class="p">)</span> + <span class="n">objects</span> <span class="o">=</span> <span class="n">hook</span><span class="o">.</span><span class="n">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">source_bucket</span><span class="p">,</span> + <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">source_object</span><span class="p">[:</span><span class="n">wildcard_position</span><span class="p">],</span> + <span class="n">delimiter</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">source_object</span><span class="p">[</span><span class="n">wildcard_position</span> <span class="o">+</span> <span class="mi">1</span><span class="p">:])</span> + + <span class="k">for</span> <span class="n">source_object</span> <span class="ow">in</span> <span class="n">objects</span><span class="p">:</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">destination_object</span><span class="p">:</span> + <span class="n">destination_object</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">/</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">destination_object</span><span class="p">,</span> + <span class="n">source_object</span><span class="p">[</span><span class="n">wildcard_position</span><span class="p">:])</span> + <span class="k">else</span><span class="p">:</span> + <span class="n">destination_object</span> <span class="o">=</span> <span class="n">source_object</span> + <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">'Executing copy of gs://</span><span class="si">{0}</span><span class="s1">/</span><span class="si">{1}</span><span class="s1"> to '</span> + <span class="s1">'gs://</span><span class="si">{2}</span><span class="s1">/</span><span class="si">{3}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">source_bucket</span><span class="p">,</span> + <span class="n">source_object</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">destination_bucket</span><span class="p">,</span> + <span class="n">destination_object</span><span class="p">))</span> + + <span class="n">hook</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">source_bucket</span><span class="p">,</span> <span class="n">source_object</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">destination_bucket</span><span class="p">,</span> <span class="n">destination_object</span><span class="p">)</span> + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">move_object</span><span class="p">:</span> + <span class="n">hook</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">source_bucket</span><span class="p">,</span> <span class="n">source_object</span><span class="p">)</span> + + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span> + <span class="s1">'Executing copy of gs://</span><span class="si">{0}</span><span class="s1">/</span><span class="si">{1}</span><span class="s1"> to '</span> + <span class="s1">'gs://</span><span class="si">{2}</span><span class="s1">/</span><span class="si">{3}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> + <span class="bp">self</span><span class="o">.</span><span class="n">source_bucket</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">source_object</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">destination_bucket</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">source_bucket</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">destination_object</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">source_object</span> + <span class="p">)</span> + <span class="p">)</span> + <span class="n">hook</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">source_bucket</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">source_object</span><span class="p">,</span> + <span class="bp">self</span><span class="o">.</span><span class="n">destination_bucket</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">destination_object</span><span class="p">)</span> + + <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">move_object</span><span class="p">:</span> + <span class="n">hook</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">source_bucket</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">source_object</span><span class="p">)</span></div> +</pre></div> + + </div> + <div class="articleComments"> + + </div> + </div> + <footer> + + + <hr/> + + <div role="contentinfo"> + <p> + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../../', + VERSION:'', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true, + SOURCELINK_SUFFIX: '.txt' + }; + </script> + <script type="text/javascript" src="../../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-airflow-site/blob/11437c14/_modules/airflow/contrib/operators/gcs_to_s3.html ---------------------------------------------------------------------- diff --git a/_modules/airflow/contrib/operators/gcs_to_s3.html b/_modules/airflow/contrib/operators/gcs_to_s3.html new file mode 100644 index 0000000..14a6549 --- /dev/null +++ b/_modules/airflow/contrib/operators/gcs_to_s3.html @@ -0,0 +1,347 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>airflow.contrib.operators.gcs_to_s3 — Airflow Documentation</title> + + + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> + + + + + + <link rel="index" title="Index" + href="../../../../genindex.html"/> + <link rel="search" title="Search" href="../../../../search.html"/> + <link rel="top" title="Airflow Documentation" href="../../../../index.html"/> + <link rel="up" title="Module code" href="../../../index.html"/> + + + <script src="../../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../../index.html" class="icon icon-home"> Airflow + + + + </a> + + + + + + + +<div role="search"> + <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> + <input type="text" name="q" placeholder="Search docs" /> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../../../../project.html">Project</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../license.html">License</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../start.html">Quick Start</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../installation.html">Installation</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../tutorial.html">Tutorial</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../howto/index.html">How-to Guides</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../ui.html">UI / Screenshots</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../concepts.html">Concepts</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../profiling.html">Data Profiling</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../cli.html">Command Line Interface</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../scheduler.html">Scheduling & Triggers</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../plugins.html">Plugins</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../security.html">Security</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../timezone.html">Time zones</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../api.html">Experimental Rest API</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../integration.html">Integration</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../lineage.html">Lineage</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../faq.html">FAQ</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../code.html">API Reference</a></li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../../index.html">Airflow</a> + + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + + + + + + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + + <ul class="wy-breadcrumbs"> + + <li><a href="../../../../index.html">Docs</a> »</li> + + <li><a href="../../../index.html">Module code</a> »</li> + + <li>airflow.contrib.operators.gcs_to_s3</li> + + + <li class="wy-breadcrumbs-aside"> + + + + </li> + + </ul> + + + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <h1>Source code for airflow.contrib.operators.gcs_to_s3</h1><div class="highlight"><pre> +<span></span><span class="c1"># -*- coding: utf-8 -*-</span> +<span class="c1">#</span> +<span class="c1"># Licensed to the Apache Software Foundation (ASF) under one</span> +<span class="c1"># or more contributor license agreements. See the NOTICE file</span> +<span class="c1"># distributed with this work for additional information</span> +<span class="c1"># regarding copyright ownership. The ASF licenses this file</span> +<span class="c1"># to you under the Apache License, Version 2.0 (the</span> +<span class="c1"># "License"); you may not use this file except in compliance</span> +<span class="c1"># with the License. You may obtain a copy of the License at</span> +<span class="c1"># </span> +<span class="c1"># http://www.apache.org/licenses/LICENSE-2.0</span> +<span class="c1"># </span> +<span class="c1"># Unless required by applicable law or agreed to in writing,</span> +<span class="c1"># software distributed under the License is distributed on an</span> +<span class="c1"># "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</span> +<span class="c1"># KIND, either express or implied. See the License for the</span> +<span class="c1"># specific language governing permissions and limitations</span> +<span class="c1"># under the License.</span> + +<span class="kn">from</span> <span class="nn">airflow.contrib.hooks.gcs_hook</span> <span class="k">import</span> <span class="n">GoogleCloudStorageHook</span> +<span class="kn">from</span> <span class="nn">airflow.contrib.operators.gcs_list_operator</span> <span class="k">import</span> <span class="n">GoogleCloudStorageListOperator</span> +<span class="kn">from</span> <span class="nn">airflow.utils.decorators</span> <span class="k">import</span> <span class="n">apply_defaults</span> +<span class="kn">from</span> <span class="nn">airflow.hooks.S3_hook</span> <span class="k">import</span> <span class="n">S3Hook</span> + + +<div class="viewcode-block" id="GoogleCloudStorageToS3Operator"><a class="viewcode-back" href="../../../../code.html#airflow.contrib.operators.gcs_to_s3.GoogleCloudStorageToS3Operator">[docs]</a><span class="k">class</span> <span class="nc">GoogleCloudStorageToS3Operator</span><span class="p">(</span><span class="n">GoogleCloudStorageListOperator</span><span class="p">):</span> + <span class="sd">"""</span> +<span class="sd"> Synchronizes a Google Cloud Storage bucket with an S3 bucket.</span> + +<span class="sd"> :param bucket: The Google Cloud Storage bucket to find the objects.</span> +<span class="sd"> :type bucket: string</span> +<span class="sd"> :param prefix: Prefix string which filters objects whose name begin with this prefix</span> +<span class="sd"> :type prefix: string</span> +<span class="sd"> :param delimiter: The delimiter by which you want to filter the objects.</span> +<span class="sd"> For e.g to lists the CSV files from in a directory in GCS you would use</span> +<span class="sd"> delimiter='.csv'.</span> +<span class="sd"> :type delimiter: string</span> +<span class="sd"> :param google_cloud_storage_conn_id: The connection ID to use when</span> +<span class="sd"> connecting to Google Cloud Storage.</span> +<span class="sd"> :type google_cloud_storage_conn_id: string</span> +<span class="sd"> :param delegate_to: The account to impersonate, if any.</span> +<span class="sd"> For this to work, the service account making the request must have</span> +<span class="sd"> domain-wide delegation enabled.</span> +<span class="sd"> :type delegate_to: string</span> +<span class="sd"> :param dest_aws_conn_id: The destination S3 connection</span> +<span class="sd"> :type dest_aws_conn_id: str</span> +<span class="sd"> :param dest_s3_key: The base S3 key to be used to store the files</span> +<span class="sd"> :type dest_s3_key: str</span> +<span class="sd"> """</span> + <span class="n">template_fields</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'bucket'</span><span class="p">,</span> <span class="s1">'prefix'</span><span class="p">,</span> <span class="s1">'delimiter'</span><span class="p">,</span> <span class="s1">'dest_s3_key'</span><span class="p">)</span> + <span class="n">ui_color</span> <span class="o">=</span> <span class="s1">'#f0eee4'</span> + + <span class="nd">@apply_defaults</span> + <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> + <span class="n">bucket</span><span class="p">,</span> + <span class="n">prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">delimiter</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">google_cloud_storage_conn_id</span><span class="o">=</span><span class="s1">'google_cloud_storage_default'</span><span class="p">,</span> + <span class="n">delegate_to</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">dest_aws_conn_id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">dest_s3_key</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> + <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> + <span class="o">*</span><span class="n">args</span><span class="p">,</span> + <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> + + <span class="nb">super</span><span class="p">(</span><span class="n">GoogleCloudStorageToS3Operator</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span> + <span class="n">bucket</span><span class="o">=</span><span class="n">bucket</span><span class="p">,</span> + <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> + <span class="n">delimiter</span><span class="o">=</span><span class="n">delimiter</span><span class="p">,</span> + <span class="n">google_cloud_storage_conn_id</span><span class="o">=</span><span class="n">google_cloud_storage_conn_id</span><span class="p">,</span> + <span class="n">delegate_to</span><span class="o">=</span><span class="n">delegate_to</span><span class="p">,</span> + <span class="o">*</span><span class="n">args</span><span class="p">,</span> + <span class="o">**</span><span class="n">kwargs</span> + <span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">dest_aws_conn_id</span> <span class="o">=</span> <span class="n">dest_aws_conn_id</span> + <span class="bp">self</span><span class="o">.</span><span class="n">dest_s3_key</span> <span class="o">=</span> <span class="n">dest_s3_key</span> + <span class="bp">self</span><span class="o">.</span><span class="n">replace</span> <span class="o">=</span> <span class="n">replace</span> + + <span class="k">def</span> <span class="nf">execute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">context</span><span class="p">):</span> + <span class="c1"># use the super to list all files in an Google Cloud Storage bucket</span> + <span class="n">files</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">GoogleCloudStorageToS3Operator</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">context</span><span class="p">)</span> + <span class="n">s3_hook</span> <span class="o">=</span> <span class="n">S3Hook</span><span class="p">(</span><span class="n">aws_conn_id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dest_aws_conn_id</span><span class="p">)</span> + + <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">replace</span><span class="p">:</span> + <span class="c1"># if we are not replacing -> list all files in the S3 bucket</span> + <span class="c1"># and only keep those files which are present in</span> + <span class="c1"># Google Cloud Storage and not in S3</span> + <span class="n">bucket_name</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">S3Hook</span><span class="o">.</span><span class="n">parse_s3_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dest_s3_key</span><span class="p">)</span> + <span class="n">existing_files</span> <span class="o">=</span> <span class="n">s3_hook</span><span class="o">.</span><span class="n">list_keys</span><span class="p">(</span><span class="n">bucket_name</span><span class="p">)</span> + <span class="n">files</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">files</span><span class="p">)</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">existing_files</span><span class="p">)</span> + + <span class="k">if</span> <span class="n">files</span><span class="p">:</span> + <span class="n">hook</span> <span class="o">=</span> <span class="n">GoogleCloudStorageHook</span><span class="p">(</span> + <span class="n">google_cloud_storage_conn_id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">google_cloud_storage_conn_id</span><span class="p">,</span> + <span class="n">delegate_to</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">delegate_to</span> + <span class="p">)</span> + + <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span> + <span class="n">file_bytes</span> <span class="o">=</span> <span class="n">hook</span><span class="o">.</span><span class="n">download</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">bucket</span><span class="p">,</span> <span class="n">file</span><span class="p">)</span> + + <span class="n">dest_key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dest_s3_key</span> <span class="o">+</span> <span class="n">file</span> + <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Saving file to </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">dest_key</span><span class="p">)</span> + + <span class="n">s3_hook</span><span class="o">.</span><span class="n">load_bytes</span><span class="p">(</span><span class="n">file_bytes</span><span class="p">,</span> + <span class="n">key</span><span class="o">=</span><span class="n">dest_key</span><span class="p">,</span> + <span class="n">replace</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">replace</span><span class="p">)</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"All done, uploaded </span><span class="si">%d</span><span class="s2"> files to S3"</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">files</span><span class="p">))</span> + <span class="k">else</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"In sync, no files needed to be uploaded to S3"</span><span class="p">)</span> + + <span class="k">return</span> <span class="n">files</span></div> +</pre></div> + + </div> + <div class="articleComments"> + + </div> + </div> + <footer> + + + <hr/> + + <div role="contentinfo"> + <p> + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../../', + VERSION:'', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true, + SOURCELINK_SUFFIX: '.txt' + }; + </script> + <script type="text/javascript" src="../../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-airflow-site/blob/11437c14/_modules/airflow/contrib/operators/hipchat_operator.html ---------------------------------------------------------------------- diff --git a/_modules/airflow/contrib/operators/hipchat_operator.html b/_modules/airflow/contrib/operators/hipchat_operator.html index 1e04bf3..4f218b7 100644 --- a/_modules/airflow/contrib/operators/hipchat_operator.html +++ b/_modules/airflow/contrib/operators/hipchat_operator.html @@ -91,7 +91,7 @@ <li class="toctree-l1"><a class="reference internal" href="../../../../start.html">Quick Start</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../installation.html">Installation</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../tutorial.html">Tutorial</a></li> -<li class="toctree-l1"><a class="reference internal" href="../../../../configuration.html">Configuration</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../howto/index.html">How-to Guides</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../ui.html">UI / Screenshots</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../concepts.html">Concepts</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../profiling.html">Data Profiling</a></li> @@ -99,8 +99,10 @@ <li class="toctree-l1"><a class="reference internal" href="../../../../scheduler.html">Scheduling & Triggers</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../plugins.html">Plugins</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../security.html">Security</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../timezone.html">Time zones</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../api.html">Experimental Rest API</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../integration.html">Integration</a></li> +<li class="toctree-l1"><a class="reference internal" href="../../../../lineage.html">Lineage</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../faq.html">FAQ</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../code.html">API Reference</a></li> </ul> @@ -169,17 +171,22 @@ <h1>Source code for airflow.contrib.operators.hipchat_operator</h1><div class="highlight"><pre> <span></span><span class="c1"># -*- coding: utf-8 -*-</span> <span class="c1">#</span> -<span class="c1"># Licensed under the Apache License, Version 2.0 (the "License");</span> -<span class="c1"># you may not use this file except in compliance with the License.</span> -<span class="c1"># You may obtain a copy of the License at</span> -<span class="c1">#</span> -<span class="c1"># http://www.apache.org/licenses/LICENSE-2.0</span> -<span class="c1">#</span> -<span class="c1"># Unless required by applicable law or agreed to in writing, software</span> -<span class="c1"># distributed under the License is distributed on an "AS IS" BASIS,</span> -<span class="c1"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span> -<span class="c1"># See the License for the specific language governing permissions and</span> -<span class="c1"># limitations under the License.</span> +<span class="c1"># Licensed to the Apache Software Foundation (ASF) under one</span> +<span class="c1"># or more contributor license agreements. See the NOTICE file</span> +<span class="c1"># distributed with this work for additional information</span> +<span class="c1"># regarding copyright ownership. The ASF licenses this file</span> +<span class="c1"># to you under the Apache License, Version 2.0 (the</span> +<span class="c1"># "License"); you may not use this file except in compliance</span> +<span class="c1"># with the License. You may obtain a copy of the License at</span> +<span class="c1"># </span> +<span class="c1"># http://www.apache.org/licenses/LICENSE-2.0</span> +<span class="c1"># </span> +<span class="c1"># Unless required by applicable law or agreed to in writing,</span> +<span class="c1"># software distributed under the License is distributed on an</span> +<span class="c1"># "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</span> +<span class="c1"># KIND, either express or implied. See the License for the</span> +<span class="c1"># specific language governing permissions and limitations</span> +<span class="c1"># under the License.</span> <span class="kn">from</span> <span class="nn">builtins</span> <span class="k">import</span> <span class="nb">str</span> @@ -216,14 +223,14 @@ <span class="bp">self</span><span class="o">.</span><span class="n">url</span> <span class="o">=</span> <span class="kc">None</span> <span class="bp">self</span><span class="o">.</span><span class="n">body</span> <span class="o">=</span> <span class="kc">None</span> - <span class="k">def</span> <span class="nf">prepare_request</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +<div class="viewcode-block" id="HipChatAPIOperator.prepare_request"><a class="viewcode-back" href="../../../../code.html#airflow.contrib.operators.hipchat_operator.HipChatAPIOperator.prepare_request">[docs]</a> <span class="k">def</span> <span class="nf">prepare_request</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""</span> <span class="sd"> Used by the execute function. Set the request method, url, and body of HipChat's</span> <span class="sd"> REST API call.</span> <span class="sd"> Override in child class. Each HipChatAPI child operator is responsible for having</span> <span class="sd"> a prepare_request method call which sets self.method, self.url, and self.body.</span> <span class="sd"> """</span> - <span class="k">pass</span> + <span class="k">pass</span></div> <span class="k">def</span> <span class="nf">execute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">context</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepare_request</span><span class="p">()</span>