1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[google|sql] Add support for Flags

- Add models, requests and tests for Flags
This commit is contained in:
Ferran Rodenas 2014-07-29 19:46:17 -07:00
parent 5025c5b417
commit 716f474545
6 changed files with 232 additions and 0 deletions

View file

@ -0,0 +1,22 @@
require 'fog/core/model'
module Fog
module Google
class SQL
##
# A Google Cloud SQL service flag resource
#
# @see https://developers.google.com/cloud-sql/docs/admin-api/v1beta3/flags
class Flag < Fog::Model
identity :name
attribute :allowed_string_values, :aliases => 'allowedStringValues'
attribute :applies_to, :aliases => 'appliesTo'
attribute :kind
attribute :max_value, :aliases => 'maxValue'
attribute :min_value, :aliases => 'minValue'
attribute :type
end
end
end
end

View file

@ -0,0 +1,21 @@
require 'fog/core/collection'
require 'fog/google/models/sql/flag'
module Fog
module Google
class SQL
class Flags < Fog::Collection
model Fog::Google::SQL::Flag
##
# List all available database flags
#
# @return [Array<Fog::Google::SQL::Flag>] List of flags
def all
data = service.list_flags.body['items'] || []
load(data)
end
end
end
end
end

View file

@ -0,0 +1,143 @@
module Fog
module Google
class SQL
##
# List all available database flags for Google Cloud SQL instances
#
# @see https://developers.google.com/cloud-sql/docs/admin-api/v1beta3/flags/list
class Real
def list_flags
api_method = @sql.flags.list
parameters = {}
request(api_method, parameters)
end
end
class Mock
def list_flags
body = {
'kind' => 'sql#flagsList',
'items' => [
{
'kind' => 'sql#flag',
'name' => 'log_output',
'type' => 'STRING',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
'allowedStringValues' => ['TABLE', 'NONE'],
},
{
'kind' => 'sql#flag',
'name' => 'general_log',
'type' => 'BOOLEAN',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
},
{
'kind' => 'sql#flag',
'name' => 'log_queries_not_using_indexes',
'type' => 'BOOLEAN',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
},
{
'kind' => 'sql#flag',
'name' => 'log_bin_trust_function_creators',
'type' => 'BOOLEAN',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
},
{
'kind' => 'sql#flag',
'name' => 'slow_query_log',
'type' => 'BOOLEAN',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
},
{
'kind' => 'sql#flag',
'name' => 'read_only',
'type' => 'BOOLEAN',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
},
{
'kind' => 'sql#flag',
'name' => 'max_allowed_packet',
'type' => 'INTEGER',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
'minValue' => '16384',
'maxValue' => '1073741824',
},
{
'kind' => 'sql#flag',
'name' => 'long_query_time',
'type' => 'INTEGER',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
'minValue' => '0',
'maxValue' => '30000000',
},
{
'kind' => 'sql#flag',
'name' => 'group_concat_max_len',
'type' => 'INTEGER',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
'minValue' => '4',
'maxValue' => '17179869184',
},
{
'kind' => 'sql#flag',
'name' => 'wait_timeout',
'type' => 'INTEGER',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
'minValue' => '1',
'maxValue' => '31536000',
},
{
'kind' => 'sql#flag',
'name' => 'innodb_lock_wait_timeout',
'type' => 'INTEGER',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
'minValue' => '1',
'maxValue' => '1073741824',
},
{
'kind' => 'sql#flag',
'name' => 'lower_case_table_names',
'type' => 'INTEGER',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
'minValue' => '0',
'maxValue' => '2',
},
{
'kind' => 'sql#flag',
'name' => 'innodb_flush_log_at_trx_commit',
'type' => 'INTEGER',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
'minValue' => '0',
'maxValue' => '2',
},
{
'kind' => 'sql#flag',
'name' => 'skip_show_database',
'type' => 'NONE',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
},
{
'kind' => 'sql#flag',
'name' => 'event_scheduler',
'type' => 'BOOLEAN',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
},
{
'kind' => 'sql#flag',
'name' => 'character_set_server',
'type' => 'STRING',
'appliesTo' => ['MYSQL_5_5', 'MYSQL_5_6'],
'allowedStringValues' => ['utf8', 'utf8mb4'],
},
]
}
build_excon_response(body)
end
end
end
end
end

View file

@ -16,6 +16,10 @@ module Fog
# MODELS
model_path 'fog/google/models/sql'
# Flag
model :flag
collection :flags
# Tier
model :tier
collection :tiers
@ -24,6 +28,9 @@ module Fog
# REQUESTS
request_path 'fog/google/requests/sql'
# Flag
request :list_flags
# Tier
request :list_tiers

View file

@ -0,0 +1,12 @@
Shindo.tests('Fog::Google[:sql] | flags model', ['google']) do
@flags = Fog::Google[:sql].tiers
tests('success') do
tests('#all').succeeds do
@flags.all
end
end
end

View file

@ -0,0 +1,27 @@
Shindo.tests('Fog::Google[:sql] | flag requests', ['google']) do
@sql = Fog::Google[:sql]
@get_flag_format = {
'name' => String,
'allowedStringValues' => Fog::Nullable::Array,
'appliesTo' => Array,
'kind' => String,
'maxValue' => Fog::Nullable::String,
'minValue' => Fog::Nullable::String,
'type' => String,
}
@list_flags_format = {
'kind' => String,
'items' => [@get_flag_format],
}
tests('success') do
tests('#list_flags').formats(@list_flags_format) do
@sql.list_flags.body
end
end
end