blob: 5ed64d14b52495310ad7c349cbc8215cee04d787 [file] [log] [blame]
<!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.hooks.gcp_pubsub_hook &mdash; Airflow Documentation</title>
<script type="text/javascript" src="../../../../../_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="../../../../../" src="../../../../../_static/documentation_options.js"></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/language_data.js"></script>
<script type="text/javascript" src="../../../../../_static/js/theme.js"></script>
<link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="../../../../../genindex.html" />
<link rel="search" title="Search" href="../../../../../search.html" />
<link rel="next" title="airflow.contrib.hooks.gcp_spanner_hook" href="../gcp_spanner_hook/index.html" />
<link rel="prev" title="airflow.contrib.hooks.gcp_natural_language_hook" href="../gcp_natural_language_hook/index.html" />
<script>
document.addEventListener('DOMContentLoaded', function() {
var el = document.getElementById('changelog');
if (el !== null ) {
// [AIRFLOW-...]
el.innerHTML = el.innerHTML.replace(
/\[(AIRFLOW-[\d]+)\]/g,
`<a href="https://issues.apache.org/jira/browse/$1">[$1]</a>`
);
// (#...)
el.innerHTML = el.innerHTML.replace(
/\(#([\d]+)\)/g,
`<a href="https://github.com/apache/airflow/pull/$1">(#$1)</a>`
);
};
})
</script>
<style>
.example-header {
position: relative;
background: #9AAA7A;
padding: 8px 16px;
margin-bottom: 0;
}
.example-header--with-button {
padding-right: 166px;
}
.example-header:after{
content: '';
display: table;
clear: both;
}
.example-title {
display:block;
padding: 4px;
margin-right: 16px;
color: white;
overflow-x: auto;
}
.example-header-button {
top: 8px;
right: 16px;
position: absolute;
}
.example-header + .highlight-python {
margin-top: 0 !important;
}
.viewcode-button {
display: inline-block;
padding: 8px 16px;
border: 0;
margin: 0;
outline: 0;
border-radius: 2px;
-webkit-box-shadow: 0 3px 5px 0 rgba(0,0,0,.3);
box-shadow: 0 3px 6px 0 rgba(0,0,0,.3);
color: #404040;
background-color: #e7e7e7;
cursor: pointer;
font-size: 16px;
font-weight: 500;
line-height: 1;
text-decoration: none;
text-overflow: ellipsis;
overflow: hidden;
text-transform: uppercase;
-webkit-transition: background-color .2s;
transition: background-color .2s;
vertical-align: middle;
white-space: nowrap;
}
.viewcode-button:visited {
color: #404040;
}
.viewcode-button:hover, .viewcode-button:focus {
color: #404040;
background-color: #d6d6d6;
}
</style>
</head>
<body class="wy-body-for-nav">
<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 class="version">
1.10.4
</div>
<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 class="current">
<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 &amp; 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="../../../../../metrics.html">Metrics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../kubernetes.html">Kubernetes</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="../../../../../changelog.html">Changelog</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="../../../../../macros.html">Macros reference</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../../../index.html">API Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../../../index.html#operators">Operators</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../../../index.html#hooks">Hooks</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="../../../../index.html#hooks-packages">Hooks packages</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../../../hooks/index.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.hooks</span></code></a></li>
<li class="toctree-l4 current"><a class="reference internal" href="../index.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.contrib.hooks</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../../index.html#executors">Executors</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../../index.html#models">Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../../index.html#core-and-community-package">Core and community package</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" 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> &raquo;</li>
<li><a href="../../../../index.html">API Reference</a> &raquo;</li>
<li><a href="../index.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.contrib.hooks</span></code></a> &raquo;</li>
<li><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.contrib.hooks.gcp_pubsub_hook</span></code></li>
<li class="wy-breadcrumbs-aside">
<a href="../../../../../_sources/_api/airflow/contrib/hooks/gcp_pubsub_hook/index.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-airflow.contrib.hooks.gcp_pubsub_hook">
<span id="airflow-contrib-hooks-gcp-pubsub-hook"></span><h1><a class="reference internal" href="#module-airflow.contrib.hooks.gcp_pubsub_hook" title="airflow.contrib.hooks.gcp_pubsub_hook"><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.contrib.hooks.gcp_pubsub_hook</span></code></a><a class="headerlink" href="#module-airflow.contrib.hooks.gcp_pubsub_hook" title="Permalink to this headline"></a></h1>
<div class="section" id="module-contents">
<h2>Module Contents<a class="headerlink" href="#module-contents" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook._format_subscription">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_pubsub_hook.</code><code class="sig-name descname">_format_subscription</code><span class="sig-paren">(</span><em class="sig-param">project</em>, <em class="sig-param">subscription</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#_format_subscription"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook._format_subscription" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook._format_topic">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_pubsub_hook.</code><code class="sig-name descname">_format_topic</code><span class="sig-paren">(</span><em class="sig-param">project</em>, <em class="sig-param">topic</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#_format_topic"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook._format_topic" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="exception">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubException">
<em class="property">exception </em><code class="sig-prename descclassname">airflow.contrib.hooks.gcp_pubsub_hook.</code><code class="sig-name descname">PubSubException</code><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubException"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubException" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#Exception" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></a></p>
</dd></dl>
<dl class="class">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook">
<em class="property">class </em><code class="sig-prename descclassname">airflow.contrib.hooks.gcp_pubsub_hook.</code><code class="sig-name descname">PubSubHook</code><span class="sig-paren">(</span><em class="sig-param">gcp_conn_id='google_cloud_default'</em>, <em class="sig-param">delegate_to=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubHook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="../gcp_api_base_hook/index.html#airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook" title="airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook"><code class="xref py py-class docutils literal notranslate"><span class="pre">airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook</span></code></a></p>
<p>Hook for accessing Google Pub/Sub.</p>
<p>The GCP project against which actions are applied is determined by
the project embedded in the Connection referenced by gcp_conn_id.</p>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.get_conn">
<code class="sig-name descname">get_conn</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubHook.get_conn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.get_conn" title="Permalink to this definition"></a></dt>
<dd><p>Returns a Pub/Sub service object.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>googleapiclient.discovery.Resource</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.publish">
<code class="sig-name descname">publish</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">project</em>, <em class="sig-param">topic</em>, <em class="sig-param">messages</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubHook.publish"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.publish" title="Permalink to this definition"></a></dt>
<dd><p>Publishes messages to a Pub/Sub topic.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>project</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the GCP project ID in which to publish</p></li>
<li><p><strong>topic</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the Pub/Sub topic to which to publish; do not
include the <code class="docutils literal notranslate"><span class="pre">projects/{project}/topics/</span></code> prefix.</p></li>
<li><p><strong>messages</strong> (list of PubSub messages; see
<a class="reference external" href="http://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage">http://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage</a>) – messages to publish; if the data field in a
message is set, it should already be base64 encoded.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.create_topic">
<code class="sig-name descname">create_topic</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">project</em>, <em class="sig-param">topic</em>, <em class="sig-param">fail_if_exists=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubHook.create_topic"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.create_topic" title="Permalink to this definition"></a></dt>
<dd><p>Creates a Pub/Sub topic, if it does not already exist.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>project</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the GCP project ID in which to create
the topic</p></li>
<li><p><strong>topic</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the Pub/Sub topic name to create; do not
include the <code class="docutils literal notranslate"><span class="pre">projects/{project}/topics/</span></code> prefix.</p></li>
<li><p><strong>fail_if_exists</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.7)"><em>bool</em></a>) – if set, raise an exception if the topic
already exists</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.delete_topic">
<code class="sig-name descname">delete_topic</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">project</em>, <em class="sig-param">topic</em>, <em class="sig-param">fail_if_not_exists=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubHook.delete_topic"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.delete_topic" title="Permalink to this definition"></a></dt>
<dd><p>Deletes a Pub/Sub topic if it exists.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>project</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the GCP project ID in which to delete the topic</p></li>
<li><p><strong>topic</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the Pub/Sub topic name to delete; do not
include the <code class="docutils literal notranslate"><span class="pre">projects/{project}/topics/</span></code> prefix.</p></li>
<li><p><strong>fail_if_not_exists</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.7)"><em>bool</em></a>) – if set, raise an exception if the topic
does not exist</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.create_subscription">
<code class="sig-name descname">create_subscription</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">topic_project</em>, <em class="sig-param">topic</em>, <em class="sig-param">subscription=None</em>, <em class="sig-param">subscription_project=None</em>, <em class="sig-param">ack_deadline_secs=10</em>, <em class="sig-param">fail_if_exists=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubHook.create_subscription"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.create_subscription" title="Permalink to this definition"></a></dt>
<dd><p>Creates a Pub/Sub subscription, if it does not already exist.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>topic_project</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the GCP project ID of the topic that the
subscription will be bound to.</p></li>
<li><p><strong>topic</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the Pub/Sub topic name that the subscription will be bound
to create; do not include the <code class="docutils literal notranslate"><span class="pre">projects/{project}/subscriptions/</span></code>
prefix.</p></li>
<li><p><strong>subscription</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the Pub/Sub subscription name. If empty, a random
name will be generated using the uuid module</p></li>
<li><p><strong>subscription_project</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the GCP project ID where the subscription
will be created. If unspecified, <code class="docutils literal notranslate"><span class="pre">topic_project</span></code> will be used.</p></li>
<li><p><strong>ack_deadline_secs</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – Number of seconds that a subscriber has to
acknowledge each message pulled from the subscription</p></li>
<li><p><strong>fail_if_exists</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.7)"><em>bool</em></a>) – if set, raise an exception if the topic
already exists</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>subscription name which will be the system-generated value if
the <code class="docutils literal notranslate"><span class="pre">subscription</span></code> parameter is not supplied</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)">str</a></p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.delete_subscription">
<code class="sig-name descname">delete_subscription</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">project</em>, <em class="sig-param">subscription</em>, <em class="sig-param">fail_if_not_exists=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubHook.delete_subscription"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.delete_subscription" title="Permalink to this definition"></a></dt>
<dd><p>Deletes a Pub/Sub subscription, if it exists.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>project</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the GCP project ID where the subscription exists</p></li>
<li><p><strong>subscription</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the Pub/Sub subscription name to delete; do not
include the <code class="docutils literal notranslate"><span class="pre">projects/{project}/subscriptions/</span></code> prefix.</p></li>
<li><p><strong>fail_if_not_exists</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.7)"><em>bool</em></a>) – if set, raise an exception if the topic
does not exist</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.pull">
<code class="sig-name descname">pull</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">project</em>, <em class="sig-param">subscription</em>, <em class="sig-param">max_messages</em>, <em class="sig-param">return_immediately=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubHook.pull"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.pull" title="Permalink to this definition"></a></dt>
<dd><p>Pulls up to <code class="docutils literal notranslate"><span class="pre">max_messages</span></code> messages from Pub/Sub subscription.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>project</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the GCP project ID where the subscription exists</p></li>
<li><p><strong>subscription</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the Pub/Sub subscription name to pull from; do not
include the ‘projects/{project}/topics/’ prefix.</p></li>
<li><p><strong>max_messages</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – The maximum number of messages to return from
the Pub/Sub API.</p></li>
<li><p><strong>return_immediately</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.7)"><em>bool</em></a>) – If set, the Pub/Sub API will immediately
return if no messages are available. Otherwise, the request will
block for an undisclosed, but bounded period of time</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A list of Pub/Sub ReceivedMessage objects each containing
an <code class="docutils literal notranslate"><span class="pre">ackId</span></code> property and a <code class="docutils literal notranslate"><span class="pre">message</span></code> property, which includes
the base64-encoded message content. See
<a class="reference external" href="https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull#ReceivedMessage">https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull#ReceivedMessage</a></p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.acknowledge">
<code class="sig-name descname">acknowledge</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">project</em>, <em class="sig-param">subscription</em>, <em class="sig-param">ack_ids</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_pubsub_hook.html#PubSubHook.acknowledge"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_pubsub_hook.PubSubHook.acknowledge" title="Permalink to this definition"></a></dt>
<dd><p>Pulls up to <code class="docutils literal notranslate"><span class="pre">max_messages</span></code> messages from Pub/Sub subscription.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>project</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the GCP project name or ID in which to create
the topic</p></li>
<li><p><strong>subscription</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – the Pub/Sub subscription name to delete; do not
include the ‘projects/{project}/topics/’ prefix.</p></li>
<li><p><strong>ack_ids</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.7)"><em>list</em></a>) – List of ReceivedMessage ackIds from a previous pull
response</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../gcp_spanner_hook/index.html" class="btn btn-neutral float-right" title="airflow.contrib.hooks.gcp_spanner_hook" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="../gcp_natural_language_hook/index.html" class="btn btn-neutral float-left" title="airflow.contrib.hooks.gcp_natural_language_hook" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/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">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>