bigquery

package
v0.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

BigQuery

Actions for BigQuery data integration.

Prerequisites

  • Google Cloud account: You need to have a Google Cloud account and the necessary permissions to create and modify BigQuery datasets and tables.
  • BigQuery dataset: You need to have a BigQuery dataset to insert the alert into. You can find instructions on how to create a dataset here.

bigquery.insert_alert

This action inserts an alert into BigQuery.

Arguments

Example policy:

run[res] {
  res := {
    id: "your-action",
    uses: "bigquery.insert_alert",
    args: {
      "project_id": "my-project",
      "dataset_id": "my-dataset",
      "table_id": "my-table",
    },
  },
}
  • project_id (string, required): Specifies the ID of the Google Project to insert the alert into.
  • dataset_id (string, required): Specifies the ID of the BigQuery dataset to insert the alert into.
  • table_id (string, required): Specifies the ID of the BigQuery table to insert the alert into. If the table does not exist, it will be created.
Table schema
Field name Type Mode
id STRING REQUIRED
schema STRING REQUIRED
created_at TIMESTAMP REQUIRED
title STRING REQUIRED
description STRING REQUIRED
source STRING REQUIRED
namespace STRING REQUIRED
attrs RECORD REPEATED
└─ id STRING REQUIRED
└─ key STRING REQUIRED
└─ value STRING REQUIRED
└─ type STRING REQUIRED
└─ ttl INTEGER REQUIRED
└─ global BOOLEAN REQUIRED
refs RECORD REPEATED
└─ Title STRING REQUIRED
└─ URL STRING REQUIRED
data JSON REQUIRED

bigquery.insert_data

This action inserts any data into BigQuery.

Arguments

Example policy:

run[res] {
  res := {
    id: "your-action",
    uses: "bigquery.insert_data",
    args: {
      "project_id": "my-project",
      "dataset_id": "my-dataset",
      "table_id": "my-table",
      "data": {
        "name": "John Doe",
        "age": 42,
      },
    },
  },
}
  • project_id (string, required): Specifies the ID of the Google Project to insert the data into.
  • dataset_id (string, required): Specifies the ID of the BigQuery dataset to insert the data into.
  • table_id (string, required): Specifies the ID of the BigQuery table to insert the data into. If the table does not exist, it will be created.
  • tags (array of string, optional): Specifies the tags to insert into the table. This field will be REPEATED STRING field type in BigQuery.
  • data (object, required): Specifies the data to insert into the table. This field will be JSON field type in BigQuery.
Table schema
Field name Type Mode
id STRING REQUIRED
alert_id STRING REQUIRED
created_at TIMESTAMP REQUIRED
tags STRING REPEATED
data JSON REQUIRED

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertAlert

func InsertAlert(ctx *model.Context, alert model.Alert, args model.ActionArgs) (any, error)

func InsertData

func InsertData(ctx *model.Context, alert model.Alert, args model.ActionArgs) (any, error)

Types

type AlertRecord

type AlertRecord struct {
	ID          types.AlertID    `bigquery:"id"`
	Schema      types.Schema     `bigquery:"schema"`
	CreatedAt   time.Time        `bigquery:"created_at"`
	Title       string           `bigquery:"title"`
	Description string           `bigquery:"description"`
	Source      string           `bigquery:"source"`
	Namespace   types.Namespace  `bigquery:"namespace"`
	Attrs       []AttrRecord     `bigquery:"attrs"`
	Refs        model.References `bigquery:"refs"`
	Data        string           `bigquery:"data"`
}

type AttrRecord

type AttrRecord struct {
	ID     string `bigquery:"id"`
	Key    string `bigquery:"key"`
	Value  string `bigquery:"value"`
	Type   string `bigquery:"type"`
	TTL    int    `bigquery:"ttl"`
	Global bool   `bigquery:"global"`
}

type DataRecord

type DataRecord struct {
	ID        string    `bigquery:"id"`
	AlertID   string    `bigquery:"alert_id"`
	CreatedAt time.Time `bigquery:"created_at"`
	Tags      []string  `bigquery:"tags"`
	Data      string    `bigquery:"data"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL