<s> from boto . cloudsearch2 . optionstatus import IndexFieldStatus <EOL> from boto . cloudsearch2 . optionstatus import ServicePoliciesStatus <EOL> from boto . cloudsearch2 . optionstatus import ExpressionStatus <EOL> from boto . cloudsearch2 . optionstatus import AvailabilityOptionsStatus <EOL> from boto . cloudsearch2 . optionstatus import ScalingParametersStatus <EOL> from boto . cloudsearch2 . document import DocumentServiceConnection <EOL> from boto . cloudsearch2 . search import SearchConnection <EOL> def handle_bool ( value ) : <EOL> if value in [ True , '<STR_LIT:true>' , '<STR_LIT:True>' , '<STR_LIT>' , <NUM_LIT:1> ] : <EOL> return True <EOL> return False <EOL> class Domain ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , layer1 , data ) : <EOL> """<STR_LIT>""" <EOL> self . layer1 = layer1 <EOL> self . update_from_data ( data ) <EOL> def update_from_data ( self , data ) : <EOL> self . created = data [ '<STR_LIT>' ] <EOL> self . deleted = data [ '<STR_LIT>' ] <EOL> self . processing = data [ '<STR_LIT>' ] <EOL> self . requires_index_documents = data [ '<STR_LIT>' ] <EOL> self . domain_id = data [ '<STR_LIT>' ] <EOL> self . domain_name = data [ '<STR_LIT>' ] <EOL> self . search_instance_count = data [ '<STR_LIT>' ] <EOL> self . search_instance_type = data . get ( '<STR_LIT>' , None ) <EOL> self . search_partition_count = data [ '<STR_LIT>' ] <EOL> self . _doc_service = data [ '<STR_LIT>' ] <EOL> self . _service_arn = data [ '<STR_LIT>' ] <EOL> self . _search_service = data [ '<STR_LIT>' ] <EOL> @ property <EOL> def service_arn ( self ) : <EOL> return self . _service_arn <EOL> @ property <EOL> def doc_service_endpoint ( self ) : <EOL> return self . _doc_service [ '<STR_LIT>' ] <EOL> @ property <EOL> def search_service_endpoint ( self ) : <EOL> return self . _search_service [ '<STR_LIT>' ] <EOL> @ property <EOL> def created ( self ) : <EOL> return self . _created <EOL> @ created . setter <EOL> def created ( self , value ) : <EOL> self . _created = handle_bool ( value ) <EOL> @ property <EOL> def deleted ( self ) : <EOL> return self . _deleted <EOL> @ deleted . setter <EOL> def deleted ( self , value ) : <EOL> self . _deleted = handle_bool ( value ) <EOL> @ property <EOL> def processing ( self ) : <EOL> return self . _processing <EOL> @ processing . setter <EOL> def processing ( self , value ) : <EOL> self . _processing = handle_bool ( value ) <EOL> @ property <EOL> def requires_index_documents ( self ) : <EOL> return self . _requires_index_documents <EOL> @ requires_index_documents . setter <EOL> def requires_index_documents ( self , value ) : <EOL> self . _requires_index_documents = handle_bool ( value ) <EOL> @ property <EOL> def search_partition_count ( self ) : <EOL> return self . _search_partition_count <EOL> @ search_partition_count . setter <EOL> def search_partition_count ( self , value ) : <EOL> self . _search_partition_count = int ( value ) <EOL> @ property <EOL> def search_instance_count ( self ) : <EOL> return self . _search_instance_count <EOL> @ search_instance_count . setter <EOL> def search_instance_count ( self , value ) : <EOL> self . _search_instance_count = int ( value ) <EOL> @ property <EOL> def name ( self ) : <EOL> return self . domain_name <EOL> @ property <EOL> def id ( self ) : <EOL> return self . domain_id <EOL> def delete ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . layer1 . delete_domain ( self . name ) <EOL> def get_analysis_schemes ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . layer1 . describe_analysis_schemes ( self . name ) <EOL> def get_availability_options ( self ) : <EOL> """<STR_LIT>""" <EOL> return AvailabilityOptionsStatus ( <EOL> self , refresh_fn = self . layer1 . describe_availability_options , <EOL> refresh_key = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> save_fn = self . layer1 . update_availability_options ) <EOL> def get_scaling_options ( self ) : <EOL> """<STR_LIT>""" <EOL> return ScalingParametersStatus ( <EOL> self , refresh_fn = self . layer1 . describe_scaling_parameters , <EOL> refresh_key = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> save_fn = self . layer1 . update_scaling_parameters ) <EOL> def get_access_policies ( self ) : <EOL> """<STR_LIT>""" <EOL> return ServicePoliciesStatus ( <EOL> self , refresh_fn = self . layer1 . describe_service_access_policies , <EOL> refresh_key = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> save_fn = self . layer1 . update_service_access_policies ) <EOL> def index_documents ( self ) : <EOL> """<STR_LIT>""" <EOL> self . layer1 . index_documents ( self . name ) <EOL> def get_index_fields ( self , field_names = None ) : <EOL> """<STR_LIT>""" <EOL> data = self . layer1 . describe_index_fields ( self . name , field_names ) <EOL> data = ( data [ '<STR_LIT>' ] <EOL> [ '<STR_LIT>' ] <EOL> [ '<STR_LIT>' ] ) <EOL> return [ IndexFieldStatus ( self , d ) for d in data ] <EOL> def create_index_field ( self , field_name , field_type , <EOL> default = '<STR_LIT>' , facet = False , returnable = False , <EOL> searchable = False , sortable = False , <EOL> highlight = False , source_field = None , <EOL> analysis_scheme = None ) : <EOL> """<STR_LIT>""" <EOL> index = { <EOL> '<STR_LIT>' : field_name , <EOL> '<STR_LIT>' : field_type <EOL> } <EOL> if field_type == '<STR_LIT>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : facet , <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : searchable , <EOL> '<STR_LIT>' : sortable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = source_field <EOL> elif field_type == '<STR_LIT>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : facet , <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : searchable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT:U+002C>' . join ( source_field ) <EOL> elif field_type == '<STR_LIT:int>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : default , <EOL> '<STR_LIT>' : facet , <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : searchable , <EOL> '<STR_LIT>' : sortable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = source_field <EOL> elif field_type == '<STR_LIT>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : facet , <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : searchable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT:U+002C>' . join ( source_field ) <EOL> elif field_type == '<STR_LIT:date>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : facet , <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : searchable , <EOL> '<STR_LIT>' : sortable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = source_field <EOL> elif field_type == '<STR_LIT>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : facet , <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : searchable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT:U+002C>' . join ( source_field ) <EOL> elif field_type == '<STR_LIT>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : facet , <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : searchable , <EOL> '<STR_LIT>' : sortable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = source_field <EOL> elif field_type == '<STR_LIT>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : facet , <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : searchable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT:U+002C>' . join ( source_field ) <EOL> elif field_type == '<STR_LIT:text>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : highlight , <EOL> '<STR_LIT>' : sortable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = source_field <EOL> if analysis_scheme : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = analysis_scheme <EOL> elif field_type == '<STR_LIT>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : highlight <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT:U+002C>' . join ( source_field ) <EOL> if analysis_scheme : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = analysis_scheme <EOL> elif field_type == '<STR_LIT>' : <EOL> index [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : facet , <EOL> '<STR_LIT>' : returnable , <EOL> '<STR_LIT>' : searchable , <EOL> '<STR_LIT>' : sortable <EOL> } <EOL> if default : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = default <EOL> if source_field : <EOL> index [ '<STR_LIT>' ] [ '<STR_LIT>' ] = source_field <EOL> data = self . layer1 . define_index_field ( self . name , index ) <EOL> data = ( data [ '<STR_LIT>' ] <EOL> [ '<STR_LIT>' ] <EOL> [ '<STR_LIT>' ] ) <EOL> return IndexFieldStatus ( self , data , <EOL> self . layer1 . describe_index_fields ) <EOL> def get_expressions ( self , names = None ) : <EOL> """<STR_LIT>""" <EOL> fn = self . layer1 . describe_expressions <EOL> data = fn ( self . name , names ) <EOL> data = ( data [ '<STR_LIT>' ] <EOL> [ '<STR_LIT>' ] <EOL> [ '<STR_LIT>' ] ) <EOL> return [ ExpressionStatus ( self , d , fn ) for d in data ] <EOL> def create_expression ( self , name , value ) : <EOL> """<STR_LIT>""" <EOL> data = self . layer1 . define_expression ( self . name , name , value ) <EOL> data = ( data [ '<STR_LIT>' ] <EOL> [ '<STR_LIT>' ] <EOL> [ '<STR_LIT>' ] ) <EOL> return ExpressionStatus ( self , data , <EOL> self . layer1 . describe_expressions ) <EOL> def get_document_service ( self ) : <EOL> return DocumentServiceConnection ( domain = self ) <EOL> def get_search_service ( self ) : <EOL> return SearchConnection ( domain = self ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . domain_name </s>
