Resume Warehouse Auto-Management with the API

Use the Warehouses API to resume Revefi auto-management of a paused Snowflake warehouse, so a temporary pause never becomes a permanent one.

Pausing auto-management is easy to justify: a backfill is about to run, an incident is open, a freeze has started. Resuming is the step that gets forgotten. The job finishes, the incident closes, the freeze ends, and the warehouse stays at whatever size it was pinned to. A paused warehouse is no longer sized to its workload, so every day it stays paused raises one question: is this warehouse still paused on purpose?

The Resume Warehouse Auto-Management endpoint closes the loop. One API call hands a paused warehouse back to Revefi, which goes back to sizing it on its schedule. Because it is an API call, it can be the last step of the same pipeline or runbook that paused the warehouse.

🚧 Private preview
The Warehouses API is under private review. Its signatures may change without notice. Please talk to the Revefi support team at [email protected] before using it.

This page describes the problems data teams solve by resuming auto-management through the API. To pause a warehouse in the first place, see Pause Warehouse Auto-Management with the API.

Who this is for

  • Data platform and data engineering leads who want every pause to end on time, without a manual follow-up.
  • Analytics engineers and pipeline owners who pause a warehouse at the start of a job and need it resumed when the job ends, whether it succeeds or fails.
  • On-call engineers and SREs who paused a warehouse during an incident and need a clear step to close it out.
  • Release managers who lift a change freeze and need every frozen warehouse handed back.
  • FinOps and cloud cost analysts who track which warehouses are paused and how long they have been that way.

How resuming works

Send a POST request to /warehouses/{warehouseName}/auto-manage/resume. That is the whole request.

  • No request body. The endpoint does not take one. A request that sends a body is rejected with 400.
  • Nothing to configure. The warehouse kept its schedule while it was paused, so Revefi picks up where it left off.
  • One warehouse per call. There is no bulk resume. To resume several warehouses, make one request for each.
  • The call is asynchronous. A 202 response means the request was accepted. The change finishes in the background, so read the warehouse's autoManageStatus to confirm it is managed.
  • Only paused warehouses can be resumed. A warehouse whose auto-management is not paused returns 409.

A successful request returns:

{
  "name": "ANALYTICS_WH",
  "action": "resume",
  "status": "accepted"
}

The examples below use Python with the requests library and read the API token from a REVEFI_API_TOKEN environment variable. Each script is complete and runs on its own.

Hand the warehouse back when a planned workload finishes

The problem

A pipeline pauses auto-management and pins a large size for a backfill. If the resume is a separate manual step, it depends on someone remembering it. If the job fails halfway, it is even more likely to be missed, and the warehouse stays pinned at the large size.

How the API helps

Put the pause and the resume in the same script, with the resume in a finally block. It runs whether the workload succeeds or fails.

The two calls are deliberately different: the pause carries a request body that sets the size, and the resume carries none.

import os

import requests

BASE_URL = "https://gateway.revefi.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['REVEFI_API_TOKEN']}"}

WAREHOUSE = "TRANSFORM_WH"


def run_backfill():
    """Your heavy workload goes here."""
    ...


# Pause: the request body pins the size for the length of the job.
pause_body = {
    "warehouseSize": {
        "mode": "custom",
        "size": "X-LARGE",
        "minClusterCount": 1,
        "maxClusterCount": 4,
    }
}
response = requests.post(
    f"{BASE_URL}/warehouses/{WAREHOUSE}/auto-manage/pause",
    headers=HEADERS,
    json=pause_body,
    timeout=30,
)
response.raise_for_status()

try:
    run_backfill()
finally:
    # Resume: no request body. Do not pass json= or data= here.
    response = requests.post(
        f"{BASE_URL}/warehouses/{WAREHOUSE}/auto-manage/resume",
        headers=HEADERS,
        timeout=30,
    )
    response.raise_for_status()
    print(response.json())
    # {'name': 'TRANSFORM_WH', 'action': 'resume', 'status': 'accepted'}

In an orchestrator, the same idea applies: make the resume a final task that runs regardless of the outcome of the tasks before it.

Outcome

The warehouse is pinned only for as long as the job runs. Revefi takes over again the moment it ends, with no manual follow-up.

Close out an incident

The problem

During an incident the on-call engineer paused auto-management to rule it out. The incident is resolved, but the warehouse is still paused, and the next shift does not know whether that is intentional.

How the API helps

Make the resume a step in the incident close-out runbook. A short script resumes the warehouse and waits until autoManageStatus reads managed, so the runbook step ends with a confirmed result instead of an assumption.

import os
import time

import requests

BASE_URL = "https://gateway.revefi.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['REVEFI_API_TOKEN']}"}

WAREHOUSE = "ANALYTICS_WH"

# Resume takes no request body.
response = requests.post(
    f"{BASE_URL}/warehouses/{WAREHOUSE}/auto-manage/resume",
    headers=HEADERS,
    timeout=30,
)

if response.status_code == 409:
    print(f"{WAREHOUSE} is not paused, so there is nothing to resume.")
else:
    response.raise_for_status()

    # 202 means accepted. Poll until the background change lands.
    deadline = time.monotonic() + 300
    status = None
    while time.monotonic() < deadline:
        check = requests.get(
            f"{BASE_URL}/warehouses/{WAREHOUSE}", headers=HEADERS, timeout=30
        )
        check.raise_for_status()
        status = check.json()[0]["autoManageStatus"]
        if status == "managed":
            break
        time.sleep(10)

    print(f"{WAREHOUSE}: autoManageStatus is {status}")

Outcome

The incident is closed with the warehouse back under auto-management, and the confirmation is in the runbook output.

Lift a change freeze

The problem

A freeze paused many warehouses at once. When it ends, each of them needs to be resumed, and missing one leaves a warehouse frozen at its size long after the freeze is over.

How the API helps

There is no bulk resume, so loop over the warehouses and make one resume call for each.

If the freeze script saved the list of warehouses it paused, resume exactly that list. This leaves alone any warehouse that someone paused for a different reason.

import json
import os

import requests

BASE_URL = "https://gateway.revefi.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['REVEFI_API_TOKEN']}"}

# The warehouses the freeze script paused.
with open("paused_by_freeze.json") as f:
    paused_by_freeze = json.load(f)

# Resume them one at a time. No request body.
for warehouse in paused_by_freeze:
    response = requests.post(
        f"{BASE_URL}/warehouses/{warehouse}/auto-manage/resume",
        headers=HEADERS,
        timeout=30,
    )
    if response.status_code == 202:
        print(f"{warehouse}: resume accepted")
    elif response.status_code == 409:
        print(f"{warehouse}: not paused, skipped")
    else:
        print(f"{warehouse}: not resumed ({response.status_code}) {response.text}")

If there is no saved list, ask the API which warehouses are paused and resume those. Review the list before you run it, because it includes every paused warehouse, whoever paused it and whatever the reason.

import os

import requests

BASE_URL = "https://gateway.revefi.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['REVEFI_API_TOKEN']}"}

# Find every warehouse whose auto-management is paused right now.
response = requests.get(f"{BASE_URL}/warehouses", headers=HEADERS, timeout=30)
response.raise_for_status()
paused = [w["name"] for w in response.json() if w["autoManageStatus"] == "paused"]

for warehouse in paused:
    response = requests.post(
        f"{BASE_URL}/warehouses/{warehouse}/auto-manage/resume",
        headers=HEADERS,
        timeout=30,
    )
    print(f"{warehouse}: {response.status_code}")

Outcome

Every warehouse the freeze touched is handed back, and each one is accounted for in the script output.

Find warehouses that were left paused

The problem

Pauses happen for good reasons and then outlive them. Without a regular check, a warehouse paused for a one-day job can stay paused for months without anyone noticing.

How the API helps

Get Warehouses returns autoManageStatus for every warehouse. A scheduled script can report the paused ones each day, so every long-running pause is either confirmed as intentional or resumed.

import os

import requests

BASE_URL = "https://gateway.revefi.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['REVEFI_API_TOKEN']}"}

