<commit_before>local typedefs = require "kong.db.schema.typedefs"
local Schema = require "kong.db.schema"
local url = require "socket.url"


local tostring = tostring
local tonumber = tonumber
local null = ngx.null


local nonzero_timeout = Schema.define {
  type = "integer",
  between = { 1, math.pow(2, 31) - 2 },
}


local default_protocol = "http"
local default_port = 80


return {
  name = "services",
  primary_key = { "id" },
  workspaceable = true,
  endpoint_key = "name",

  fields = {
    { id                 = typedefs.uuid, },
    { created_at         = typedefs.auto_timestamp_s },
    { updated_at         = typedefs.auto_timestamp_s },
    { name               = typedefs.utf8_name },
    { retries            = { type = "integer", default = 5, between = { 0, 32767 } }, },
    -- { tags             = { type = "array", array = { type = "string" } }, },
    { protocol           = typedefs.protocol { required = true, default = default_protocol } },
    { host               = typedefs.host { required = true } },
    { port               = typedefs.port { required = true, default = default_port }, },
    { path               = typedefs.path },
    { connect_timeout    = nonzero_timeout { default = 60000 }, },
    { write_timeout      = nonzero_timeout { default = 60000 }, },
    { read_timeout       = nonzero_timeout { default = 60000 }, },
    { tags               = typedefs.tags },
    { client_certificate = { type = "foreign", reference = "certificates" }, },
    { tls_verify         = { type = "boolean", }, },
    { tls_verify_depth   = { type = "integer", default = null, between = { 0, 64 }, }, },
    { ca_certificates    = { type = "array", elements = { type = "string", uuid = true, }, }, },
    -- { load_balancer = { type = "foreign", reference = "load_balancers" } },
  },

  entity_checks = {
    { conditional = { if_field = "protocol",<commit_msg>feat(services) add enabled to service schema<commit_after>local typedefs = require "kong.db.schema.typedefs"
local Schema = require "kong.db.schema"
local url = require "socket.url"


local tostring = tostring
local tonumber = tonumber
local null = ngx.null


local nonzero_timeout = Schema.define {
  type = "integer",
  between = { 1, math.pow(2, 31) - 2 },
}


local default_protocol = "http"
local default_port = 80


return {
  name = "services",
  primary_key = { "id" },
  workspaceable = true,
  endpoint_key = "name",

  fields = {
    { id                 = typedefs.uuid, },
    { created_at         = typedefs.auto_timestamp_s },
    { updated_at         = typedefs.auto_timestamp_s },
    { name               = typedefs.utf8_name },
    { retries            = { type = "integer", default = 5, between = { 0, 32767 } }, },
    -- { tags             = { type = "array", array = { type = "string" } }, },
    { protocol           = typedefs.protocol { required = true, default = default_protocol } },
    { host               = typedefs.host { required = true } },
    { port               = typedefs.port { required = true, default = default_port }, },
    { path               = typedefs.path },
    { connect_timeout    = nonzero_timeout { default = 60000 }, },
    { write_timeout      = nonzero_timeout { default = 60000 }, },
    { read_timeout       = nonzero_timeout { default = 60000 }, },
    { tags               = typedefs.tags },
    { client_certificate = { type = "foreign", reference = "certificates" }, },
    { tls_verify         = { type = "boolean", }, },
    { tls_verify_depth   = { type = "integer", default = null, between = { 0, 64 }, }, },
    { ca_certificates    = { type = "array", elements = { type = "string", uuid = true, }, }, },
    { enabled            = { type = "boolean", required = true, default = true, }, },
    -- { load_balancer = { type = "foreign", reference = "load_balancers" } },
  },

  entity_checks = {
    { conditional = { if_field = "protocol",
{'fraction_non_alphanumeric': 0.1443219687259677, 'fraction_numerical': 0.016918738784926942, 'mean_word_length': 2.2789915966386554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '112042', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1158, 'n_words': 279}