From 69245233a7679a3ad10ed66bb7e9fabd0d5da466 Mon Sep 17 00:00:00 2001 From: CrazyBolillo Date: Sat, 15 Jun 2024 15:51:22 -0600 Subject: [PATCH] feat: app skeleton, create endpoints The applications structure has been implemented. This also includes setting up CI pipelines and integrating with swagger. As of now a single route to create endpoints has been added. --- .github/workflows/qa.yaml | 27 + .gitignore | 22 + .golangci.yaml | 4 + Makefile | 7 + README.md | 3 + cmd/main.go | 51 + docs/swagger.yaml | 47 + go.mod | 14 + go.sum | 32 + internal/db/types.go | 17 + internal/handler/endpoint.go | 104 ++ internal/sqlc/db.go | 32 + internal/sqlc/models.go | 2238 ++++++++++++++++++++++++++++++++++ internal/sqlc/queries.sql.go | 77 ++ queries.sql | 17 + schema.sql | 1163 ++++++++++++++++++ sqlc.yaml | 10 + 17 files changed, 3865 insertions(+) create mode 100644 .github/workflows/qa.yaml create mode 100644 .gitignore create mode 100644 .golangci.yaml create mode 100644 Makefile create mode 100644 README.md create mode 100644 cmd/main.go create mode 100644 docs/swagger.yaml create mode 100644 go.mod create mode 100644 go.sum create mode 100644 internal/db/types.go create mode 100644 internal/handler/endpoint.go create mode 100644 internal/sqlc/db.go create mode 100644 internal/sqlc/models.go create mode 100644 internal/sqlc/queries.sql.go create mode 100644 queries.sql create mode 100644 schema.sql create mode 100644 sqlc.yaml diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml new file mode 100644 index 0000000..2dd4aeb --- /dev/null +++ b/.github/workflows/qa.yaml @@ -0,0 +1,27 @@ +name: qa +on: + push: + branches: + - 'main' + pull_request: +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + - uses: golangci/golangci-lint-action@v5 + with: + version: latest + sqlc: + runs-on: ubuntu-latest + steps: + - uses: sqlc-dev/setup-sqlc@v4 + with: + sqlc-version: '1.21.0' + - name: Vet + run: sqlc vet + - name: Diff + run: sqlc diff diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f07ba12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Go workspace file +go.work +go.work.sum + +# env file +.env + +# IDEs +.idea/ \ No newline at end of file diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..05b36f7 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,4 @@ +linters-settings: + errcheck: + exclude-functions: + - (github.com/jackc/pgx/v5.Tx).Rollback diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..73772d8 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: swagger docs + +docs: + swag init --generalInfo cmd/main.go --outputTypes=yaml + +swagger: + docker run --detach -p 4000:8080 -e API_URL=/doc/swagger.yaml --mount 'type=bind,src=$(shell pwd)/docs,dst=/usr/share/nginx/html/doc' swaggerapi/swagger-ui diff --git a/README.md b/README.md new file mode 100644 index 0000000..6c95892 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# eryth +API to perform configuration management on Asterisk servers. Project named after +[Erythrina americana](https://mexico.inaturalist.org/taxa/201455-Erythrina-americana). diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 0000000..143e0d5 --- /dev/null +++ b/cmd/main.go @@ -0,0 +1,51 @@ +package main + +import ( + "context" + "github.com/crazybolillo/eryth/internal/handler" + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" + "github.com/go-chi/cors" + "github.com/jackc/pgx/v5" + "log/slog" + "net/http" + "os" + "strings" +) + +// @title Asterisk Administration API +// @version 1.0 +// @description API to perform configuration management on Asterisk servers. +// @host localhost:8080 +func main() { + os.Exit(run(context.Background())) +} + +func run(ctx context.Context) int { + err := serve(ctx) + if err != nil { + return 1 + } + + return 0 +} + +func serve(ctx context.Context) error { + conn, err := pgx.Connect(ctx, os.Getenv("DATABASE_URL")) + if err != nil { + slog.Error("failed to establish database connection") + return err + } + defer conn.Close(ctx) + + r := chi.NewRouter() + r.Use(cors.Handler(cors.Options{ + AllowedOrigins: strings.Split(os.Getenv("CORS_ALLOWED_ORIGINS"), ","), + })) + r.Use(middleware.AllowContentEncoding("application/json")) + + endpoint := handler.Endpoint{Conn: conn} + r.Mount("/endpoint", endpoint.Router()) + + return http.ListenAndServe(":8080", r) +} diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 0000000..5b2fc78 --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,47 @@ +definitions: + handler.createRequest: + properties: + codecs: + items: + type: string + type: array + context: + type: string + id: + type: string + max_contacts: + type: integer + password: + type: string + realm: + type: string + transport: + type: string + type: object +host: localhost:8080 +info: + contact: {} + description: API to perform configuration management on Asterisk servers. + title: Asterisk Administration API + version: "1.0" +paths: + /endpoint: + post: + consumes: + - application/json + parameters: + - description: Endpoint's information + in: body + name: payload + required: true + schema: + $ref: '#/definitions/handler.createRequest' + responses: + "204": + description: No Content + "400": + description: Bad Request + "500": + description: Internal Server Error + summary: Create a new endpoint. +swagger: "2.0" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1e5ad29 --- /dev/null +++ b/go.mod @@ -0,0 +1,14 @@ +module github.com/crazybolillo/eryth + +go 1.22 + +require github.com/jackc/pgx/v5 v5.6.0 + +require ( + github.com/go-chi/chi/v5 v5.0.12 // indirect + github.com/go-chi/cors v1.2.1 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/text v0.14.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..807cae8 --- /dev/null +++ b/go.sum @@ -0,0 +1,32 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= +github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= +github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY= +github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/db/types.go b/internal/db/types.go new file mode 100644 index 0000000..ca0fd00 --- /dev/null +++ b/internal/db/types.go @@ -0,0 +1,17 @@ +package db + +import "github.com/jackc/pgx/v5/pgtype" + +func Text(value string) pgtype.Text { + return pgtype.Text{ + String: value, + Valid: true, + } +} + +func Int4(value int32) pgtype.Int4 { + return pgtype.Int4{ + Int32: value, + Valid: true, + } +} diff --git a/internal/handler/endpoint.go b/internal/handler/endpoint.go new file mode 100644 index 0000000..e06c209 --- /dev/null +++ b/internal/handler/endpoint.go @@ -0,0 +1,104 @@ +package handler + +import ( + "crypto/md5" + "encoding/hex" + "encoding/json" + "github.com/crazybolillo/eryth/internal/db" + "github.com/crazybolillo/eryth/internal/sqlc" + "github.com/go-chi/chi/v5" + "github.com/jackc/pgx/v5" + "net/http" + "strings" +) + +type Endpoint struct { + *pgx.Conn +} + +type createRequest struct { + ID string `json:"id"` + Password string `json:"password"` + Realm string `json:"realm,omitempty"` + Transport string `json:"transport"` + Context string `json:"context"` + Codecs []string `json:"codecs"` + MaxContacts int32 `json:"max_contacts,omitempty"` +} + +func (e *Endpoint) Router() chi.Router { + r := chi.NewRouter() + r.Post("/", e.create) + + return r +} + +// @Summary Create a new endpoint. +// @Accept json +// @Param payload body createRequest true "Endpoint's information" +// @Success 204 +// @Failure 400 +// @Failure 500 +// @Router /endpoint [post] +func (e *Endpoint) create(w http.ResponseWriter, r *http.Request) { + decoder := json.NewDecoder(r.Body) + payload := createRequest{ + Realm: "asterisk", + MaxContacts: 1, + } + + err := decoder.Decode(&payload) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + + tx, err := e.Begin(r.Context()) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + defer tx.Rollback(r.Context()) + + queries := sqlc.New(tx) + + hash := md5.Sum([]byte(payload.ID + ":" + payload.Realm + ":" + payload.Password)) + err = queries.NewMD5Auth(r.Context(), sqlc.NewMD5AuthParams{ + ID: payload.ID, + Username: db.Text(payload.ID), + Realm: db.Text(payload.Realm), + Md5Cred: db.Text(hex.EncodeToString(hash[:])), + }) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + err = queries.NewEndpoint(r.Context(), sqlc.NewEndpointParams{ + ID: payload.ID, + Transport: db.Text(payload.Transport), + Context: db.Text(payload.Context), + Allow: db.Text(strings.Join(payload.Codecs, ",")), + }) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + err = queries.NewAOR(r.Context(), sqlc.NewAORParams{ + ID: payload.ID, + MaxContacts: db.Int4(payload.MaxContacts), + }) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + err = tx.Commit(r.Context()) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + w.WriteHeader(http.StatusNoContent) +} diff --git a/internal/sqlc/db.go b/internal/sqlc/db.go new file mode 100644 index 0000000..278c210 --- /dev/null +++ b/internal/sqlc/db.go @@ -0,0 +1,32 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package sqlc + +import ( + "context" + + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgconn" +) + +type DBTX interface { + Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error) + Query(context.Context, string, ...interface{}) (pgx.Rows, error) + QueryRow(context.Context, string, ...interface{}) pgx.Row +} + +func New(db DBTX) *Queries { + return &Queries{db: db} +} + +type Queries struct { + db DBTX +} + +func (q *Queries) WithTx(tx pgx.Tx) *Queries { + return &Queries{ + db: tx, + } +} diff --git a/internal/sqlc/models.go b/internal/sqlc/models.go new file mode 100644 index 0000000..461665a --- /dev/null +++ b/internal/sqlc/models.go @@ -0,0 +1,2238 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 + +package sqlc + +import ( + "database/sql/driver" + "fmt" + + "github.com/jackc/pgx/v5/pgtype" +) + +type AstBoolValues string + +const ( + AstBoolValues0 AstBoolValues = "0" + AstBoolValues1 AstBoolValues = "1" + AstBoolValuesOff AstBoolValues = "off" + AstBoolValuesOn AstBoolValues = "on" + AstBoolValuesFalse AstBoolValues = "false" + AstBoolValuesTrue AstBoolValues = "true" + AstBoolValuesNo AstBoolValues = "no" + AstBoolValuesYes AstBoolValues = "yes" +) + +func (e *AstBoolValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = AstBoolValues(s) + case string: + *e = AstBoolValues(s) + default: + return fmt.Errorf("unsupported scan type for AstBoolValues: %T", src) + } + return nil +} + +type NullAstBoolValues struct { + AstBoolValues AstBoolValues + Valid bool // Valid is true if AstBoolValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullAstBoolValues) Scan(value interface{}) error { + if value == nil { + ns.AstBoolValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.AstBoolValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullAstBoolValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.AstBoolValues), nil +} + +type IaxEncryptionValues string + +const ( + IaxEncryptionValuesYes IaxEncryptionValues = "yes" + IaxEncryptionValuesNo IaxEncryptionValues = "no" + IaxEncryptionValuesAes128 IaxEncryptionValues = "aes128" +) + +func (e *IaxEncryptionValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = IaxEncryptionValues(s) + case string: + *e = IaxEncryptionValues(s) + default: + return fmt.Errorf("unsupported scan type for IaxEncryptionValues: %T", src) + } + return nil +} + +type NullIaxEncryptionValues struct { + IaxEncryptionValues IaxEncryptionValues + Valid bool // Valid is true if IaxEncryptionValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullIaxEncryptionValues) Scan(value interface{}) error { + if value == nil { + ns.IaxEncryptionValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.IaxEncryptionValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullIaxEncryptionValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.IaxEncryptionValues), nil +} + +type IaxRequirecalltokenValues string + +const ( + IaxRequirecalltokenValuesYes IaxRequirecalltokenValues = "yes" + IaxRequirecalltokenValuesNo IaxRequirecalltokenValues = "no" + IaxRequirecalltokenValuesAuto IaxRequirecalltokenValues = "auto" +) + +func (e *IaxRequirecalltokenValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = IaxRequirecalltokenValues(s) + case string: + *e = IaxRequirecalltokenValues(s) + default: + return fmt.Errorf("unsupported scan type for IaxRequirecalltokenValues: %T", src) + } + return nil +} + +type NullIaxRequirecalltokenValues struct { + IaxRequirecalltokenValues IaxRequirecalltokenValues + Valid bool // Valid is true if IaxRequirecalltokenValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullIaxRequirecalltokenValues) Scan(value interface{}) error { + if value == nil { + ns.IaxRequirecalltokenValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.IaxRequirecalltokenValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullIaxRequirecalltokenValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.IaxRequirecalltokenValues), nil +} + +type IaxTransferValues string + +const ( + IaxTransferValuesYes IaxTransferValues = "yes" + IaxTransferValuesNo IaxTransferValues = "no" + IaxTransferValuesMediaonly IaxTransferValues = "mediaonly" +) + +func (e *IaxTransferValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = IaxTransferValues(s) + case string: + *e = IaxTransferValues(s) + default: + return fmt.Errorf("unsupported scan type for IaxTransferValues: %T", src) + } + return nil +} + +type NullIaxTransferValues struct { + IaxTransferValues IaxTransferValues + Valid bool // Valid is true if IaxTransferValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullIaxTransferValues) Scan(value interface{}) error { + if value == nil { + ns.IaxTransferValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.IaxTransferValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullIaxTransferValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.IaxTransferValues), nil +} + +type MohModeValues string + +const ( + MohModeValuesCustom MohModeValues = "custom" + MohModeValuesFiles MohModeValues = "files" + MohModeValuesMp3nb MohModeValues = "mp3nb" + MohModeValuesQuietmp3nb MohModeValues = "quietmp3nb" + MohModeValuesQuietmp3 MohModeValues = "quietmp3" + MohModeValuesPlaylist MohModeValues = "playlist" +) + +func (e *MohModeValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = MohModeValues(s) + case string: + *e = MohModeValues(s) + default: + return fmt.Errorf("unsupported scan type for MohModeValues: %T", src) + } + return nil +} + +type NullMohModeValues struct { + MohModeValues MohModeValues + Valid bool // Valid is true if MohModeValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullMohModeValues) Scan(value interface{}) error { + if value == nil { + ns.MohModeValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.MohModeValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullMohModeValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.MohModeValues), nil +} + +type Pjsip100relValuesV2 string + +const ( + Pjsip100relValuesV2No Pjsip100relValuesV2 = "no" + Pjsip100relValuesV2Required Pjsip100relValuesV2 = "required" + Pjsip100relValuesV2PeerSupported Pjsip100relValuesV2 = "peer_supported" + Pjsip100relValuesV2Yes Pjsip100relValuesV2 = "yes" +) + +func (e *Pjsip100relValuesV2) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = Pjsip100relValuesV2(s) + case string: + *e = Pjsip100relValuesV2(s) + default: + return fmt.Errorf("unsupported scan type for Pjsip100relValuesV2: %T", src) + } + return nil +} + +type NullPjsip100relValuesV2 struct { + Pjsip100relValuesV2 Pjsip100relValuesV2 + Valid bool // Valid is true if Pjsip100relValuesV2 is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsip100relValuesV2) Scan(value interface{}) error { + if value == nil { + ns.Pjsip100relValuesV2, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.Pjsip100relValuesV2.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsip100relValuesV2) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.Pjsip100relValuesV2), nil +} + +type PjsipAuthTypeValuesV2 string + +const ( + PjsipAuthTypeValuesV2Md5 PjsipAuthTypeValuesV2 = "md5" + PjsipAuthTypeValuesV2Userpass PjsipAuthTypeValuesV2 = "userpass" + PjsipAuthTypeValuesV2GoogleOauth PjsipAuthTypeValuesV2 = "google_oauth" +) + +func (e *PjsipAuthTypeValuesV2) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipAuthTypeValuesV2(s) + case string: + *e = PjsipAuthTypeValuesV2(s) + default: + return fmt.Errorf("unsupported scan type for PjsipAuthTypeValuesV2: %T", src) + } + return nil +} + +type NullPjsipAuthTypeValuesV2 struct { + PjsipAuthTypeValuesV2 PjsipAuthTypeValuesV2 + Valid bool // Valid is true if PjsipAuthTypeValuesV2 is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipAuthTypeValuesV2) Scan(value interface{}) error { + if value == nil { + ns.PjsipAuthTypeValuesV2, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipAuthTypeValuesV2.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipAuthTypeValuesV2) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipAuthTypeValuesV2), nil +} + +type PjsipCidPrivacyValues string + +const ( + PjsipCidPrivacyValuesAllowedNotScreened PjsipCidPrivacyValues = "allowed_not_screened" + PjsipCidPrivacyValuesAllowedPassedScreened PjsipCidPrivacyValues = "allowed_passed_screened" + PjsipCidPrivacyValuesAllowedFailedScreened PjsipCidPrivacyValues = "allowed_failed_screened" + PjsipCidPrivacyValuesAllowed PjsipCidPrivacyValues = "allowed" + PjsipCidPrivacyValuesProhibNotScreened PjsipCidPrivacyValues = "prohib_not_screened" + PjsipCidPrivacyValuesProhibPassedScreened PjsipCidPrivacyValues = "prohib_passed_screened" + PjsipCidPrivacyValuesProhibFailedScreened PjsipCidPrivacyValues = "prohib_failed_screened" + PjsipCidPrivacyValuesProhib PjsipCidPrivacyValues = "prohib" + PjsipCidPrivacyValuesUnavailable PjsipCidPrivacyValues = "unavailable" +) + +func (e *PjsipCidPrivacyValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipCidPrivacyValues(s) + case string: + *e = PjsipCidPrivacyValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipCidPrivacyValues: %T", src) + } + return nil +} + +type NullPjsipCidPrivacyValues struct { + PjsipCidPrivacyValues PjsipCidPrivacyValues + Valid bool // Valid is true if PjsipCidPrivacyValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipCidPrivacyValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipCidPrivacyValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipCidPrivacyValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipCidPrivacyValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipCidPrivacyValues), nil +} + +type PjsipConnectedLineMethodValues string + +const ( + PjsipConnectedLineMethodValuesInvite PjsipConnectedLineMethodValues = "invite" + PjsipConnectedLineMethodValuesReinvite PjsipConnectedLineMethodValues = "reinvite" + PjsipConnectedLineMethodValuesUpdate PjsipConnectedLineMethodValues = "update" +) + +func (e *PjsipConnectedLineMethodValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipConnectedLineMethodValues(s) + case string: + *e = PjsipConnectedLineMethodValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipConnectedLineMethodValues: %T", src) + } + return nil +} + +type NullPjsipConnectedLineMethodValues struct { + PjsipConnectedLineMethodValues PjsipConnectedLineMethodValues + Valid bool // Valid is true if PjsipConnectedLineMethodValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipConnectedLineMethodValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipConnectedLineMethodValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipConnectedLineMethodValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipConnectedLineMethodValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipConnectedLineMethodValues), nil +} + +type PjsipDirectMediaGlareMitigationValues string + +const ( + PjsipDirectMediaGlareMitigationValuesNone PjsipDirectMediaGlareMitigationValues = "none" + PjsipDirectMediaGlareMitigationValuesOutgoing PjsipDirectMediaGlareMitigationValues = "outgoing" + PjsipDirectMediaGlareMitigationValuesIncoming PjsipDirectMediaGlareMitigationValues = "incoming" +) + +func (e *PjsipDirectMediaGlareMitigationValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipDirectMediaGlareMitigationValues(s) + case string: + *e = PjsipDirectMediaGlareMitigationValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipDirectMediaGlareMitigationValues: %T", src) + } + return nil +} + +type NullPjsipDirectMediaGlareMitigationValues struct { + PjsipDirectMediaGlareMitigationValues PjsipDirectMediaGlareMitigationValues + Valid bool // Valid is true if PjsipDirectMediaGlareMitigationValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipDirectMediaGlareMitigationValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipDirectMediaGlareMitigationValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipDirectMediaGlareMitigationValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipDirectMediaGlareMitigationValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipDirectMediaGlareMitigationValues), nil +} + +type PjsipDtlsSetupValues string + +const ( + PjsipDtlsSetupValuesActive PjsipDtlsSetupValues = "active" + PjsipDtlsSetupValuesPassive PjsipDtlsSetupValues = "passive" + PjsipDtlsSetupValuesActpass PjsipDtlsSetupValues = "actpass" +) + +func (e *PjsipDtlsSetupValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipDtlsSetupValues(s) + case string: + *e = PjsipDtlsSetupValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipDtlsSetupValues: %T", src) + } + return nil +} + +type NullPjsipDtlsSetupValues struct { + PjsipDtlsSetupValues PjsipDtlsSetupValues + Valid bool // Valid is true if PjsipDtlsSetupValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipDtlsSetupValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipDtlsSetupValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipDtlsSetupValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipDtlsSetupValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipDtlsSetupValues), nil +} + +type PjsipDtmfModeValuesV3 string + +const ( + PjsipDtmfModeValuesV3Rfc4733 PjsipDtmfModeValuesV3 = "rfc4733" + PjsipDtmfModeValuesV3Inband PjsipDtmfModeValuesV3 = "inband" + PjsipDtmfModeValuesV3Info PjsipDtmfModeValuesV3 = "info" + PjsipDtmfModeValuesV3Auto PjsipDtmfModeValuesV3 = "auto" + PjsipDtmfModeValuesV3AutoInfo PjsipDtmfModeValuesV3 = "auto_info" +) + +func (e *PjsipDtmfModeValuesV3) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipDtmfModeValuesV3(s) + case string: + *e = PjsipDtmfModeValuesV3(s) + default: + return fmt.Errorf("unsupported scan type for PjsipDtmfModeValuesV3: %T", src) + } + return nil +} + +type NullPjsipDtmfModeValuesV3 struct { + PjsipDtmfModeValuesV3 PjsipDtmfModeValuesV3 + Valid bool // Valid is true if PjsipDtmfModeValuesV3 is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipDtmfModeValuesV3) Scan(value interface{}) error { + if value == nil { + ns.PjsipDtmfModeValuesV3, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipDtmfModeValuesV3.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipDtmfModeValuesV3) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipDtmfModeValuesV3), nil +} + +type PjsipIncomingCallOfferPrefValues string + +const ( + PjsipIncomingCallOfferPrefValuesLocal PjsipIncomingCallOfferPrefValues = "local" + PjsipIncomingCallOfferPrefValuesLocalFirst PjsipIncomingCallOfferPrefValues = "local_first" + PjsipIncomingCallOfferPrefValuesRemote PjsipIncomingCallOfferPrefValues = "remote" + PjsipIncomingCallOfferPrefValuesRemoteFirst PjsipIncomingCallOfferPrefValues = "remote_first" +) + +func (e *PjsipIncomingCallOfferPrefValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipIncomingCallOfferPrefValues(s) + case string: + *e = PjsipIncomingCallOfferPrefValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipIncomingCallOfferPrefValues: %T", src) + } + return nil +} + +type NullPjsipIncomingCallOfferPrefValues struct { + PjsipIncomingCallOfferPrefValues PjsipIncomingCallOfferPrefValues + Valid bool // Valid is true if PjsipIncomingCallOfferPrefValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipIncomingCallOfferPrefValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipIncomingCallOfferPrefValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipIncomingCallOfferPrefValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipIncomingCallOfferPrefValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipIncomingCallOfferPrefValues), nil +} + +type PjsipMediaEncryptionValues string + +const ( + PjsipMediaEncryptionValuesNo PjsipMediaEncryptionValues = "no" + PjsipMediaEncryptionValuesSdes PjsipMediaEncryptionValues = "sdes" + PjsipMediaEncryptionValuesDtls PjsipMediaEncryptionValues = "dtls" +) + +func (e *PjsipMediaEncryptionValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipMediaEncryptionValues(s) + case string: + *e = PjsipMediaEncryptionValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipMediaEncryptionValues: %T", src) + } + return nil +} + +type NullPjsipMediaEncryptionValues struct { + PjsipMediaEncryptionValues PjsipMediaEncryptionValues + Valid bool // Valid is true if PjsipMediaEncryptionValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipMediaEncryptionValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipMediaEncryptionValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipMediaEncryptionValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipMediaEncryptionValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipMediaEncryptionValues), nil +} + +type PjsipOutgoingCallOfferPrefValues string + +const ( + PjsipOutgoingCallOfferPrefValuesLocal PjsipOutgoingCallOfferPrefValues = "local" + PjsipOutgoingCallOfferPrefValuesLocalMerge PjsipOutgoingCallOfferPrefValues = "local_merge" + PjsipOutgoingCallOfferPrefValuesLocalFirst PjsipOutgoingCallOfferPrefValues = "local_first" + PjsipOutgoingCallOfferPrefValuesRemote PjsipOutgoingCallOfferPrefValues = "remote" + PjsipOutgoingCallOfferPrefValuesRemoteMerge PjsipOutgoingCallOfferPrefValues = "remote_merge" + PjsipOutgoingCallOfferPrefValuesRemoteFirst PjsipOutgoingCallOfferPrefValues = "remote_first" +) + +func (e *PjsipOutgoingCallOfferPrefValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipOutgoingCallOfferPrefValues(s) + case string: + *e = PjsipOutgoingCallOfferPrefValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipOutgoingCallOfferPrefValues: %T", src) + } + return nil +} + +type NullPjsipOutgoingCallOfferPrefValues struct { + PjsipOutgoingCallOfferPrefValues PjsipOutgoingCallOfferPrefValues + Valid bool // Valid is true if PjsipOutgoingCallOfferPrefValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipOutgoingCallOfferPrefValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipOutgoingCallOfferPrefValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipOutgoingCallOfferPrefValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipOutgoingCallOfferPrefValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipOutgoingCallOfferPrefValues), nil +} + +type PjsipRedirectMethodValues string + +const ( + PjsipRedirectMethodValuesUser PjsipRedirectMethodValues = "user" + PjsipRedirectMethodValuesUriCore PjsipRedirectMethodValues = "uri_core" + PjsipRedirectMethodValuesUriPjsip PjsipRedirectMethodValues = "uri_pjsip" +) + +func (e *PjsipRedirectMethodValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipRedirectMethodValues(s) + case string: + *e = PjsipRedirectMethodValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipRedirectMethodValues: %T", src) + } + return nil +} + +type NullPjsipRedirectMethodValues struct { + PjsipRedirectMethodValues PjsipRedirectMethodValues + Valid bool // Valid is true if PjsipRedirectMethodValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipRedirectMethodValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipRedirectMethodValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipRedirectMethodValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipRedirectMethodValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipRedirectMethodValues), nil +} + +type PjsipT38udptlEcValues string + +const ( + PjsipT38udptlEcValuesNone PjsipT38udptlEcValues = "none" + PjsipT38udptlEcValuesFec PjsipT38udptlEcValues = "fec" + PjsipT38udptlEcValuesRedundancy PjsipT38udptlEcValues = "redundancy" +) + +func (e *PjsipT38udptlEcValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipT38udptlEcValues(s) + case string: + *e = PjsipT38udptlEcValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipT38udptlEcValues: %T", src) + } + return nil +} + +type NullPjsipT38udptlEcValues struct { + PjsipT38udptlEcValues PjsipT38udptlEcValues + Valid bool // Valid is true if PjsipT38udptlEcValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipT38udptlEcValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipT38udptlEcValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipT38udptlEcValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipT38udptlEcValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipT38udptlEcValues), nil +} + +type PjsipTaskprocessorOverloadTriggerValues string + +const ( + PjsipTaskprocessorOverloadTriggerValuesNone PjsipTaskprocessorOverloadTriggerValues = "none" + PjsipTaskprocessorOverloadTriggerValuesGlobal PjsipTaskprocessorOverloadTriggerValues = "global" + PjsipTaskprocessorOverloadTriggerValuesPjsipOnly PjsipTaskprocessorOverloadTriggerValues = "pjsip_only" +) + +func (e *PjsipTaskprocessorOverloadTriggerValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipTaskprocessorOverloadTriggerValues(s) + case string: + *e = PjsipTaskprocessorOverloadTriggerValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipTaskprocessorOverloadTriggerValues: %T", src) + } + return nil +} + +type NullPjsipTaskprocessorOverloadTriggerValues struct { + PjsipTaskprocessorOverloadTriggerValues PjsipTaskprocessorOverloadTriggerValues + Valid bool // Valid is true if PjsipTaskprocessorOverloadTriggerValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipTaskprocessorOverloadTriggerValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipTaskprocessorOverloadTriggerValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipTaskprocessorOverloadTriggerValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipTaskprocessorOverloadTriggerValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipTaskprocessorOverloadTriggerValues), nil +} + +type PjsipTimerValues string + +const ( + PjsipTimerValuesForced PjsipTimerValues = "forced" + PjsipTimerValuesNo PjsipTimerValues = "no" + PjsipTimerValuesRequired PjsipTimerValues = "required" + PjsipTimerValuesYes PjsipTimerValues = "yes" +) + +func (e *PjsipTimerValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipTimerValues(s) + case string: + *e = PjsipTimerValues(s) + default: + return fmt.Errorf("unsupported scan type for PjsipTimerValues: %T", src) + } + return nil +} + +type NullPjsipTimerValues struct { + PjsipTimerValues PjsipTimerValues + Valid bool // Valid is true if PjsipTimerValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipTimerValues) Scan(value interface{}) error { + if value == nil { + ns.PjsipTimerValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipTimerValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipTimerValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipTimerValues), nil +} + +type PjsipTransportMethodValuesV2 string + +const ( + PjsipTransportMethodValuesV2Default PjsipTransportMethodValuesV2 = "default" + PjsipTransportMethodValuesV2Unspecified PjsipTransportMethodValuesV2 = "unspecified" + PjsipTransportMethodValuesV2Tlsv1 PjsipTransportMethodValuesV2 = "tlsv1" + PjsipTransportMethodValuesV2Tlsv11 PjsipTransportMethodValuesV2 = "tlsv1_1" + PjsipTransportMethodValuesV2Tlsv12 PjsipTransportMethodValuesV2 = "tlsv1_2" + PjsipTransportMethodValuesV2Tlsv13 PjsipTransportMethodValuesV2 = "tlsv1_3" + PjsipTransportMethodValuesV2Sslv2 PjsipTransportMethodValuesV2 = "sslv2" + PjsipTransportMethodValuesV2Sslv23 PjsipTransportMethodValuesV2 = "sslv23" + PjsipTransportMethodValuesV2Sslv3 PjsipTransportMethodValuesV2 = "sslv3" +) + +func (e *PjsipTransportMethodValuesV2) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipTransportMethodValuesV2(s) + case string: + *e = PjsipTransportMethodValuesV2(s) + default: + return fmt.Errorf("unsupported scan type for PjsipTransportMethodValuesV2: %T", src) + } + return nil +} + +type NullPjsipTransportMethodValuesV2 struct { + PjsipTransportMethodValuesV2 PjsipTransportMethodValuesV2 + Valid bool // Valid is true if PjsipTransportMethodValuesV2 is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipTransportMethodValuesV2) Scan(value interface{}) error { + if value == nil { + ns.PjsipTransportMethodValuesV2, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipTransportMethodValuesV2.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipTransportMethodValuesV2) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipTransportMethodValuesV2), nil +} + +type PjsipTransportProtocolValuesV2 string + +const ( + PjsipTransportProtocolValuesV2Udp PjsipTransportProtocolValuesV2 = "udp" + PjsipTransportProtocolValuesV2Tcp PjsipTransportProtocolValuesV2 = "tcp" + PjsipTransportProtocolValuesV2Tls PjsipTransportProtocolValuesV2 = "tls" + PjsipTransportProtocolValuesV2Ws PjsipTransportProtocolValuesV2 = "ws" + PjsipTransportProtocolValuesV2Wss PjsipTransportProtocolValuesV2 = "wss" + PjsipTransportProtocolValuesV2Flow PjsipTransportProtocolValuesV2 = "flow" +) + +func (e *PjsipTransportProtocolValuesV2) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = PjsipTransportProtocolValuesV2(s) + case string: + *e = PjsipTransportProtocolValuesV2(s) + default: + return fmt.Errorf("unsupported scan type for PjsipTransportProtocolValuesV2: %T", src) + } + return nil +} + +type NullPjsipTransportProtocolValuesV2 struct { + PjsipTransportProtocolValuesV2 PjsipTransportProtocolValuesV2 + Valid bool // Valid is true if PjsipTransportProtocolValuesV2 is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullPjsipTransportProtocolValuesV2) Scan(value interface{}) error { + if value == nil { + ns.PjsipTransportProtocolValuesV2, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.PjsipTransportProtocolValuesV2.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullPjsipTransportProtocolValuesV2) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.PjsipTransportProtocolValuesV2), nil +} + +type QueueAutopauseValues string + +const ( + QueueAutopauseValuesYes QueueAutopauseValues = "yes" + QueueAutopauseValuesNo QueueAutopauseValues = "no" + QueueAutopauseValuesAll QueueAutopauseValues = "all" +) + +func (e *QueueAutopauseValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = QueueAutopauseValues(s) + case string: + *e = QueueAutopauseValues(s) + default: + return fmt.Errorf("unsupported scan type for QueueAutopauseValues: %T", src) + } + return nil +} + +type NullQueueAutopauseValues struct { + QueueAutopauseValues QueueAutopauseValues + Valid bool // Valid is true if QueueAutopauseValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullQueueAutopauseValues) Scan(value interface{}) error { + if value == nil { + ns.QueueAutopauseValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.QueueAutopauseValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullQueueAutopauseValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.QueueAutopauseValues), nil +} + +type QueueStrategyValues string + +const ( + QueueStrategyValuesRingall QueueStrategyValues = "ringall" + QueueStrategyValuesLeastrecent QueueStrategyValues = "leastrecent" + QueueStrategyValuesFewestcalls QueueStrategyValues = "fewestcalls" + QueueStrategyValuesRandom QueueStrategyValues = "random" + QueueStrategyValuesRrmemory QueueStrategyValues = "rrmemory" + QueueStrategyValuesLinear QueueStrategyValues = "linear" + QueueStrategyValuesWrandom QueueStrategyValues = "wrandom" + QueueStrategyValuesRrordered QueueStrategyValues = "rrordered" +) + +func (e *QueueStrategyValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = QueueStrategyValues(s) + case string: + *e = QueueStrategyValues(s) + default: + return fmt.Errorf("unsupported scan type for QueueStrategyValues: %T", src) + } + return nil +} + +type NullQueueStrategyValues struct { + QueueStrategyValues QueueStrategyValues + Valid bool // Valid is true if QueueStrategyValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullQueueStrategyValues) Scan(value interface{}) error { + if value == nil { + ns.QueueStrategyValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.QueueStrategyValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullQueueStrategyValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.QueueStrategyValues), nil +} + +type SecurityNegotiationValues string + +const ( + SecurityNegotiationValuesNo SecurityNegotiationValues = "no" + SecurityNegotiationValuesMediasec SecurityNegotiationValues = "mediasec" +) + +func (e *SecurityNegotiationValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = SecurityNegotiationValues(s) + case string: + *e = SecurityNegotiationValues(s) + default: + return fmt.Errorf("unsupported scan type for SecurityNegotiationValues: %T", src) + } + return nil +} + +type NullSecurityNegotiationValues struct { + SecurityNegotiationValues SecurityNegotiationValues + Valid bool // Valid is true if SecurityNegotiationValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullSecurityNegotiationValues) Scan(value interface{}) error { + if value == nil { + ns.SecurityNegotiationValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.SecurityNegotiationValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullSecurityNegotiationValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.SecurityNegotiationValues), nil +} + +type ShaHashValues string + +const ( + ShaHashValuesSHA1 ShaHashValues = "SHA-1" + ShaHashValuesSHA256 ShaHashValues = "SHA-256" +) + +func (e *ShaHashValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = ShaHashValues(s) + case string: + *e = ShaHashValues(s) + default: + return fmt.Errorf("unsupported scan type for ShaHashValues: %T", src) + } + return nil +} + +type NullShaHashValues struct { + ShaHashValues ShaHashValues + Valid bool // Valid is true if ShaHashValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullShaHashValues) Scan(value interface{}) error { + if value == nil { + ns.ShaHashValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.ShaHashValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullShaHashValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.ShaHashValues), nil +} + +type SipCallingpresValues string + +const ( + SipCallingpresValuesAllowedNotScreened SipCallingpresValues = "allowed_not_screened" + SipCallingpresValuesAllowedPassedScreen SipCallingpresValues = "allowed_passed_screen" + SipCallingpresValuesAllowedFailedScreen SipCallingpresValues = "allowed_failed_screen" + SipCallingpresValuesAllowed SipCallingpresValues = "allowed" + SipCallingpresValuesProhibNotScreened SipCallingpresValues = "prohib_not_screened" + SipCallingpresValuesProhibPassedScreen SipCallingpresValues = "prohib_passed_screen" + SipCallingpresValuesProhibFailedScreen SipCallingpresValues = "prohib_failed_screen" + SipCallingpresValuesProhib SipCallingpresValues = "prohib" +) + +func (e *SipCallingpresValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = SipCallingpresValues(s) + case string: + *e = SipCallingpresValues(s) + default: + return fmt.Errorf("unsupported scan type for SipCallingpresValues: %T", src) + } + return nil +} + +type NullSipCallingpresValues struct { + SipCallingpresValues SipCallingpresValues + Valid bool // Valid is true if SipCallingpresValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullSipCallingpresValues) Scan(value interface{}) error { + if value == nil { + ns.SipCallingpresValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.SipCallingpresValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullSipCallingpresValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.SipCallingpresValues), nil +} + +type SipDirectmediaValuesV2 string + +const ( + SipDirectmediaValuesV2Yes SipDirectmediaValuesV2 = "yes" + SipDirectmediaValuesV2No SipDirectmediaValuesV2 = "no" + SipDirectmediaValuesV2Nonat SipDirectmediaValuesV2 = "nonat" + SipDirectmediaValuesV2Update SipDirectmediaValuesV2 = "update" + SipDirectmediaValuesV2Outgoing SipDirectmediaValuesV2 = "outgoing" +) + +func (e *SipDirectmediaValuesV2) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = SipDirectmediaValuesV2(s) + case string: + *e = SipDirectmediaValuesV2(s) + default: + return fmt.Errorf("unsupported scan type for SipDirectmediaValuesV2: %T", src) + } + return nil +} + +type NullSipDirectmediaValuesV2 struct { + SipDirectmediaValuesV2 SipDirectmediaValuesV2 + Valid bool // Valid is true if SipDirectmediaValuesV2 is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullSipDirectmediaValuesV2) Scan(value interface{}) error { + if value == nil { + ns.SipDirectmediaValuesV2, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.SipDirectmediaValuesV2.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullSipDirectmediaValuesV2) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.SipDirectmediaValuesV2), nil +} + +type SipDtmfmodeValues string + +const ( + SipDtmfmodeValuesRfc2833 SipDtmfmodeValues = "rfc2833" + SipDtmfmodeValuesInfo SipDtmfmodeValues = "info" + SipDtmfmodeValuesShortinfo SipDtmfmodeValues = "shortinfo" + SipDtmfmodeValuesInband SipDtmfmodeValues = "inband" + SipDtmfmodeValuesAuto SipDtmfmodeValues = "auto" +) + +func (e *SipDtmfmodeValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = SipDtmfmodeValues(s) + case string: + *e = SipDtmfmodeValues(s) + default: + return fmt.Errorf("unsupported scan type for SipDtmfmodeValues: %T", src) + } + return nil +} + +type NullSipDtmfmodeValues struct { + SipDtmfmodeValues SipDtmfmodeValues + Valid bool // Valid is true if SipDtmfmodeValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullSipDtmfmodeValues) Scan(value interface{}) error { + if value == nil { + ns.SipDtmfmodeValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.SipDtmfmodeValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullSipDtmfmodeValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.SipDtmfmodeValues), nil +} + +type SipProgressinbandValues string + +const ( + SipProgressinbandValuesYes SipProgressinbandValues = "yes" + SipProgressinbandValuesNo SipProgressinbandValues = "no" + SipProgressinbandValuesNever SipProgressinbandValues = "never" +) + +func (e *SipProgressinbandValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = SipProgressinbandValues(s) + case string: + *e = SipProgressinbandValues(s) + default: + return fmt.Errorf("unsupported scan type for SipProgressinbandValues: %T", src) + } + return nil +} + +type NullSipProgressinbandValues struct { + SipProgressinbandValues SipProgressinbandValues + Valid bool // Valid is true if SipProgressinbandValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullSipProgressinbandValues) Scan(value interface{}) error { + if value == nil { + ns.SipProgressinbandValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.SipProgressinbandValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullSipProgressinbandValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.SipProgressinbandValues), nil +} + +type SipSessionRefresherValues string + +const ( + SipSessionRefresherValuesUac SipSessionRefresherValues = "uac" + SipSessionRefresherValuesUas SipSessionRefresherValues = "uas" +) + +func (e *SipSessionRefresherValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = SipSessionRefresherValues(s) + case string: + *e = SipSessionRefresherValues(s) + default: + return fmt.Errorf("unsupported scan type for SipSessionRefresherValues: %T", src) + } + return nil +} + +type NullSipSessionRefresherValues struct { + SipSessionRefresherValues SipSessionRefresherValues + Valid bool // Valid is true if SipSessionRefresherValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullSipSessionRefresherValues) Scan(value interface{}) error { + if value == nil { + ns.SipSessionRefresherValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.SipSessionRefresherValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullSipSessionRefresherValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.SipSessionRefresherValues), nil +} + +type SipSessionTimersValues string + +const ( + SipSessionTimersValuesAccept SipSessionTimersValues = "accept" + SipSessionTimersValuesRefuse SipSessionTimersValues = "refuse" + SipSessionTimersValuesOriginate SipSessionTimersValues = "originate" +) + +func (e *SipSessionTimersValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = SipSessionTimersValues(s) + case string: + *e = SipSessionTimersValues(s) + default: + return fmt.Errorf("unsupported scan type for SipSessionTimersValues: %T", src) + } + return nil +} + +type NullSipSessionTimersValues struct { + SipSessionTimersValues SipSessionTimersValues + Valid bool // Valid is true if SipSessionTimersValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullSipSessionTimersValues) Scan(value interface{}) error { + if value == nil { + ns.SipSessionTimersValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.SipSessionTimersValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullSipSessionTimersValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.SipSessionTimersValues), nil +} + +type SipTransportValues string + +const ( + SipTransportValuesUdp SipTransportValues = "udp" + SipTransportValuesTcp SipTransportValues = "tcp" + SipTransportValuesTls SipTransportValues = "tls" + SipTransportValuesWs SipTransportValues = "ws" + SipTransportValuesWss SipTransportValues = "wss" + SipTransportValuesUdptcp SipTransportValues = "udp,tcp" + SipTransportValuesTcpudp SipTransportValues = "tcp,udp" +) + +func (e *SipTransportValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = SipTransportValues(s) + case string: + *e = SipTransportValues(s) + default: + return fmt.Errorf("unsupported scan type for SipTransportValues: %T", src) + } + return nil +} + +type NullSipTransportValues struct { + SipTransportValues SipTransportValues + Valid bool // Valid is true if SipTransportValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullSipTransportValues) Scan(value interface{}) error { + if value == nil { + ns.SipTransportValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.SipTransportValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullSipTransportValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.SipTransportValues), nil +} + +type TypeValues string + +const ( + TypeValuesFriend TypeValues = "friend" + TypeValuesUser TypeValues = "user" + TypeValuesPeer TypeValues = "peer" +) + +func (e *TypeValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = TypeValues(s) + case string: + *e = TypeValues(s) + default: + return fmt.Errorf("unsupported scan type for TypeValues: %T", src) + } + return nil +} + +type NullTypeValues struct { + TypeValues TypeValues + Valid bool // Valid is true if TypeValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullTypeValues) Scan(value interface{}) error { + if value == nil { + ns.TypeValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.TypeValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullTypeValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.TypeValues), nil +} + +type YesNoValues string + +const ( + YesNoValuesYes YesNoValues = "yes" + YesNoValuesNo YesNoValues = "no" +) + +func (e *YesNoValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = YesNoValues(s) + case string: + *e = YesNoValues(s) + default: + return fmt.Errorf("unsupported scan type for YesNoValues: %T", src) + } + return nil +} + +type NullYesNoValues struct { + YesNoValues YesNoValues + Valid bool // Valid is true if YesNoValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullYesNoValues) Scan(value interface{}) error { + if value == nil { + ns.YesNoValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.YesNoValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullYesNoValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.YesNoValues), nil +} + +type YesnoValues string + +const ( + YesnoValuesYes YesnoValues = "yes" + YesnoValuesNo YesnoValues = "no" +) + +func (e *YesnoValues) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = YesnoValues(s) + case string: + *e = YesnoValues(s) + default: + return fmt.Errorf("unsupported scan type for YesnoValues: %T", src) + } + return nil +} + +type NullYesnoValues struct { + YesnoValues YesnoValues + Valid bool // Valid is true if YesnoValues is not NULL +} + +// Scan implements the Scanner interface. +func (ns *NullYesnoValues) Scan(value interface{}) error { + if value == nil { + ns.YesnoValues, ns.Valid = "", false + return nil + } + ns.Valid = true + return ns.YesnoValues.Scan(value) +} + +// Value implements the driver Valuer interface. +func (ns NullYesnoValues) Value() (driver.Value, error) { + if !ns.Valid { + return nil, nil + } + return string(ns.YesnoValues), nil +} + +type AlembicVersion struct { + VersionNum string +} + +type Extension struct { + ID int64 + Context string + Exten string + Priority int32 + App string + Appdata string +} + +type Iaxfriend struct { + ID int32 + Name string + Type NullTypeValues + Username pgtype.Text + Mailbox pgtype.Text + Secret pgtype.Text + Dbsecret pgtype.Text + Context pgtype.Text + Regcontext pgtype.Text + Host pgtype.Text + Ipaddr pgtype.Text + Port pgtype.Int4 + Defaultip pgtype.Text + Sourceaddress pgtype.Text + Mask pgtype.Text + Regexten pgtype.Text + Regseconds pgtype.Int4 + Accountcode pgtype.Text + Mohinterpret pgtype.Text + Mohsuggest pgtype.Text + Inkeys pgtype.Text + Outkeys pgtype.Text + Language pgtype.Text + Callerid pgtype.Text + CidNumber pgtype.Text + Sendani NullYesNoValues + Fullname pgtype.Text + Trunk NullYesNoValues + Auth pgtype.Text + Maxauthreq pgtype.Int4 + Requirecalltoken NullIaxRequirecalltokenValues + Encryption NullIaxEncryptionValues + Transfer NullIaxTransferValues + Jitterbuffer NullYesNoValues + Forcejitterbuffer NullYesNoValues + Disallow pgtype.Text + Allow pgtype.Text + Codecpriority pgtype.Text + Qualify pgtype.Text + Qualifysmoothing NullYesNoValues + Qualifyfreqok pgtype.Text + Qualifyfreqnotok pgtype.Text + Timezone pgtype.Text + Adsi NullYesNoValues + Amaflags pgtype.Text + Setvar pgtype.Text +} + +type Meetme struct { + Bookid int32 + Confno string + Starttime pgtype.Timestamp + Endtime pgtype.Timestamp + Pin pgtype.Text + Adminpin pgtype.Text + Opts pgtype.Text + Adminopts pgtype.Text + Recordingfilename pgtype.Text + Recordingformat pgtype.Text + Maxusers pgtype.Int4 + Members int32 +} + +type Musiconhold struct { + Name string + Mode NullMohModeValues + Directory pgtype.Text + Application pgtype.Text + Digit pgtype.Text + Sort pgtype.Text + Format pgtype.Text + Stamp pgtype.Timestamp + LoopLast NullYesnoValues +} + +type MusiconholdEntry struct { + Name string + Position int32 + Entry string +} + +type PsAor struct { + ID string + Contact pgtype.Text + DefaultExpiration pgtype.Int4 + Mailboxes pgtype.Text + MaxContacts pgtype.Int4 + MinimumExpiration pgtype.Int4 + RemoveExisting NullAstBoolValues + QualifyFrequency pgtype.Int4 + AuthenticateQualify NullAstBoolValues + MaximumExpiration pgtype.Int4 + OutboundProxy pgtype.Text + SupportPath NullAstBoolValues + QualifyTimeout pgtype.Float8 + VoicemailExtension pgtype.Text + RemoveUnavailable NullAstBoolValues +} + +type PsAsteriskPublication struct { + ID string + DevicestatePublish pgtype.Text + MailboxstatePublish pgtype.Text + DeviceState NullAstBoolValues + DeviceStateFilter pgtype.Text + MailboxState NullAstBoolValues + MailboxStateFilter pgtype.Text +} + +type PsAuth struct { + ID string + AuthType NullPjsipAuthTypeValuesV2 + NonceLifetime pgtype.Int4 + Md5Cred pgtype.Text + Password pgtype.Text + Realm pgtype.Text + Username pgtype.Text + RefreshToken pgtype.Text + OauthClientid pgtype.Text + OauthSecret pgtype.Text +} + +type PsContact struct { + ID string + Uri pgtype.Text + ExpirationTime pgtype.Int8 + QualifyFrequency pgtype.Int4 + OutboundProxy pgtype.Text + Path pgtype.Text + UserAgent pgtype.Text + QualifyTimeout pgtype.Float8 + RegServer pgtype.Text + AuthenticateQualify NullAstBoolValues + ViaAddr pgtype.Text + ViaPort pgtype.Int4 + CallID pgtype.Text + Endpoint pgtype.Text + PruneOnBoot NullAstBoolValues +} + +type PsDomainAlias struct { + ID string + Domain pgtype.Text +} + +type PsEndpoint struct { + ID string + Transport pgtype.Text + Aors pgtype.Text + Auth pgtype.Text + Context pgtype.Text + Disallow pgtype.Text + Allow pgtype.Text + DirectMedia NullAstBoolValues + ConnectedLineMethod NullPjsipConnectedLineMethodValues + DirectMediaMethod NullPjsipConnectedLineMethodValues + DirectMediaGlareMitigation NullPjsipDirectMediaGlareMitigationValues + DisableDirectMediaOnNat NullAstBoolValues + DtmfMode NullPjsipDtmfModeValuesV3 + ExternalMediaAddress pgtype.Text + ForceRport NullAstBoolValues + IceSupport NullAstBoolValues + IdentifyBy pgtype.Text + Mailboxes pgtype.Text + MohSuggest pgtype.Text + OutboundAuth pgtype.Text + OutboundProxy pgtype.Text + RewriteContact NullAstBoolValues + RtpIpv6 NullAstBoolValues + RtpSymmetric NullAstBoolValues + SendDiversion NullAstBoolValues + SendPai NullAstBoolValues + SendRpid NullAstBoolValues + TimersMinSe pgtype.Int4 + Timers NullPjsipTimerValues + TimersSessExpires pgtype.Int4 + Callerid pgtype.Text + CalleridPrivacy NullPjsipCidPrivacyValues + CalleridTag pgtype.Text + _100rel NullPjsip100relValuesV2 + AggregateMwi NullAstBoolValues + TrustIDInbound NullAstBoolValues + TrustIDOutbound NullAstBoolValues + UsePtime NullAstBoolValues + UseAvpf NullAstBoolValues + MediaEncryption NullPjsipMediaEncryptionValues + InbandProgress NullAstBoolValues + CallGroup pgtype.Text + PickupGroup pgtype.Text + NamedCallGroup pgtype.Text + NamedPickupGroup pgtype.Text + DeviceStateBusyAt pgtype.Int4 + FaxDetect NullAstBoolValues + T38Udptl NullAstBoolValues + T38UdptlEc NullPjsipT38udptlEcValues + T38UdptlMaxdatagram pgtype.Int4 + T38UdptlNat NullAstBoolValues + T38UdptlIpv6 NullAstBoolValues + ToneZone pgtype.Text + Language pgtype.Text + OneTouchRecording NullAstBoolValues + RecordOnFeature pgtype.Text + RecordOffFeature pgtype.Text + RtpEngine pgtype.Text + AllowTransfer NullAstBoolValues + AllowSubscribe NullAstBoolValues + SdpOwner pgtype.Text + SdpSession pgtype.Text + TosAudio pgtype.Text + TosVideo pgtype.Text + SubMinExpiry pgtype.Int4 + FromDomain pgtype.Text + FromUser pgtype.Text + MwiFromUser pgtype.Text + DtlsVerify pgtype.Text + DtlsRekey pgtype.Text + DtlsCertFile pgtype.Text + DtlsPrivateKey pgtype.Text + DtlsCipher pgtype.Text + DtlsCaFile pgtype.Text + DtlsCaPath pgtype.Text + DtlsSetup NullPjsipDtlsSetupValues + SrtpTag32 NullAstBoolValues + MediaAddress pgtype.Text + RedirectMethod NullPjsipRedirectMethodValues + SetVar pgtype.Text + CosAudio pgtype.Int4 + CosVideo pgtype.Int4 + MessageContext pgtype.Text + ForceAvp NullAstBoolValues + MediaUseReceivedTransport NullAstBoolValues + Accountcode pgtype.Text + UserEqPhone NullAstBoolValues + MohPassthrough NullAstBoolValues + MediaEncryptionOptimistic NullAstBoolValues + RpidImmediate NullAstBoolValues + G726NonStandard NullAstBoolValues + RtpKeepalive pgtype.Int4 + RtpTimeout pgtype.Int4 + RtpTimeoutHold pgtype.Int4 + BindRtpToMediaAddress NullAstBoolValues + VoicemailExtension pgtype.Text + MwiSubscribeReplacesUnsolicited NullAstBoolValues + Deny pgtype.Text + Permit pgtype.Text + Acl pgtype.Text + ContactDeny pgtype.Text + ContactPermit pgtype.Text + ContactAcl pgtype.Text + SubscribeContext pgtype.Text + FaxDetectTimeout pgtype.Int4 + ContactUser pgtype.Text + PreferredCodecOnly NullAstBoolValues + AsymmetricRtpCodec NullAstBoolValues + RtcpMux NullAstBoolValues + AllowOverlap NullAstBoolValues + ReferBlindProgress NullAstBoolValues + NotifyEarlyInuseRinging NullAstBoolValues + MaxAudioStreams pgtype.Int4 + MaxVideoStreams pgtype.Int4 + Webrtc NullAstBoolValues + DtlsFingerprint NullShaHashValues + IncomingMwiMailbox pgtype.Text + Bundle NullAstBoolValues + DtlsAutoGenerateCert NullAstBoolValues + FollowEarlyMediaFork NullAstBoolValues + AcceptMultipleSdpAnswers NullAstBoolValues + SuppressQ850ReasonHeaders NullAstBoolValues + TrustConnectedLine NullAstBoolValues + SendConnectedLine NullAstBoolValues + Ignore183WithoutSdp NullAstBoolValues + CodecPrefsIncomingOffer pgtype.Text + CodecPrefsOutgoingOffer pgtype.Text + CodecPrefsIncomingAnswer pgtype.Text + CodecPrefsOutgoingAnswer pgtype.Text + StirShaken NullAstBoolValues + SendHistoryInfo NullAstBoolValues + AllowUnauthenticatedOptions NullAstBoolValues + T38BindUdptlToMediaAddress NullAstBoolValues + GeolocIncomingCallProfile pgtype.Text + GeolocOutgoingCallProfile pgtype.Text + IncomingCallOfferPref NullPjsipIncomingCallOfferPrefValues + OutgoingCallOfferPref NullPjsipOutgoingCallOfferPrefValues + StirShakenProfile pgtype.Text + SecurityNegotiation NullSecurityNegotiationValues + SecurityMechanisms pgtype.Text + SendAoc NullAstBoolValues + OverlapContext pgtype.Text +} + +type PsEndpointIDIp struct { + ID string + Endpoint pgtype.Text + Match pgtype.Text + SrvLookups NullAstBoolValues + MatchHeader pgtype.Text + MatchRequestUri pgtype.Text +} + +type PsGlobal struct { + ID string + MaxForwards pgtype.Int4 + UserAgent pgtype.Text + DefaultOutboundEndpoint pgtype.Text + Debug pgtype.Text + EndpointIdentifierOrder pgtype.Text + MaxInitialQualifyTime pgtype.Int4 + DefaultFromUser pgtype.Text + KeepAliveInterval pgtype.Int4 + Regcontext pgtype.Text + ContactExpirationCheckInterval pgtype.Int4 + DefaultVoicemailExtension pgtype.Text + DisableMultiDomain NullAstBoolValues + UnidentifiedRequestCount pgtype.Int4 + UnidentifiedRequestPeriod pgtype.Int4 + UnidentifiedRequestPruneInterval pgtype.Int4 + DefaultRealm pgtype.Text + MwiTpsQueueHigh pgtype.Int4 + MwiTpsQueueLow pgtype.Int4 + MwiDisableInitialUnsolicited NullAstBoolValues + IgnoreUriUserOptions NullAstBoolValues + UseCalleridContact NullAstBoolValues + SendContactStatusOnUpdateRegistration NullAstBoolValues + TaskprocessorOverloadTrigger NullPjsipTaskprocessorOverloadTriggerValues + Norefersub NullAstBoolValues + AllowSending180After183 NullAstBoolValues + AllCodecsOnEmptyReinvite NullAstBoolValues +} + +type PsInboundPublication struct { + ID string + Endpoint pgtype.Text + EventAsteriskDevicestate pgtype.Text + EventAsteriskMwi pgtype.Text +} + +type PsOutboundPublish struct { + ID string + Expiration pgtype.Int4 + OutboundAuth pgtype.Text + OutboundProxy pgtype.Text + ServerUri pgtype.Text + FromUri pgtype.Text + ToUri pgtype.Text + Event pgtype.Text + MaxAuthAttempts pgtype.Int4 + Transport pgtype.Text + MultiUser NullAstBoolValues + Body pgtype.Text + Context pgtype.Text + Exten pgtype.Text +} + +type PsRegistration struct { + ID string + AuthRejectionPermanent NullAstBoolValues + ClientUri pgtype.Text + ContactUser pgtype.Text + Expiration pgtype.Int4 + MaxRetries pgtype.Int4 + OutboundAuth pgtype.Text + OutboundProxy pgtype.Text + RetryInterval pgtype.Int4 + ForbiddenRetryInterval pgtype.Int4 + ServerUri pgtype.Text + Transport pgtype.Text + SupportPath NullAstBoolValues + FatalRetryInterval pgtype.Int4 + Line NullAstBoolValues + Endpoint pgtype.Text + SupportOutbound NullAstBoolValues + ContactHeaderParams pgtype.Text + MaxRandomInitialDelay pgtype.Int4 + SecurityNegotiation NullSecurityNegotiationValues + SecurityMechanisms pgtype.Text + UserAgent pgtype.Text +} + +type PsResourceList struct { + ID string + ListItem pgtype.Text + Event pgtype.Text + FullState NullAstBoolValues + NotificationBatchInterval pgtype.Int4 + ResourceDisplayName NullAstBoolValues +} + +type PsSubscriptionPersistence struct { + ID string + Packet pgtype.Text + SrcName pgtype.Text + SrcPort pgtype.Int4 + TransportKey pgtype.Text + LocalName pgtype.Text + LocalPort pgtype.Int4 + Cseq pgtype.Int4 + Tag pgtype.Text + Endpoint pgtype.Text + Expires pgtype.Int4 + ContactUri pgtype.Text + PruneOnBoot NullAstBoolValues +} + +type PsSystem struct { + ID string + TimerT1 pgtype.Int4 + TimerB pgtype.Int4 + CompactHeaders NullAstBoolValues + ThreadpoolInitialSize pgtype.Int4 + ThreadpoolAutoIncrement pgtype.Int4 + ThreadpoolIdleTimeout pgtype.Int4 + ThreadpoolMaxSize pgtype.Int4 + DisableTcpSwitch NullAstBoolValues + FollowEarlyMediaFork NullAstBoolValues + AcceptMultipleSdpAnswers NullAstBoolValues + DisableRport NullAstBoolValues +} + +type PsTransport struct { + ID string + AsyncOperations pgtype.Int4 + Bind pgtype.Text + CaListFile pgtype.Text + CertFile pgtype.Text + Cipher pgtype.Text + Domain pgtype.Text + ExternalMediaAddress pgtype.Text + ExternalSignalingAddress pgtype.Text + ExternalSignalingPort pgtype.Int4 + Method NullPjsipTransportMethodValuesV2 + LocalNet pgtype.Text + Password pgtype.Text + PrivKeyFile pgtype.Text + Protocol NullPjsipTransportProtocolValuesV2 + RequireClientCert NullAstBoolValues + VerifyClient NullAstBoolValues + VerifyServer NullAstBoolValues + Tos pgtype.Text + Cos pgtype.Int4 + AllowReload NullAstBoolValues + SymmetricTransport NullAstBoolValues + AllowWildcardCerts NullAstBoolValues + TcpKeepaliveEnable pgtype.Bool + TcpKeepaliveIdleTime pgtype.Int4 + TcpKeepaliveIntervalTime pgtype.Int4 + TcpKeepaliveProbeCount pgtype.Int4 +} + +type Queue struct { + Name string + Musiconhold pgtype.Text + Announce pgtype.Text + Context pgtype.Text + Timeout pgtype.Int4 + Ringinuse NullYesnoValues + Setinterfacevar NullYesnoValues + Setqueuevar NullYesnoValues + Setqueueentryvar NullYesnoValues + MonitorFormat pgtype.Text + Membermacro pgtype.Text + Membergosub pgtype.Text + QueueYouarenext pgtype.Text + QueueThereare pgtype.Text + QueueCallswaiting pgtype.Text + QueueQuantity1 pgtype.Text + QueueQuantity2 pgtype.Text + QueueHoldtime pgtype.Text + QueueMinutes pgtype.Text + QueueMinute pgtype.Text + QueueSeconds pgtype.Text + QueueThankyou pgtype.Text + QueueCallerannounce pgtype.Text + QueueReporthold pgtype.Text + AnnounceFrequency pgtype.Int4 + AnnounceToFirstUser NullYesnoValues + MinAnnounceFrequency pgtype.Int4 + AnnounceRoundSeconds pgtype.Int4 + AnnounceHoldtime pgtype.Text + AnnouncePosition pgtype.Text + AnnouncePositionLimit pgtype.Int4 + PeriodicAnnounce pgtype.Text + PeriodicAnnounceFrequency pgtype.Int4 + RelativePeriodicAnnounce NullYesnoValues + RandomPeriodicAnnounce NullYesnoValues + Retry pgtype.Int4 + Wrapuptime pgtype.Int4 + Penaltymemberslimit pgtype.Int4 + Autofill NullYesnoValues + MonitorType pgtype.Text + Autopause NullQueueAutopauseValues + Autopausedelay pgtype.Int4 + Autopausebusy NullYesnoValues + Autopauseunavail NullYesnoValues + Maxlen pgtype.Int4 + Servicelevel pgtype.Int4 + Strategy NullQueueStrategyValues + Joinempty pgtype.Text + Leavewhenempty pgtype.Text + Reportholdtime NullYesnoValues + Memberdelay pgtype.Int4 + Weight pgtype.Int4 + Timeoutrestart NullYesnoValues + Defaultrule pgtype.Text + Timeoutpriority pgtype.Text +} + +type QueueMember struct { + QueueName string + Interface string + Membername pgtype.Text + StateInterface pgtype.Text + Penalty pgtype.Int4 + Paused pgtype.Int4 + Uniqueid int32 + Wrapuptime pgtype.Int4 + Ringinuse NullAstBoolValues + ReasonPaused pgtype.Text +} + +type QueueRule struct { + RuleName string + Time string + MinPenalty string + MaxPenalty string +} + +type Sippeer struct { + ID int32 + Name string + Ipaddr pgtype.Text + Port pgtype.Int4 + Regseconds pgtype.Int4 + Defaultuser pgtype.Text + Fullcontact pgtype.Text + Regserver pgtype.Text + Useragent pgtype.Text + Lastms pgtype.Int4 + Host pgtype.Text + Type NullTypeValues + Context pgtype.Text + Permit pgtype.Text + Deny pgtype.Text + Secret pgtype.Text + Md5secret pgtype.Text + Remotesecret pgtype.Text + Transport NullSipTransportValues + Dtmfmode NullSipDtmfmodeValues + Directmedia NullSipDirectmediaValuesV2 + Nat pgtype.Text + Callgroup pgtype.Text + Pickupgroup pgtype.Text + Language pgtype.Text + Disallow pgtype.Text + Allow pgtype.Text + Insecure pgtype.Text + Trustrpid NullYesNoValues + Progressinband NullSipProgressinbandValues + Promiscredir NullYesNoValues + Useclientcode NullYesNoValues + Accountcode pgtype.Text + Setvar pgtype.Text + Callerid pgtype.Text + Amaflags pgtype.Text + Callcounter NullYesNoValues + Busylevel pgtype.Int4 + Allowoverlap NullYesNoValues + Allowsubscribe NullYesNoValues + Videosupport NullYesNoValues + Maxcallbitrate pgtype.Int4 + Rfc2833compensate NullYesNoValues + Mailbox pgtype.Text + SessionTimers NullSipSessionTimersValues + SessionExpires pgtype.Int4 + SessionMinse pgtype.Int4 + SessionRefresher NullSipSessionRefresherValues + T38ptUsertpsource pgtype.Text + Regexten pgtype.Text + Fromdomain pgtype.Text + Fromuser pgtype.Text + Qualify pgtype.Text + Defaultip pgtype.Text + Rtptimeout pgtype.Int4 + Rtpholdtimeout pgtype.Int4 + Sendrpid NullYesNoValues + Outboundproxy pgtype.Text + Callbackextension pgtype.Text + Timert1 pgtype.Int4 + Timerb pgtype.Int4 + Qualifyfreq pgtype.Int4 + Constantssrc NullYesNoValues + Contactpermit pgtype.Text + Contactdeny pgtype.Text + Usereqphone NullYesNoValues + Textsupport NullYesNoValues + Faxdetect NullYesNoValues + Buggymwi NullYesNoValues + Auth pgtype.Text + Fullname pgtype.Text + Trunkname pgtype.Text + CidNumber pgtype.Text + Callingpres NullSipCallingpresValues + Mohinterpret pgtype.Text + Mohsuggest pgtype.Text + Parkinglot pgtype.Text + Hasvoicemail NullYesNoValues + Subscribemwi NullYesNoValues + Vmexten pgtype.Text + Autoframing NullYesNoValues + Rtpkeepalive pgtype.Int4 + CallLimit pgtype.Int4 + G726nonstandard NullYesNoValues + Ignoresdpversion NullYesNoValues + Allowtransfer NullYesNoValues + Dynamic NullYesNoValues + Path pgtype.Text + Supportpath NullYesNoValues +} + +type StirTn struct { + ID string + PrivateKeyFile pgtype.Text + PublicCertUrl pgtype.Text + AttestLevel pgtype.Text + SendMky NullAstBoolValues +} + +type Voicemail struct { + Uniqueid int32 + Context string + Mailbox string + Password string + Fullname pgtype.Text + Alias pgtype.Text + Email pgtype.Text + Pager pgtype.Text + Attach NullYesNoValues + Attachfmt pgtype.Text + Serveremail pgtype.Text + Language pgtype.Text + Tz pgtype.Text + Deletevoicemail NullYesNoValues + Saycid NullYesNoValues + Sendvoicemail NullYesNoValues + Review NullYesNoValues + Tempgreetwarn NullYesNoValues + Operator NullYesNoValues + Envelope NullYesNoValues + Sayduration pgtype.Int4 + Forcename NullYesNoValues + Forcegreetings NullYesNoValues + Callback pgtype.Text + Dialout pgtype.Text + Exitcontext pgtype.Text + Maxmsg pgtype.Int4 + Volgain pgtype.Numeric + Imapuser pgtype.Text + Imappassword pgtype.Text + Imapserver pgtype.Text + Imapport pgtype.Text + Imapflags pgtype.Text + Stamp pgtype.Timestamp +} diff --git a/internal/sqlc/queries.sql.go b/internal/sqlc/queries.sql.go new file mode 100644 index 0000000..ac161a8 --- /dev/null +++ b/internal/sqlc/queries.sql.go @@ -0,0 +1,77 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.26.0 +// source: queries.sql + +package sqlc + +import ( + "context" + + "github.com/jackc/pgx/v5/pgtype" +) + +const newAOR = `-- name: NewAOR :exec +INSERT INTO ps_aors + (id, max_contacts) +VALUES + ($1, $2) +` + +type NewAORParams struct { + ID string + MaxContacts pgtype.Int4 +} + +func (q *Queries) NewAOR(ctx context.Context, arg NewAORParams) error { + _, err := q.db.Exec(ctx, newAOR, arg.ID, arg.MaxContacts) + return err +} + +const newEndpoint = `-- name: NewEndpoint :exec +INSERT INTO ps_endpoints + (id, transport, aors, auth, context, disallow, allow) +VALUES + ($1, $2, $1, $1, $3, 'all', $4) +` + +type NewEndpointParams struct { + ID string + Transport pgtype.Text + Context pgtype.Text + Allow pgtype.Text +} + +func (q *Queries) NewEndpoint(ctx context.Context, arg NewEndpointParams) error { + _, err := q.db.Exec(ctx, newEndpoint, + arg.ID, + arg.Transport, + arg.Context, + arg.Allow, + ) + return err +} + +const newMD5Auth = `-- name: NewMD5Auth :exec +INSERT INTO ps_auths + (id, auth_type, username, realm, md5_cred) +VALUES + ($1, 'md5', $2, $3, $4) +` + +type NewMD5AuthParams struct { + ID string + Username pgtype.Text + Realm pgtype.Text + Md5Cred pgtype.Text +} + +func (q *Queries) NewMD5Auth(ctx context.Context, arg NewMD5AuthParams) error { + _, err := q.db.Exec(ctx, newMD5Auth, + arg.ID, + arg.Username, + arg.Realm, + arg.Md5Cred, + ) + return err +} diff --git a/queries.sql b/queries.sql new file mode 100644 index 0000000..2c13bff --- /dev/null +++ b/queries.sql @@ -0,0 +1,17 @@ +-- name: NewMD5Auth :exec +INSERT INTO ps_auths + (id, auth_type, username, realm, md5_cred) +VALUES + ($1, 'md5', $2, $3, $4); + +-- name: NewAOR :exec +INSERT INTO ps_aors + (id, max_contacts) +VALUES + ($1, $2); + +-- name: NewEndpoint :exec +INSERT INTO ps_endpoints + (id, transport, aors, auth, context, disallow, allow) +VALUES + ($1, $2, $1, $1, $3, 'all', $4); diff --git a/schema.sql b/schema.sql new file mode 100644 index 0000000..d43c91a --- /dev/null +++ b/schema.sql @@ -0,0 +1,1163 @@ +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +CREATE TYPE public.ast_bool_values AS ENUM ( + '0', + '1', + 'off', + 'on', + 'false', + 'true', + 'no', + 'yes' +); + +CREATE TYPE public.iax_encryption_values AS ENUM ( + 'yes', + 'no', + 'aes128' +); + +CREATE TYPE public.iax_requirecalltoken_values AS ENUM ( + 'yes', + 'no', + 'auto' +); + +CREATE TYPE public.iax_transfer_values AS ENUM ( + 'yes', + 'no', + 'mediaonly' +); + +CREATE TYPE public.moh_mode_values AS ENUM ( + 'custom', + 'files', + 'mp3nb', + 'quietmp3nb', + 'quietmp3', + 'playlist' +); + +CREATE TYPE public.pjsip_100rel_values_v2 AS ENUM ( + 'no', + 'required', + 'peer_supported', + 'yes' +); + +CREATE TYPE public.pjsip_auth_type_values_v2 AS ENUM ( + 'md5', + 'userpass', + 'google_oauth' +); + +CREATE TYPE public.pjsip_cid_privacy_values AS ENUM ( + 'allowed_not_screened', + 'allowed_passed_screened', + 'allowed_failed_screened', + 'allowed', + 'prohib_not_screened', + 'prohib_passed_screened', + 'prohib_failed_screened', + 'prohib', + 'unavailable' +); + +CREATE TYPE public.pjsip_connected_line_method_values AS ENUM ( + 'invite', + 'reinvite', + 'update' +); + +CREATE TYPE public.pjsip_direct_media_glare_mitigation_values AS ENUM ( + 'none', + 'outgoing', + 'incoming' +); + +CREATE TYPE public.pjsip_dtls_setup_values AS ENUM ( + 'active', + 'passive', + 'actpass' +); + +CREATE TYPE public.pjsip_dtmf_mode_values_v3 AS ENUM ( + 'rfc4733', + 'inband', + 'info', + 'auto', + 'auto_info' +); + +CREATE TYPE public.pjsip_incoming_call_offer_pref_values AS ENUM ( + 'local', + 'local_first', + 'remote', + 'remote_first' +); + +CREATE TYPE public.pjsip_media_encryption_values AS ENUM ( + 'no', + 'sdes', + 'dtls' +); + +CREATE TYPE public.pjsip_outgoing_call_offer_pref_values AS ENUM ( + 'local', + 'local_merge', + 'local_first', + 'remote', + 'remote_merge', + 'remote_first' +); + +CREATE TYPE public.pjsip_redirect_method_values AS ENUM ( + 'user', + 'uri_core', + 'uri_pjsip' +); + +CREATE TYPE public.pjsip_t38udptl_ec_values AS ENUM ( + 'none', + 'fec', + 'redundancy' +); + +CREATE TYPE public.pjsip_taskprocessor_overload_trigger_values AS ENUM ( + 'none', + 'global', + 'pjsip_only' +); + +CREATE TYPE public.pjsip_timer_values AS ENUM ( + 'forced', + 'no', + 'required', + 'yes' +); + +CREATE TYPE public.pjsip_transport_method_values_v2 AS ENUM ( + 'default', + 'unspecified', + 'tlsv1', + 'tlsv1_1', + 'tlsv1_2', + 'tlsv1_3', + 'sslv2', + 'sslv23', + 'sslv3' +); + +CREATE TYPE public.pjsip_transport_protocol_values_v2 AS ENUM ( + 'udp', + 'tcp', + 'tls', + 'ws', + 'wss', + 'flow' +); + +CREATE TYPE public.queue_autopause_values AS ENUM ( + 'yes', + 'no', + 'all' +); + +CREATE TYPE public.queue_strategy_values AS ENUM ( + 'ringall', + 'leastrecent', + 'fewestcalls', + 'random', + 'rrmemory', + 'linear', + 'wrandom', + 'rrordered' +); + +CREATE TYPE public.security_negotiation_values AS ENUM ( + 'no', + 'mediasec' +); + +CREATE TYPE public.sha_hash_values AS ENUM ( + 'SHA-1', + 'SHA-256' +); + +CREATE TYPE public.sip_callingpres_values AS ENUM ( + 'allowed_not_screened', + 'allowed_passed_screen', + 'allowed_failed_screen', + 'allowed', + 'prohib_not_screened', + 'prohib_passed_screen', + 'prohib_failed_screen', + 'prohib' +); + +CREATE TYPE public.sip_directmedia_values_v2 AS ENUM ( + 'yes', + 'no', + 'nonat', + 'update', + 'outgoing' +); + +CREATE TYPE public.sip_dtmfmode_values AS ENUM ( + 'rfc2833', + 'info', + 'shortinfo', + 'inband', + 'auto' +); + +CREATE TYPE public.sip_progressinband_values AS ENUM ( + 'yes', + 'no', + 'never' +); + +CREATE TYPE public.sip_session_refresher_values AS ENUM ( + 'uac', + 'uas' +); + +CREATE TYPE public.sip_session_timers_values AS ENUM ( + 'accept', + 'refuse', + 'originate' +); + +CREATE TYPE public.sip_transport_values AS ENUM ( + 'udp', + 'tcp', + 'tls', + 'ws', + 'wss', + 'udp,tcp', + 'tcp,udp' +); + +CREATE TYPE public.type_values AS ENUM ( + 'friend', + 'user', + 'peer' +); + +CREATE TYPE public.yes_no_values AS ENUM ( + 'yes', + 'no' +); + +CREATE TYPE public.yesno_values AS ENUM ( + 'yes', + 'no' +); + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +CREATE TABLE public.alembic_version ( + version_num character varying(32) NOT NULL +); + +CREATE TABLE public.extensions ( + id bigint NOT NULL, + context character varying(40) NOT NULL, + exten character varying(40) NOT NULL, + priority integer NOT NULL, + app character varying(40) NOT NULL, + appdata character varying(256) NOT NULL +); + +CREATE SEQUENCE public.extensions_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE public.extensions_id_seq OWNED BY public.extensions.id; + +CREATE TABLE public.iaxfriends ( + id integer NOT NULL, + name character varying(40) NOT NULL, + type public.type_values, + username character varying(40), + mailbox character varying(40), + secret character varying(40), + dbsecret character varying(40), + context character varying(40), + regcontext character varying(40), + host character varying(40), + ipaddr character varying(40), + port integer, + defaultip character varying(20), + sourceaddress character varying(20), + mask character varying(20), + regexten character varying(40), + regseconds integer, + accountcode character varying(80), + mohinterpret character varying(20), + mohsuggest character varying(20), + inkeys character varying(40), + outkeys character varying(40), + language character varying(10), + callerid character varying(100), + cid_number character varying(40), + sendani public.yes_no_values, + fullname character varying(40), + trunk public.yes_no_values, + auth character varying(20), + maxauthreq integer, + requirecalltoken public.iax_requirecalltoken_values, + encryption public.iax_encryption_values, + transfer public.iax_transfer_values, + jitterbuffer public.yes_no_values, + forcejitterbuffer public.yes_no_values, + disallow character varying(200), + allow character varying(200), + codecpriority character varying(40), + qualify character varying(10), + qualifysmoothing public.yes_no_values, + qualifyfreqok character varying(10), + qualifyfreqnotok character varying(10), + timezone character varying(20), + adsi public.yes_no_values, + amaflags character varying(20), + setvar character varying(200) +); + +CREATE SEQUENCE public.iaxfriends_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE public.iaxfriends_id_seq OWNED BY public.iaxfriends.id; + +CREATE TABLE public.meetme ( + bookid integer NOT NULL, + confno character varying(80) NOT NULL, + starttime timestamp without time zone, + endtime timestamp without time zone, + pin character varying(20), + adminpin character varying(20), + opts character varying(20), + adminopts character varying(20), + recordingfilename character varying(80), + recordingformat character varying(10), + maxusers integer, + members integer NOT NULL +); + +CREATE SEQUENCE public.meetme_bookid_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE public.meetme_bookid_seq OWNED BY public.meetme.bookid; + +CREATE TABLE public.musiconhold ( + name character varying(80) NOT NULL, + mode public.moh_mode_values, + directory character varying(255), + application character varying(255), + digit character varying(1), + sort character varying(10), + format character varying(10), + stamp timestamp without time zone, + loop_last public.yesno_values +); + +CREATE TABLE public.musiconhold_entry ( + name character varying(80) NOT NULL, + "position" integer NOT NULL, + entry character varying(1024) NOT NULL +); + +CREATE TABLE public.ps_aors ( + id character varying(255) NOT NULL, + contact character varying(255), + default_expiration integer, + mailboxes character varying(80), + max_contacts integer, + minimum_expiration integer, + remove_existing public.ast_bool_values, + qualify_frequency integer, + authenticate_qualify public.ast_bool_values, + maximum_expiration integer, + outbound_proxy character varying(255), + support_path public.ast_bool_values, + qualify_timeout double precision, + voicemail_extension character varying(40), + remove_unavailable public.ast_bool_values +); + +CREATE TABLE public.ps_asterisk_publications ( + id character varying(40) NOT NULL, + devicestate_publish character varying(40), + mailboxstate_publish character varying(40), + device_state public.ast_bool_values, + device_state_filter character varying(256), + mailbox_state public.ast_bool_values, + mailbox_state_filter character varying(256) +); + +CREATE TABLE public.ps_auths ( + id character varying(255) NOT NULL, + auth_type public.pjsip_auth_type_values_v2, + nonce_lifetime integer, + md5_cred character varying(40), + password character varying(80), + realm character varying(255), + username character varying(40), + refresh_token character varying(255), + oauth_clientid character varying(255), + oauth_secret character varying(255) +); + +CREATE TABLE public.ps_contacts ( + id character varying(255) NOT NULL, + uri character varying(511), + expiration_time bigint, + qualify_frequency integer, + outbound_proxy character varying(255), + path text, + user_agent character varying(255), + qualify_timeout double precision, + reg_server character varying(255), + authenticate_qualify public.ast_bool_values, + via_addr character varying(40), + via_port integer, + call_id character varying(255), + endpoint character varying(255), + prune_on_boot public.ast_bool_values +); + +CREATE TABLE public.ps_domain_aliases ( + id character varying(255) NOT NULL, + domain character varying(255) +); + +CREATE TABLE public.ps_endpoint_id_ips ( + id character varying(255) NOT NULL, + endpoint character varying(255), + match character varying(80), + srv_lookups public.ast_bool_values, + match_header character varying(255), + match_request_uri character varying(255) +); + +CREATE TABLE public.ps_endpoints ( + id character varying(255) NOT NULL, + transport character varying(40), + aors character varying(2048), + auth character varying(255), + context character varying(40), + disallow character varying(200), + allow character varying(200), + direct_media public.ast_bool_values, + connected_line_method public.pjsip_connected_line_method_values, + direct_media_method public.pjsip_connected_line_method_values, + direct_media_glare_mitigation public.pjsip_direct_media_glare_mitigation_values, + disable_direct_media_on_nat public.ast_bool_values, + dtmf_mode public.pjsip_dtmf_mode_values_v3, + external_media_address character varying(40), + force_rport public.ast_bool_values, + ice_support public.ast_bool_values, + identify_by character varying(80), + mailboxes character varying(40), + moh_suggest character varying(40), + outbound_auth character varying(255), + outbound_proxy character varying(255), + rewrite_contact public.ast_bool_values, + rtp_ipv6 public.ast_bool_values, + rtp_symmetric public.ast_bool_values, + send_diversion public.ast_bool_values, + send_pai public.ast_bool_values, + send_rpid public.ast_bool_values, + timers_min_se integer, + timers public.pjsip_timer_values, + timers_sess_expires integer, + callerid character varying(40), + callerid_privacy public.pjsip_cid_privacy_values, + callerid_tag character varying(40), + "100rel" public.pjsip_100rel_values_v2, + aggregate_mwi public.ast_bool_values, + trust_id_inbound public.ast_bool_values, + trust_id_outbound public.ast_bool_values, + use_ptime public.ast_bool_values, + use_avpf public.ast_bool_values, + media_encryption public.pjsip_media_encryption_values, + inband_progress public.ast_bool_values, + call_group character varying(40), + pickup_group character varying(40), + named_call_group character varying(40), + named_pickup_group character varying(40), + device_state_busy_at integer, + fax_detect public.ast_bool_values, + t38_udptl public.ast_bool_values, + t38_udptl_ec public.pjsip_t38udptl_ec_values, + t38_udptl_maxdatagram integer, + t38_udptl_nat public.ast_bool_values, + t38_udptl_ipv6 public.ast_bool_values, + tone_zone character varying(40), + language character varying(40), + one_touch_recording public.ast_bool_values, + record_on_feature character varying(40), + record_off_feature character varying(40), + rtp_engine character varying(40), + allow_transfer public.ast_bool_values, + allow_subscribe public.ast_bool_values, + sdp_owner character varying(40), + sdp_session character varying(40), + tos_audio character varying(10), + tos_video character varying(10), + sub_min_expiry integer, + from_domain character varying(40), + from_user character varying(40), + mwi_from_user character varying(40), + dtls_verify character varying(40), + dtls_rekey character varying(40), + dtls_cert_file character varying(200), + dtls_private_key character varying(200), + dtls_cipher character varying(200), + dtls_ca_file character varying(200), + dtls_ca_path character varying(200), + dtls_setup public.pjsip_dtls_setup_values, + srtp_tag_32 public.ast_bool_values, + media_address character varying(40), + redirect_method public.pjsip_redirect_method_values, + set_var text, + cos_audio integer, + cos_video integer, + message_context character varying(40), + force_avp public.ast_bool_values, + media_use_received_transport public.ast_bool_values, + accountcode character varying(80), + user_eq_phone public.ast_bool_values, + moh_passthrough public.ast_bool_values, + media_encryption_optimistic public.ast_bool_values, + rpid_immediate public.ast_bool_values, + g726_non_standard public.ast_bool_values, + rtp_keepalive integer, + rtp_timeout integer, + rtp_timeout_hold integer, + bind_rtp_to_media_address public.ast_bool_values, + voicemail_extension character varying(40), + mwi_subscribe_replaces_unsolicited public.ast_bool_values, + deny character varying(95), + permit character varying(95), + acl character varying(40), + contact_deny character varying(95), + contact_permit character varying(95), + contact_acl character varying(40), + subscribe_context character varying(40), + fax_detect_timeout integer, + contact_user character varying(80), + preferred_codec_only public.ast_bool_values, + asymmetric_rtp_codec public.ast_bool_values, + rtcp_mux public.ast_bool_values, + allow_overlap public.ast_bool_values, + refer_blind_progress public.ast_bool_values, + notify_early_inuse_ringing public.ast_bool_values, + max_audio_streams integer, + max_video_streams integer, + webrtc public.ast_bool_values, + dtls_fingerprint public.sha_hash_values, + incoming_mwi_mailbox character varying(40), + bundle public.ast_bool_values, + dtls_auto_generate_cert public.ast_bool_values, + follow_early_media_fork public.ast_bool_values, + accept_multiple_sdp_answers public.ast_bool_values, + suppress_q850_reason_headers public.ast_bool_values, + trust_connected_line public.ast_bool_values, + send_connected_line public.ast_bool_values, + ignore_183_without_sdp public.ast_bool_values, + codec_prefs_incoming_offer character varying(128), + codec_prefs_outgoing_offer character varying(128), + codec_prefs_incoming_answer character varying(128), + codec_prefs_outgoing_answer character varying(128), + stir_shaken public.ast_bool_values, + send_history_info public.ast_bool_values, + allow_unauthenticated_options public.ast_bool_values, + t38_bind_udptl_to_media_address public.ast_bool_values, + geoloc_incoming_call_profile character varying(80), + geoloc_outgoing_call_profile character varying(80), + incoming_call_offer_pref public.pjsip_incoming_call_offer_pref_values, + outgoing_call_offer_pref public.pjsip_outgoing_call_offer_pref_values, + stir_shaken_profile character varying(80), + security_negotiation public.security_negotiation_values, + security_mechanisms character varying(512), + send_aoc public.ast_bool_values, + overlap_context character varying(80) +); + +CREATE TABLE public.ps_globals ( + id character varying(40) NOT NULL, + max_forwards integer, + user_agent character varying(255), + default_outbound_endpoint character varying(40), + debug character varying(40), + endpoint_identifier_order character varying(40), + max_initial_qualify_time integer, + default_from_user character varying(80), + keep_alive_interval integer, + regcontext character varying(80), + contact_expiration_check_interval integer, + default_voicemail_extension character varying(40), + disable_multi_domain public.ast_bool_values, + unidentified_request_count integer, + unidentified_request_period integer, + unidentified_request_prune_interval integer, + default_realm character varying(40), + mwi_tps_queue_high integer, + mwi_tps_queue_low integer, + mwi_disable_initial_unsolicited public.ast_bool_values, + ignore_uri_user_options public.ast_bool_values, + use_callerid_contact public.ast_bool_values, + send_contact_status_on_update_registration public.ast_bool_values, + taskprocessor_overload_trigger public.pjsip_taskprocessor_overload_trigger_values, + norefersub public.ast_bool_values, + allow_sending_180_after_183 public.ast_bool_values, + all_codecs_on_empty_reinvite public.ast_bool_values +); + +CREATE TABLE public.ps_inbound_publications ( + id character varying(255) NOT NULL, + endpoint character varying(255), + "event_asterisk-devicestate" character varying(40), + "event_asterisk-mwi" character varying(40) +); + +CREATE TABLE public.ps_outbound_publishes ( + id character varying(255) NOT NULL, + expiration integer, + outbound_auth character varying(255), + outbound_proxy character varying(256), + server_uri character varying(256), + from_uri character varying(256), + to_uri character varying(256), + event character varying(40), + max_auth_attempts integer, + transport character varying(40), + multi_user public.ast_bool_values, + "@body" character varying(40), + "@context" character varying(256), + "@exten" character varying(256) +); + +CREATE TABLE public.ps_registrations ( + id character varying(255) NOT NULL, + auth_rejection_permanent public.ast_bool_values, + client_uri character varying(255), + contact_user character varying(40), + expiration integer, + max_retries integer, + outbound_auth character varying(255), + outbound_proxy character varying(255), + retry_interval integer, + forbidden_retry_interval integer, + server_uri character varying(255), + transport character varying(40), + support_path public.ast_bool_values, + fatal_retry_interval integer, + line public.ast_bool_values, + endpoint character varying(255), + support_outbound public.ast_bool_values, + contact_header_params character varying(255), + max_random_initial_delay integer, + security_negotiation public.security_negotiation_values, + security_mechanisms character varying(512), + user_agent character varying(255) +); + +CREATE TABLE public.ps_resource_list ( + id character varying(40) NOT NULL, + list_item character varying(2048), + event character varying(40), + full_state public.ast_bool_values, + notification_batch_interval integer, + resource_display_name public.ast_bool_values +); + +CREATE TABLE public.ps_subscription_persistence ( + id character varying(40) NOT NULL, + packet character varying(2048), + src_name character varying(128), + src_port integer, + transport_key character varying(64), + local_name character varying(128), + local_port integer, + cseq integer, + tag character varying(128), + endpoint character varying(40), + expires integer, + contact_uri character varying(256), + prune_on_boot public.ast_bool_values +); + +CREATE TABLE public.ps_systems ( + id character varying(40) NOT NULL, + timer_t1 integer, + timer_b integer, + compact_headers public.ast_bool_values, + threadpool_initial_size integer, + threadpool_auto_increment integer, + threadpool_idle_timeout integer, + threadpool_max_size integer, + disable_tcp_switch public.ast_bool_values, + follow_early_media_fork public.ast_bool_values, + accept_multiple_sdp_answers public.ast_bool_values, + disable_rport public.ast_bool_values +); + +CREATE TABLE public.ps_transports ( + id character varying(40) NOT NULL, + async_operations integer, + bind character varying(40), + ca_list_file character varying(200), + cert_file character varying(200), + cipher character varying(200), + domain character varying(40), + external_media_address character varying(40), + external_signaling_address character varying(40), + external_signaling_port integer, + method public.pjsip_transport_method_values_v2, + local_net character varying(40), + password character varying(40), + priv_key_file character varying(200), + protocol public.pjsip_transport_protocol_values_v2, + require_client_cert public.ast_bool_values, + verify_client public.ast_bool_values, + verify_server public.ast_bool_values, + tos character varying(10), + cos integer, + allow_reload public.ast_bool_values, + symmetric_transport public.ast_bool_values, + allow_wildcard_certs public.ast_bool_values, + tcp_keepalive_enable boolean, + tcp_keepalive_idle_time integer, + tcp_keepalive_interval_time integer, + tcp_keepalive_probe_count integer +); + +CREATE TABLE public.queue_members ( + queue_name character varying(80) NOT NULL, + interface character varying(80) NOT NULL, + membername character varying(80), + state_interface character varying(80), + penalty integer, + paused integer, + uniqueid integer NOT NULL, + wrapuptime integer, + ringinuse public.ast_bool_values, + reason_paused character varying(80) +); + +CREATE TABLE public.queue_rules ( + rule_name character varying(80) NOT NULL, + "time" character varying(32) NOT NULL, + min_penalty character varying(32) NOT NULL, + max_penalty character varying(32) NOT NULL +); + +CREATE TABLE public.queues ( + name character varying(128) NOT NULL, + musiconhold character varying(128), + announce character varying(128), + context character varying(128), + timeout integer, + ringinuse public.yesno_values, + setinterfacevar public.yesno_values, + setqueuevar public.yesno_values, + setqueueentryvar public.yesno_values, + monitor_format character varying(8), + membermacro character varying(512), + membergosub character varying(512), + queue_youarenext character varying(128), + queue_thereare character varying(128), + queue_callswaiting character varying(128), + queue_quantity1 character varying(128), + queue_quantity2 character varying(128), + queue_holdtime character varying(128), + queue_minutes character varying(128), + queue_minute character varying(128), + queue_seconds character varying(128), + queue_thankyou character varying(128), + queue_callerannounce character varying(128), + queue_reporthold character varying(128), + announce_frequency integer, + announce_to_first_user public.yesno_values, + min_announce_frequency integer, + announce_round_seconds integer, + announce_holdtime character varying(128), + announce_position character varying(128), + announce_position_limit integer, + periodic_announce character varying(50), + periodic_announce_frequency integer, + relative_periodic_announce public.yesno_values, + random_periodic_announce public.yesno_values, + retry integer, + wrapuptime integer, + penaltymemberslimit integer, + autofill public.yesno_values, + monitor_type character varying(128), + autopause public.queue_autopause_values, + autopausedelay integer, + autopausebusy public.yesno_values, + autopauseunavail public.yesno_values, + maxlen integer, + servicelevel integer, + strategy public.queue_strategy_values, + joinempty character varying(128), + leavewhenempty character varying(128), + reportholdtime public.yesno_values, + memberdelay integer, + weight integer, + timeoutrestart public.yesno_values, + defaultrule character varying(128), + timeoutpriority character varying(128) +); + +CREATE TABLE public.sippeers ( + id integer NOT NULL, + name character varying(40) NOT NULL, + ipaddr character varying(45), + port integer, + regseconds integer, + defaultuser character varying(40), + fullcontact character varying(80), + regserver character varying(20), + useragent character varying(255), + lastms integer, + host character varying(40), + type public.type_values, + context character varying(40), + permit character varying(95), + deny character varying(95), + secret character varying(40), + md5secret character varying(40), + remotesecret character varying(40), + transport public.sip_transport_values, + dtmfmode public.sip_dtmfmode_values, + directmedia public.sip_directmedia_values_v2, + nat character varying(29), + callgroup character varying(40), + pickupgroup character varying(40), + language character varying(40), + disallow character varying(200), + allow character varying(200), + insecure character varying(40), + trustrpid public.yes_no_values, + progressinband public.sip_progressinband_values, + promiscredir public.yes_no_values, + useclientcode public.yes_no_values, + accountcode character varying(80), + setvar character varying(200), + callerid character varying(40), + amaflags character varying(40), + callcounter public.yes_no_values, + busylevel integer, + allowoverlap public.yes_no_values, + allowsubscribe public.yes_no_values, + videosupport public.yes_no_values, + maxcallbitrate integer, + rfc2833compensate public.yes_no_values, + mailbox character varying(40), + "session-timers" public.sip_session_timers_values, + "session-expires" integer, + "session-minse" integer, + "session-refresher" public.sip_session_refresher_values, + t38pt_usertpsource character varying(40), + regexten character varying(40), + fromdomain character varying(40), + fromuser character varying(40), + qualify character varying(40), + defaultip character varying(45), + rtptimeout integer, + rtpholdtimeout integer, + sendrpid public.yes_no_values, + outboundproxy character varying(40), + callbackextension character varying(40), + timert1 integer, + timerb integer, + qualifyfreq integer, + constantssrc public.yes_no_values, + contactpermit character varying(95), + contactdeny character varying(95), + usereqphone public.yes_no_values, + textsupport public.yes_no_values, + faxdetect public.yes_no_values, + buggymwi public.yes_no_values, + auth character varying(40), + fullname character varying(40), + trunkname character varying(40), + cid_number character varying(40), + callingpres public.sip_callingpres_values, + mohinterpret character varying(40), + mohsuggest character varying(40), + parkinglot character varying(40), + hasvoicemail public.yes_no_values, + subscribemwi public.yes_no_values, + vmexten character varying(40), + autoframing public.yes_no_values, + rtpkeepalive integer, + "call-limit" integer, + g726nonstandard public.yes_no_values, + ignoresdpversion public.yes_no_values, + allowtransfer public.yes_no_values, + dynamic public.yes_no_values, + path character varying(256), + supportpath public.yes_no_values +); + +CREATE SEQUENCE public.sippeers_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE public.sippeers_id_seq OWNED BY public.sippeers.id; + +CREATE TABLE public.stir_tn ( + id character varying(80) NOT NULL, + private_key_file character varying(1024), + public_cert_url character varying(1024), + attest_level character varying(1), + send_mky public.ast_bool_values +); + +CREATE TABLE public.voicemail ( + uniqueid integer NOT NULL, + context character varying(80) NOT NULL, + mailbox character varying(80) NOT NULL, + password character varying(80) NOT NULL, + fullname character varying(80), + alias character varying(80), + email character varying(80), + pager character varying(80), + attach public.yes_no_values, + attachfmt character varying(10), + serveremail character varying(80), + language character varying(20), + tz character varying(30), + deletevoicemail public.yes_no_values, + saycid public.yes_no_values, + sendvoicemail public.yes_no_values, + review public.yes_no_values, + tempgreetwarn public.yes_no_values, + operator public.yes_no_values, + envelope public.yes_no_values, + sayduration integer, + forcename public.yes_no_values, + forcegreetings public.yes_no_values, + callback character varying(80), + dialout character varying(80), + exitcontext character varying(80), + maxmsg integer, + volgain numeric(5,2), + imapuser character varying(80), + imappassword character varying(80), + imapserver character varying(80), + imapport character varying(8), + imapflags character varying(80), + stamp timestamp without time zone +); + +CREATE SEQUENCE public.voicemail_uniqueid_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE public.voicemail_uniqueid_seq OWNED BY public.voicemail.uniqueid; + +ALTER TABLE ONLY public.extensions ALTER COLUMN id SET DEFAULT nextval('public.extensions_id_seq'::regclass); + +ALTER TABLE ONLY public.iaxfriends ALTER COLUMN id SET DEFAULT nextval('public.iaxfriends_id_seq'::regclass); + +ALTER TABLE ONLY public.meetme ALTER COLUMN bookid SET DEFAULT nextval('public.meetme_bookid_seq'::regclass); + +ALTER TABLE ONLY public.sippeers ALTER COLUMN id SET DEFAULT nextval('public.sippeers_id_seq'::regclass); + +ALTER TABLE ONLY public.voicemail ALTER COLUMN uniqueid SET DEFAULT nextval('public.voicemail_uniqueid_seq'::regclass); + +ALTER TABLE ONLY public.alembic_version + ADD CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num); + +ALTER TABLE ONLY public.extensions + ADD CONSTRAINT extensions_context_exten_priority_key UNIQUE (context, exten, priority); + +ALTER TABLE ONLY public.extensions + ADD CONSTRAINT extensions_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY public.iaxfriends + ADD CONSTRAINT iaxfriends_name_key UNIQUE (name); + +ALTER TABLE ONLY public.iaxfriends + ADD CONSTRAINT iaxfriends_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY public.meetme + ADD CONSTRAINT meetme_pkey PRIMARY KEY (bookid); + +ALTER TABLE ONLY public.musiconhold_entry + ADD CONSTRAINT musiconhold_entry_pkey PRIMARY KEY (name, "position"); + +ALTER TABLE ONLY public.musiconhold + ADD CONSTRAINT musiconhold_pkey PRIMARY KEY (name); + +ALTER TABLE ONLY public.ps_aors + ADD CONSTRAINT ps_aors_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_asterisk_publications + ADD CONSTRAINT ps_asterisk_publications_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_auths + ADD CONSTRAINT ps_auths_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_contacts + ADD CONSTRAINT ps_contacts_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_contacts + ADD CONSTRAINT ps_contacts_uq UNIQUE (id, reg_server); + +ALTER TABLE ONLY public.ps_domain_aliases + ADD CONSTRAINT ps_domain_aliases_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_endpoint_id_ips + ADD CONSTRAINT ps_endpoint_id_ips_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_endpoints + ADD CONSTRAINT ps_endpoints_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_globals + ADD CONSTRAINT ps_globals_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_inbound_publications + ADD CONSTRAINT ps_inbound_publications_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_outbound_publishes + ADD CONSTRAINT ps_outbound_publishes_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_registrations + ADD CONSTRAINT ps_registrations_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_resource_list + ADD CONSTRAINT ps_resource_list_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_subscription_persistence + ADD CONSTRAINT ps_subscription_persistence_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_systems + ADD CONSTRAINT ps_systems_id_key UNIQUE (id); + +ALTER TABLE ONLY public.ps_transports + ADD CONSTRAINT ps_transports_id_key UNIQUE (id); + +ALTER TABLE ONLY public.queue_members + ADD CONSTRAINT queue_members_pkey PRIMARY KEY (queue_name, interface); + +ALTER TABLE ONLY public.queue_members + ADD CONSTRAINT queue_members_uniqueid_key UNIQUE (uniqueid); + +ALTER TABLE ONLY public.queues + ADD CONSTRAINT queues_pkey PRIMARY KEY (name); + +ALTER TABLE ONLY public.sippeers + ADD CONSTRAINT sippeers_name_key UNIQUE (name); + +ALTER TABLE ONLY public.sippeers + ADD CONSTRAINT sippeers_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY public.stir_tn + ADD CONSTRAINT stir_tn_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY public.voicemail + ADD CONSTRAINT voicemail_pkey PRIMARY KEY (uniqueid); + +CREATE INDEX iaxfriends_host_port ON public.iaxfriends USING btree (host, port); + +CREATE INDEX iaxfriends_ipaddr_port ON public.iaxfriends USING btree (ipaddr, port); + +CREATE INDEX iaxfriends_name ON public.iaxfriends USING btree (name); + +CREATE INDEX iaxfriends_name_host ON public.iaxfriends USING btree (name, host); + +CREATE INDEX iaxfriends_name_ipaddr_port ON public.iaxfriends USING btree (name, ipaddr, port); + +CREATE INDEX meetme_confno_start_end ON public.meetme USING btree (confno, starttime, endtime); + +CREATE INDEX ps_aors_id ON public.ps_aors USING btree (id); + +CREATE INDEX ps_aors_qualifyfreq_contact ON public.ps_aors USING btree (qualify_frequency, contact); + +CREATE INDEX ps_asterisk_publications_id ON public.ps_asterisk_publications USING btree (id); + +CREATE INDEX ps_auths_id ON public.ps_auths USING btree (id); + +CREATE INDEX ps_contacts_id ON public.ps_contacts USING btree (id); + +CREATE INDEX ps_contacts_qualifyfreq_exp ON public.ps_contacts USING btree (qualify_frequency, expiration_time); + +CREATE INDEX ps_domain_aliases_id ON public.ps_domain_aliases USING btree (id); + +CREATE INDEX ps_endpoint_id_ips_id ON public.ps_endpoint_id_ips USING btree (id); + +CREATE INDEX ps_endpoints_id ON public.ps_endpoints USING btree (id); + +CREATE INDEX ps_globals_id ON public.ps_globals USING btree (id); + +CREATE INDEX ps_inbound_publications_id ON public.ps_inbound_publications USING btree (id); + +CREATE INDEX ps_outbound_publishes_id ON public.ps_outbound_publishes USING btree (id); + +CREATE INDEX ps_registrations_id ON public.ps_registrations USING btree (id); + +CREATE INDEX ps_resource_list_id ON public.ps_resource_list USING btree (id); + +CREATE INDEX ps_subscription_persistence_id ON public.ps_subscription_persistence USING btree (id); + +CREATE INDEX ps_systems_id ON public.ps_systems USING btree (id); + +CREATE INDEX ps_transports_id ON public.ps_transports USING btree (id); + +CREATE INDEX sippeers_host_port ON public.sippeers USING btree (host, port); + +CREATE INDEX sippeers_ipaddr_port ON public.sippeers USING btree (ipaddr, port); + +CREATE INDEX sippeers_name ON public.sippeers USING btree (name); + +CREATE INDEX sippeers_name_host ON public.sippeers USING btree (name, host); + +CREATE INDEX voicemail_context ON public.voicemail USING btree (context); + +CREATE INDEX voicemail_imapuser ON public.voicemail USING btree (imapuser); + +CREATE INDEX voicemail_mailbox ON public.voicemail USING btree (mailbox); + +CREATE INDEX voicemail_mailbox_context ON public.voicemail USING btree (mailbox, context); + +ALTER TABLE ONLY public.musiconhold_entry + ADD CONSTRAINT fk_musiconhold_entry_name_musiconhold FOREIGN KEY (name) REFERENCES public.musiconhold(name); + diff --git a/sqlc.yaml b/sqlc.yaml new file mode 100644 index 0000000..b8037e2 --- /dev/null +++ b/sqlc.yaml @@ -0,0 +1,10 @@ +version: 2 +sql: + - engine: postgresql + queries: queries.sql + schema: schema.sql + gen: + go: + package: sqlc + out: internal/sqlc + sql_package: pgx/v5