# Warehouses that are meant to stay paused. Everything else gets reported.
EXPECTED_PAUSED = {"SANDBOX_WH"}

response = requests.get(f"{BASE_URL}/warehouses", headers=HEADERS, timeout=30)
response.raise_for_status()

left_paused = [
    w["name"]
    for w in response.json()
    if w["autoManageStatus"] == "paused" and w["name"] not in EXPECTED_PAUSED
]

if left_paused:
    print("Auto-management is paused on:", ", ".join(left_paused))
else:
    print("No unexpected paused warehouses.")

Send the output to the channel your team already watches, or resume the warehouses directly with one call for each.

Outcome

Paused warehouses are visible every day. A pause stays in place only when someone has decided it should.

Build automation that is safe to rerun

The problem

A resume step that fails when the warehouse is already managed, or that reports success before the change has landed, makes pipelines brittle and reruns risky.

How the API helps

The resume call has the same automation-friendly behavior as the pause call: the status is readable before you act, each error code points to a specific action, and the result can be confirmed afterwards.

StatusWhat it meansWhat to do
202The resume was acceptedPoll autoManageStatus until it is managed
400A request body was sent, or the account does not have exactly one Snowflake data sourceRemove the body. Do not retry the request unchanged
403The token's user does not have edit access to this warehouseUse a token whose user can edit the warehouse
404No warehouse with this name existsCheck the name
409Auto-management of the warehouse is not pausedNothing to resume. Treat as a skip
429Too many requestsWait, then retry
503Access to the warehouse could not be verified. Nothing was changedWait, then retry
import os
import time

import requests

BASE_URL = "https://gateway.revefi.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['REVEFI_API_TOKEN']}"}
RETRYABLE = {429, 503}


def get_status(warehouse):
    """Return the warehouse's autoManageStatus: managed, paused or not_managed."""
    response = requests.get(
        f"{BASE_URL}/warehouses/{warehouse}", headers=HEADERS, timeout=30
    )
    response.raise_for_status()
    return response.json()[0]["autoManageStatus"]


def wait_for_status(warehouse, expected, timeout_seconds=300, interval_seconds=10):
    """Poll until the background change lands, or give up after the timeout."""
    deadline = time.monotonic() + timeout_seconds
    while time.monotonic() < deadline:
        if get_status(warehouse) == expected:
            return True
        time.sleep(interval_seconds)
    return False


def resume(warehouse, attempts=3):
    """Resume auto-management of one warehouse. Safe to call more than once."""
    status = get_status(warehouse)
    if status == "managed":
        print(f"{warehouse}: already managed, nothing to do")
        return
    if status == "not_managed":
        print(f"{warehouse}: not auto-managed, so it cannot be resumed")
        return

    for attempt in range(1, attempts + 1):
        # No json= or data= argument: the endpoint rejects a request body.
        response = requests.post(
            f"{BASE_URL}/warehouses/{warehouse}/auto-manage/resume",
            headers=HEADERS,
            timeout=30,
        )
        if response.status_code == 202:
            break
        if response.status_code in RETRYABLE and attempt < attempts:
            time.sleep(15 * attempt)
            continue
        raise RuntimeError(
            f"{warehouse}: resume failed ({response.status_code}) {response.text}"
        )

    if wait_for_status(warehouse, "managed"):
        print(f"{warehouse}: auto-management resumed")
    else:
        raise TimeoutError(f"{warehouse}: resume accepted but not confirmed yet")


# One call per warehouse.
for name in ["ANALYTICS_WH", "REPORTING_WH", "TRANSFORM_WH"]:
    resume(name)

Outcome

The resume step can be retried, rerun, and scheduled without side effects, and it reports success only when Revefi is managing the warehouse again.

Get started

  1. Create an API token by following the steps in Public APIs. The token's user needs edit access to the warehouses you want to resume.
  2. Call Get Warehouses and pick the warehouses whose autoManageStatus is paused.
  3. Call Resume Warehouse Auto-Management once for each warehouse, with no request body.
  4. Read autoManageStatus to confirm each warehouse is managed.
  5. Add the resume call as the final step of any pipeline or runbook that pauses auto-management.

Did this page help you?