File: layer1.py

package info (click to toggle)
python-boto 2.49.0-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,888 kB
  • sloc: python: 86,396; makefile: 112
file content (747 lines) | stat: -rw-r--r-- 34,141 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
# Copyright (c) 2012 Mitch Garnaat http://garnaat.org/
# Copyright (c) 2012 Amazon.com, Inc. or its affiliates.
# All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

import boto
import boto.jsonresponse
from boto.connection import AWSQueryConnection
from boto.regioninfo import RegionInfo

#boto.set_stream_logger('cloudsearch')


def do_bool(val):
    return 'true' if val in [True, 1, '1', 'true'] else 'false'


class Layer1(AWSQueryConnection):

    APIVersion = '2011-02-01'
    DefaultRegionName = boto.config.get('Boto', 'cs_region_name', 'us-east-1')
    DefaultRegionEndpoint = boto.config.get('Boto', 'cs_region_endpoint',
                                            'cloudsearch.us-east-1.amazonaws.com')

    def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                 is_secure=True, host=None, port=None,
                 proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None, debug=0,
                 https_connection_factory=None, region=None, path='/',
                 api_version=None, security_token=None,
                 validate_certs=True, profile_name=None):
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
        self.region = region
        AWSQueryConnection.__init__(
            self,
            host=self.region.endpoint,
            aws_access_key_id=aws_access_key_id,
            aws_secret_access_key=aws_secret_access_key,
            is_secure=is_secure,
            port=port,
            proxy=proxy,
            proxy_port=proxy_port,
            proxy_user=proxy_user,
            proxy_pass=proxy_pass,
            debug=debug,
            https_connection_factory=https_connection_factory,
            path=path,
            security_token=security_token,
            validate_certs=validate_certs,
            profile_name=profile_name)

    def _required_auth_capability(self):
        return ['hmac-v4']

    def get_response(self, doc_path, action, params, path='/',
                     parent=None, verb='GET', list_marker=None):
        if not parent:
            parent = self
        response = self.make_request(action, params, path, verb)
        body = response.read()
        boto.log.debug(body)
        if response.status == 200:
            e = boto.jsonresponse.Element(
                list_marker=list_marker if list_marker else 'Set',
                pythonize_name=True)
            h = boto.jsonresponse.XmlHandler(e, parent)
            h.parse(body)
            inner = e
            for p in doc_path:
                inner = inner.get(p)
            if not inner:
                return None if list_marker is None else []
            if isinstance(inner, list):
                return inner
            else:
                return dict(**inner)
        else:
            raise self.ResponseError(response.status, response.reason, body)

    def create_domain(self, domain_name):
        """
        Create a new search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :raises: BaseException, InternalException, LimitExceededException
        """
        doc_path = ('create_domain_response',
                    'create_domain_result',
                    'domain_status')
        params = {'DomainName': domain_name}
        return self.get_response(doc_path, 'CreateDomain',
                                 params, verb='POST')

    def define_index_field(self, domain_name, field_name, field_type,
                           default='', facet=False, result=False,
                           searchable=False, source_attributes=None):
        """
        Defines an ``IndexField``, either replacing an existing
        definition or creating a new one.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type field_name: string
        :param field_name: The name of a field in the search index.

        :type field_type: string
        :param field_type: The type of field.  Valid values are
            uint | literal | text

        :type default: string or int
        :param default: The default value for the field.  If the
            field is of type ``uint`` this should be an integer value.
            Otherwise, it's a string.

        :type facet: bool
        :param facet: A boolean to indicate whether facets
            are enabled for this field or not.  Does not apply to
            fields of type ``uint``.

        :type results: bool
        :param results: A boolean to indicate whether values
            of this field can be returned in search results or
            used in ranking.  Does not apply to fields of type ``uint``.

        :type searchable: bool
        :param searchable: A boolean to indicate whether search
            is enabled for this field or not.  Applies only to fields
            of type ``literal``.

        :type source_attributes: list of dicts
        :param source_attributes: An optional list of dicts that
            provide information about attributes for this index field.
            A maximum of 20 source attributes can be configured for
            each index field.

            Each item in the list is a dict with the following keys:

            * data_copy - The value is a dict with the following keys:
                * default - Optional default value if the source attribute
                    is not specified in a document.
                * name - The name of the document source field to add
                    to this ``IndexField``.
            * data_function - Identifies the transformation to apply
                when copying data from a source attribute.
            * data_map - The value is a dict with the following keys:
                * cases - A dict that translates source field values
                    to custom values.
                * default - An optional default value to use if the
                    source attribute is not specified in a document.
                * name - the name of the document source field to add
                    to this ``IndexField``
            * data_trim_title - Trims common title words from a source
                document attribute when populating an ``IndexField``.
                This can be used to create an ``IndexField`` you can
                use for sorting.  The value is a dict with the following
                fields:
                * default - An optional default value.
                * language - an IETF RFC 4646 language code.
                * separator - The separator that follows the text to trim.
                * name - The name of the document source field to add.

        :raises: BaseException, InternalException, LimitExceededException,
            InvalidTypeException, ResourceNotFoundException
        """
        doc_path = ('define_index_field_response',
                    'define_index_field_result',
                    'index_field')
        params = {'DomainName': domain_name,
                  'IndexField.IndexFieldName': field_name,
                  'IndexField.IndexFieldType': field_type}
        if field_type == 'literal':
            params['IndexField.LiteralOptions.DefaultValue'] = default
            params['IndexField.LiteralOptions.FacetEnabled'] = do_bool(facet)
            params['IndexField.LiteralOptions.ResultEnabled'] = do_bool(result)
            params['IndexField.LiteralOptions.SearchEnabled'] = do_bool(searchable)
        elif field_type == 'uint':
            params['IndexField.UIntOptions.DefaultValue'] = default
        elif field_type == 'text':
            params['IndexField.TextOptions.DefaultValue'] = default
            params['IndexField.TextOptions.FacetEnabled'] = do_bool(facet)
            params['IndexField.TextOptions.ResultEnabled'] = do_bool(result)

        return self.get_response(doc_path, 'DefineIndexField',
                                 params, verb='POST')

    def define_rank_expression(self, domain_name, rank_name, rank_expression):
        """
        Defines a RankExpression, either replacing an existing
        definition or creating a new one.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type rank_name: string
        :param rank_name: The name of an expression computed for ranking
            while processing a search request.

        :type rank_expression: string
        :param rank_expression: The expression to evaluate for ranking
            or thresholding while processing a search request. The
            RankExpression syntax is based on JavaScript expressions
            and supports:

            * Integer, floating point, hex and octal literals
            * Shortcut evaluation of logical operators such that an
                expression a || b evaluates to the value a if a is
                true without evaluting b at all
            * JavaScript order of precedence for operators
            * Arithmetic operators: + - * / %
            * Boolean operators (including the ternary operator)
            * Bitwise operators
            * Comparison operators
            * Common mathematic functions: abs ceil erf exp floor
                lgamma ln log2 log10 max min sqrt pow
            * Trigonometric library functions: acosh acos asinh asin
                atanh atan cosh cos sinh sin tanh tan
            * Random generation of a number between 0 and 1: rand
            * Current time in epoch: time
            * The min max functions that operate on a variable argument list

            Intermediate results are calculated as double precision
            floating point values. The final return value of a
            RankExpression is automatically converted from floating
            point to a 32-bit unsigned integer by rounding to the
            nearest integer, with a natural floor of 0 and a ceiling
            of max(uint32_t), 4294967295. Mathematical errors such as
            dividing by 0 will fail during evaluation and return a
            value of 0.

            The source data for a RankExpression can be the name of an
            IndexField of type uint, another RankExpression or the
            reserved name text_relevance. The text_relevance source is
            defined to return an integer from 0 to 1000 (inclusive) to
            indicate how relevant a document is to the search request,
            taking into account repetition of search terms in the
            document and proximity of search terms to each other in
            each matching IndexField in the document.

            For more information about using rank expressions to
            customize ranking, see the Amazon CloudSearch Developer
            Guide.

        :raises: BaseException, InternalException, LimitExceededException,
            InvalidTypeException, ResourceNotFoundException
        """
        doc_path = ('define_rank_expression_response',
                    'define_rank_expression_result',
                    'rank_expression')
        params = {'DomainName': domain_name,
                  'RankExpression.RankExpression': rank_expression,
                  'RankExpression.RankName': rank_name}
        return self.get_response(doc_path, 'DefineRankExpression',
                                 params, verb='POST')

    def delete_domain(self, domain_name):
        """
        Delete a search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :raises: BaseException, InternalException
        """
        doc_path = ('delete_domain_response',
                    'delete_domain_result',
                    'domain_status')
        params = {'DomainName': domain_name}
        return self.get_response(doc_path, 'DeleteDomain',
                                 params, verb='POST')

    def delete_index_field(self, domain_name, field_name):
        """
        Deletes an existing ``IndexField`` from the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type field_name: string
        :param field_name: A string that represents the name of
            an index field. Field names must begin with a letter and
            can contain the following characters: a-z (lowercase),
            0-9, and _ (underscore). Uppercase letters and hyphens are
            not allowed. The names "body", "docid", and
            "text_relevance" are reserved and cannot be specified as
            field or rank expression names.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('delete_index_field_response',
                    'delete_index_field_result',
                    'index_field')
        params = {'DomainName': domain_name,
                  'IndexFieldName': field_name}
        return self.get_response(doc_path, 'DeleteIndexField',
                                 params, verb='POST')

    def delete_rank_expression(self, domain_name, rank_name):
        """
        Deletes an existing ``RankExpression`` from the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type rank_name: string
        :param rank_name: Name of the ``RankExpression`` to delete.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('delete_rank_expression_response',
                    'delete_rank_expression_result',
                    'rank_expression')
        params = {'DomainName': domain_name, 'RankName': rank_name}
        return self.get_response(doc_path, 'DeleteRankExpression',
                                 params, verb='POST')

    def describe_default_search_field(self, domain_name):
        """
        Describes options defining the default search field used by
        indexing for the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('describe_default_search_field_response',
                    'describe_default_search_field_result',
                    'default_search_field')
        params = {'DomainName': domain_name}
        return self.get_response(doc_path, 'DescribeDefaultSearchField',
                                 params, verb='POST')

    def describe_domains(self, domain_names=None):
        """
        Describes the domains (optionally limited to one or more
        domains by name) owned by this account.

        :type domain_names: list
        :param domain_names: Limits the response to the specified domains.

        :raises: BaseException, InternalException
        """
        doc_path = ('describe_domains_response',
                    'describe_domains_result',
                    'domain_status_list')
        params = {}
        if domain_names:
            for i, domain_name in enumerate(domain_names, 1):
                params['DomainNames.member.%d' % i] = domain_name
        return self.get_response(doc_path, 'DescribeDomains',
                                 params, verb='POST',
                                 list_marker='DomainStatusList')

    def describe_index_fields(self, domain_name, field_names=None):
        """
        Describes index fields in the search domain, optionally
        limited to a single ``IndexField``.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type field_names: list
        :param field_names: Limits the response to the specified fields.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('describe_index_fields_response',
                    'describe_index_fields_result',
                    'index_fields')
        params = {'DomainName': domain_name}
        if field_names:
            for i, field_name in enumerate(field_names, 1):
                params['FieldNames.member.%d' % i] = field_name
        return self.get_response(doc_path, 'DescribeIndexFields',
                                 params, verb='POST',
                                 list_marker='IndexFields')

    def describe_rank_expressions(self, domain_name, rank_names=None):
        """
        Describes RankExpressions in the search domain, optionally
        limited to a single expression.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type rank_names: list
        :param rank_names: Limit response to the specified rank names.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('describe_rank_expressions_response',
                    'describe_rank_expressions_result',
                    'rank_expressions')
        params = {'DomainName': domain_name}
        if rank_names:
            for i, rank_name in enumerate(rank_names, 1):
                params['RankNames.member.%d' % i] = rank_name
        return self.get_response(doc_path, 'DescribeRankExpressions',
                                 params, verb='POST',
                                 list_marker='RankExpressions')

    def describe_service_access_policies(self, domain_name):
        """
        Describes the resource-based policies controlling access to
        the services in this search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('describe_service_access_policies_response',
                    'describe_service_access_policies_result',
                    'access_policies')
        params = {'DomainName': domain_name}
        return self.get_response(doc_path, 'DescribeServiceAccessPolicies',
                                 params, verb='POST')

    def describe_stemming_options(self, domain_name):
        """
        Describes stemming options used by indexing for the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('describe_stemming_options_response',
                    'describe_stemming_options_result',
                    'stems')
        params = {'DomainName': domain_name}
        return self.get_response(doc_path, 'DescribeStemmingOptions',
                                 params, verb='POST')

    def describe_stopword_options(self, domain_name):
        """
        Describes stopword options used by indexing for the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('describe_stopword_options_response',
                    'describe_stopword_options_result',
                    'stopwords')
        params = {'DomainName': domain_name}
        return self.get_response(doc_path, 'DescribeStopwordOptions',
                                 params, verb='POST')

    def describe_synonym_options(self, domain_name):
        """
        Describes synonym options used by indexing for the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('describe_synonym_options_response',
                    'describe_synonym_options_result',
                    'synonyms')
        params = {'DomainName': domain_name}
        return self.get_response(doc_path, 'DescribeSynonymOptions',
                                 params, verb='POST')

    def index_documents(self, domain_name):
        """
        Tells the search domain to start scanning its documents using
        the latest text processing options and ``IndexFields``.  This
        operation must be invoked to make visible in searches any
        options whose <a>OptionStatus</a> has ``OptionState`` of
        ``RequiresIndexDocuments``.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :raises: BaseException, InternalException, ResourceNotFoundException
        """
        doc_path = ('index_documents_response',
                    'index_documents_result',
                    'field_names')
        params = {'DomainName': domain_name}
        return self.get_response(doc_path, 'IndexDocuments', params,
                                 verb='POST', list_marker='FieldNames')

    def update_default_search_field(self, domain_name, default_search_field):
        """
        Updates options defining the default search field used by
        indexing for the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type default_search_field: string
        :param default_search_field: The IndexField to use for search
            requests issued with the q parameter. The default is an
            empty string, which automatically searches all text
            fields.

        :raises: BaseException, InternalException, InvalidTypeException,
            ResourceNotFoundException
        """
        doc_path = ('update_default_search_field_response',
                    'update_default_search_field_result',
                    'default_search_field')
        params = {'DomainName': domain_name,
                  'DefaultSearchField': default_search_field}
        return self.get_response(doc_path, 'UpdateDefaultSearchField',
                                 params, verb='POST')

    def update_service_access_policies(self, domain_name, access_policies):
        """
        Updates the policies controlling access to the services in
        this search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type access_policies: string
        :param access_policies: An IAM access policy as described in
            The Access Policy Language in Using AWS Identity and
            Access Management. The maximum size of an access policy
            document is 100KB.

        :raises: BaseException, InternalException, LimitExceededException,
            ResourceNotFoundException, InvalidTypeException
        """
        doc_path = ('update_service_access_policies_response',
                    'update_service_access_policies_result',
                    'access_policies')
        params = {'AccessPolicies': access_policies,
                  'DomainName': domain_name}
        return self.get_response(doc_path, 'UpdateServiceAccessPolicies',
                                 params, verb='POST')

    def update_stemming_options(self, domain_name, stems):
        """
        Updates stemming options used by indexing for the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type stems: string
        :param stems: Maps terms to their stems.  The JSON object
            has a single key called "stems" whose value is a
            dict mapping terms to their stems. The maximum size
            of a stemming document is 500KB.
            Example: {"stems":{"people": "person", "walking":"walk"}}

        :raises: BaseException, InternalException, InvalidTypeException,
            LimitExceededException, ResourceNotFoundException
        """
        doc_path = ('update_stemming_options_response',
                    'update_stemming_options_result',
                    'stems')
        params = {'DomainName': domain_name,
                  'Stems': stems}
        return self.get_response(doc_path, 'UpdateStemmingOptions',
                                 params, verb='POST')

    def update_stopword_options(self, domain_name, stopwords):
        """
        Updates stopword options used by indexing for the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type stopwords: string
        :param stopwords: Lists stopwords in a JSON object. The object has a
            single key called "stopwords" whose value is an array of strings.
            The maximum size of a stopwords document is 10KB. Example:
            {"stopwords": ["a", "an", "the", "of"]}

        :raises: BaseException, InternalException, InvalidTypeException,
            LimitExceededException, ResourceNotFoundException
        """
        doc_path = ('update_stopword_options_response',
                    'update_stopword_options_result',
                    'stopwords')
        params = {'DomainName': domain_name,
                  'Stopwords': stopwords}
        return self.get_response(doc_path, 'UpdateStopwordOptions',
                                 params, verb='POST')

    def update_synonym_options(self, domain_name, synonyms):
        """
        Updates synonym options used by indexing for the search domain.

        :type domain_name: string
        :param domain_name: A string that represents the name of a
            domain. Domain names must be unique across the domains
            owned by an account within an AWS region. Domain names
            must start with a letter or number and can contain the
            following characters: a-z (lowercase), 0-9, and -
            (hyphen). Uppercase letters and underscores are not
            allowed.

        :type synonyms: string
        :param synonyms: Maps terms to their synonyms.  The JSON object
            has a single key "synonyms" whose value is a dict mapping terms
            to their synonyms. Each synonym is a simple string or an
            array of strings. The maximum size of a stopwords document
            is 100KB. Example:
            {"synonyms": {"cat": ["feline", "kitten"], "puppy": "dog"}}

        :raises: BaseException, InternalException, InvalidTypeException,
            LimitExceededException, ResourceNotFoundException
        """
        doc_path = ('update_synonym_options_response',
                    'update_synonym_options_result',
                    'synonyms')
        params = {'DomainName': domain_name,
                  'Synonyms': synonyms}
        return self.get_response(doc_path, 'UpdateSynonymOptions',
                                 params, verb='POST')