Swirls

SWIRLS_

  • How it works
  • Pricing

56 matches

OverviewDeliver client operations10Win and grow accounts8Resolve customer issues6Create and distribute content9Run people and operations5Review money and agreements3Monitor systems and data9Compose dependable work6

56 matches

OverviewDeliver client operations10Win and grow accounts8Resolve customer issues6Create and distribute content9Run people and operations5Review money and agreements3Monitor systems and data9Compose dependable work6
← DevOpsScheduleView on GitHub

API Key Auth Example

Demonstrates auth blocks with API key authentication (OpenWeatherMap).

http

Source

/**
 * Demonstrates the auth block pattern for API key authentication.
 */

secret weather_creds {
  label: "Weather API"
  vars: [WEATHER_API_KEY, WEATHER_API_URL]
}

auth weather_auth {
  label: "Weather API Auth"
  type: api_key
  secrets: weather_creds
  key: WEATHER_API_KEY
  query_param: "appid"
}

schedule hourly_weather {
  label: "Hourly Weather"
  cron: "0 * * * *"
}

workflow fetch_weather {
  label: "Fetch Weather"

  root {
    type: code
    label: "Prepare request"
    code: @ts {
      return { city: "San Francisco", units: "imperial" }
    }
    outputSchema: @json {
      {
        "type": "object",
        "properties": {
          "city": { "type": "string" },
          "units": { "type": "string" }
        }
      }
    }
  }

  node get_weather {
    type: http
    label: "Call weather API"
    url: @ts {
      const params = context.nodes.root.output
      const base = context.secrets.weather_creds.WEATHER_API_URL || "https://api.openweathermap.org"
      return base + "/data/2.5/weather?q=" + params.city + "&units=" + params.units
    }
    secrets: {
      weather_creds: [WEATHER_API_URL]
    }
    auth: weather_auth
  }

  node format {
    type: code
    label: "Format result"
    code: @ts {
      const data = context.nodes.get_weather.output
      return {
        city: data.name || "unknown",
        temp: data.main ? data.main.temp : 0,
        description: data.weather && data.weather[0] ? data.weather[0].description : "unknown",
        humidity: data.main ? data.main.humidity : 0
      }
    }
  }

  flow {
    root -> get_weather
    get_weather -> format
  }
}

trigger on_weather {
  schedule:hourly_weather -> fetch_weather
  enabled: true
}

Flow

Trigger to workflow

hourly_weatherschedule
fetch_weather
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

Workflow nodes

CODE
Code Node
Prepare request
HTTP
HTTP Node
Call weather API
CODE
Code Node
Format result
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.