comparison env/lib/python3.9/site-packages/boto/cloudsearch2/layer1.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 # Copyright (c) 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions:
10 #
11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE.
21 #
22
23 import boto
24 from boto.compat import json
25 from boto.connection import AWSQueryConnection
26 from boto.regioninfo import RegionInfo
27 from boto.exception import JSONResponseError
28 from boto.cloudsearch2 import exceptions
29
30
31 class CloudSearchConnection(AWSQueryConnection):
32 """
33 Amazon CloudSearch Configuration Service
34 You use the Amazon CloudSearch configuration service to create,
35 configure, and manage search domains. Configuration service
36 requests are submitted using the AWS Query protocol. AWS Query
37 requests are HTTP or HTTPS requests submitted via HTTP GET or POST
38 with a query parameter named Action.
39
40 The endpoint for configuration service requests is region-
41 specific: cloudsearch. region .amazonaws.com. For example,
42 cloudsearch.us-east-1.amazonaws.com. For a current list of
43 supported regions and endpoints, see `Regions and Endpoints`_.
44 """
45 APIVersion = "2013-01-01"
46 DefaultRegionName = "us-east-1"
47 DefaultRegionEndpoint = "cloudsearch.us-east-1.amazonaws.com"
48 ResponseError = JSONResponseError
49
50 _faults = {
51 "InvalidTypeException": exceptions.InvalidTypeException,
52 "LimitExceededException": exceptions.LimitExceededException,
53 "InternalException": exceptions.InternalException,
54 "DisabledOperationException": exceptions.DisabledOperationException,
55 "ResourceNotFoundException": exceptions.ResourceNotFoundException,
56 "BaseException": exceptions.BaseException,
57 }
58
59 def __init__(self, **kwargs):
60 region = kwargs.pop('region', None)
61 if not region:
62 region = RegionInfo(self, self.DefaultRegionName,
63 self.DefaultRegionEndpoint)
64
65 if 'host' not in kwargs or kwargs['host'] is None:
66 kwargs['host'] = region.endpoint
67
68 sign_request = kwargs.pop('sign_request', False)
69 self.sign_request = sign_request
70
71 super(CloudSearchConnection, self).__init__(**kwargs)
72 self.region = region
73
74 def _required_auth_capability(self):
75 return ['hmac-v4']
76
77 def build_suggesters(self, domain_name):
78 """
79 Indexes the search suggestions.
80
81 :type domain_name: string
82 :param domain_name: A string that represents the name of a domain.
83 Domain names are unique across the domains owned by an account
84 within an AWS region. Domain names start with a letter or number
85 and can contain the following characters: a-z (lowercase), 0-9, and
86 - (hyphen).
87
88 """
89 params = {'DomainName': domain_name, }
90 return self._make_request(
91 action='BuildSuggesters',
92 verb='POST',
93 path='/', params=params)
94
95 def create_domain(self, domain_name):
96 """
97 Creates a new search domain. For more information, see
98 `Creating a Search Domain`_ in the Amazon CloudSearch
99 Developer Guide .
100
101 :type domain_name: string
102 :param domain_name: A name for the domain you are creating. Allowed
103 characters are a-z (lower-case letters), 0-9, and hyphen (-).
104 Domain names must start with a letter or number and be at least 3
105 and no more than 28 characters long.
106
107 """
108 params = {'DomainName': domain_name, }
109 return self._make_request(
110 action='CreateDomain',
111 verb='POST',
112 path='/', params=params)
113
114 def define_analysis_scheme(self, domain_name, analysis_scheme):
115 """
116 Configures an analysis scheme that can be applied to a `text`
117 or `text-array` field to define language-specific text
118 processing options. For more information, see `Configuring
119 Analysis Schemes`_ in the Amazon CloudSearch Developer Guide .
120
121 :type domain_name: string
122 :param domain_name: A string that represents the name of a domain.
123 Domain names are unique across the domains owned by an account
124 within an AWS region. Domain names start with a letter or number
125 and can contain the following characters: a-z (lowercase), 0-9, and
126 - (hyphen).
127
128 :type analysis_scheme: dict
129 :param analysis_scheme: Configuration information for an analysis
130 scheme. Each analysis scheme has a unique name and specifies the
131 language of the text to be processed. The following options can be
132 configured for an analysis scheme: `Synonyms`, `Stopwords`,
133 `StemmingDictionary`, and `AlgorithmicStemming`.
134
135 """
136 params = {'DomainName': domain_name, }
137 self.build_complex_param(params, 'AnalysisScheme',
138 analysis_scheme)
139 return self._make_request(
140 action='DefineAnalysisScheme',
141 verb='POST',
142 path='/', params=params)
143
144 def define_expression(self, domain_name, expression):
145 """
146 Configures an `Expression` for the search domain. Used to
147 create new expressions and modify existing ones. If the
148 expression exists, the new configuration replaces the old one.
149 For more information, see `Configuring Expressions`_ in the
150 Amazon CloudSearch Developer Guide .
151
152 :type domain_name: string
153 :param domain_name: A string that represents the name of a domain.
154 Domain names are unique across the domains owned by an account
155 within an AWS region. Domain names start with a letter or number
156 and can contain the following characters: a-z (lowercase), 0-9, and
157 - (hyphen).
158
159 :type expression: dict
160 :param expression: A named expression that can be evaluated at search
161 time. Can be used to sort the search results, define other
162 expressions, or return computed information in the search results.
163
164 """
165 params = {'DomainName': domain_name, }
166 self.build_complex_param(params, 'Expression',
167 expression)
168 return self._make_request(
169 action='DefineExpression',
170 verb='POST',
171 path='/', params=params)
172
173 def define_index_field(self, domain_name, index_field):
174 """
175 Configures an `IndexField` for the search domain. Used to
176 create new fields and modify existing ones. You must specify
177 the name of the domain you are configuring and an index field
178 configuration. The index field configuration specifies a
179 unique name, the index field type, and the options you want to
180 configure for the field. The options you can specify depend on
181 the `IndexFieldType`. If the field exists, the new
182 configuration replaces the old one. For more information, see
183 `Configuring Index Fields`_ in the Amazon CloudSearch
184 Developer Guide .
185
186 :type domain_name: string
187 :param domain_name: A string that represents the name of a domain.
188 Domain names are unique across the domains owned by an account
189 within an AWS region. Domain names start with a letter or number
190 and can contain the following characters: a-z (lowercase), 0-9, and
191 - (hyphen).
192
193 :type index_field: dict
194 :param index_field: The index field and field options you want to
195 configure.
196
197 """
198 params = {'DomainName': domain_name, }
199 self.build_complex_param(params, 'IndexField',
200 index_field)
201 return self._make_request(
202 action='DefineIndexField',
203 verb='POST',
204 path='/', params=params)
205
206 def define_suggester(self, domain_name, suggester):
207 """
208 Configures a suggester for a domain. A suggester enables you
209 to display possible matches before users finish typing their
210 queries. When you configure a suggester, you must specify the
211 name of the text field you want to search for possible matches
212 and a unique name for the suggester. For more information, see
213 `Getting Search Suggestions`_ in the Amazon CloudSearch
214 Developer Guide .
215
216 :type domain_name: string
217 :param domain_name: A string that represents the name of a domain.
218 Domain names are unique across the domains owned by an account
219 within an AWS region. Domain names start with a letter or number
220 and can contain the following characters: a-z (lowercase), 0-9, and
221 - (hyphen).
222
223 :type suggester: dict
224 :param suggester: Configuration information for a search suggester.
225 Each suggester has a unique name and specifies the text field you
226 want to use for suggestions. The following options can be
227 configured for a suggester: `FuzzyMatching`, `SortExpression`.
228
229 """
230 params = {'DomainName': domain_name, }
231 self.build_complex_param(params, 'Suggester',
232 suggester)
233 return self._make_request(
234 action='DefineSuggester',
235 verb='POST',
236 path='/', params=params)
237
238 def delete_analysis_scheme(self, domain_name, analysis_scheme_name):
239 """
240 Deletes an analysis scheme. For more information, see
241 `Configuring Analysis Schemes`_ in the Amazon CloudSearch
242 Developer Guide .
243
244 :type domain_name: string
245 :param domain_name: A string that represents the name of a domain.
246 Domain names are unique across the domains owned by an account
247 within an AWS region. Domain names start with a letter or number
248 and can contain the following characters: a-z (lowercase), 0-9, and
249 - (hyphen).
250
251 :type analysis_scheme_name: string
252 :param analysis_scheme_name: The name of the analysis scheme you want
253 to delete.
254
255 """
256 params = {
257 'DomainName': domain_name,
258 'AnalysisSchemeName': analysis_scheme_name,
259 }
260 return self._make_request(
261 action='DeleteAnalysisScheme',
262 verb='POST',
263 path='/', params=params)
264
265 def delete_domain(self, domain_name):
266 """
267 Permanently deletes a search domain and all of its data. Once
268 a domain has been deleted, it cannot be recovered. For more
269 information, see `Deleting a Search Domain`_ in the Amazon
270 CloudSearch Developer Guide .
271
272 :type domain_name: string
273 :param domain_name: The name of the domain you want to permanently
274 delete.
275
276 """
277 params = {'DomainName': domain_name, }
278 return self._make_request(
279 action='DeleteDomain',
280 verb='POST',
281 path='/', params=params)
282
283 def delete_expression(self, domain_name, expression_name):
284 """
285 Removes an `Expression` from the search domain. For more
286 information, see `Configuring Expressions`_ in the Amazon
287 CloudSearch Developer Guide .
288
289 :type domain_name: string
290 :param domain_name: A string that represents the name of a domain.
291 Domain names are unique across the domains owned by an account
292 within an AWS region. Domain names start with a letter or number
293 and can contain the following characters: a-z (lowercase), 0-9, and
294 - (hyphen).
295
296 :type expression_name: string
297 :param expression_name: The name of the `Expression` to delete.
298
299 """
300 params = {
301 'DomainName': domain_name,
302 'ExpressionName': expression_name,
303 }
304 return self._make_request(
305 action='DeleteExpression',
306 verb='POST',
307 path='/', params=params)
308
309 def delete_index_field(self, domain_name, index_field_name):
310 """
311 Removes an `IndexField` from the search domain. For more
312 information, see `Configuring Index Fields`_ in the Amazon
313 CloudSearch Developer Guide .
314
315 :type domain_name: string
316 :param domain_name: A string that represents the name of a domain.
317 Domain names are unique across the domains owned by an account
318 within an AWS region. Domain names start with a letter or number
319 and can contain the following characters: a-z (lowercase), 0-9, and
320 - (hyphen).
321
322 :type index_field_name: string
323 :param index_field_name: The name of the index field your want to
324 remove from the domain's indexing options.
325
326 """
327 params = {
328 'DomainName': domain_name,
329 'IndexFieldName': index_field_name,
330 }
331 return self._make_request(
332 action='DeleteIndexField',
333 verb='POST',
334 path='/', params=params)
335
336 def delete_suggester(self, domain_name, suggester_name):
337 """
338 Deletes a suggester. For more information, see `Getting Search
339 Suggestions`_ in the Amazon CloudSearch Developer Guide .
340
341 :type domain_name: string
342 :param domain_name: A string that represents the name of a domain.
343 Domain names are unique across the domains owned by an account
344 within an AWS region. Domain names start with a letter or number
345 and can contain the following characters: a-z (lowercase), 0-9, and
346 - (hyphen).
347
348 :type suggester_name: string
349 :param suggester_name: Specifies the name of the suggester you want to
350 delete.
351
352 """
353 params = {
354 'DomainName': domain_name,
355 'SuggesterName': suggester_name,
356 }
357 return self._make_request(
358 action='DeleteSuggester',
359 verb='POST',
360 path='/', params=params)
361
362 def describe_analysis_schemes(self, domain_name,
363 analysis_scheme_names=None, deployed=None):
364 """
365 Gets the analysis schemes configured for a domain. An analysis
366 scheme defines language-specific text processing options for a
367 `text` field. Can be limited to specific analysis schemes by
368 name. By default, shows all analysis schemes and includes any
369 pending changes to the configuration. Set the `Deployed`
370 option to `True` to show the active configuration and exclude
371 pending changes. For more information, see `Configuring
372 Analysis Schemes`_ in the Amazon CloudSearch Developer Guide .
373
374 :type domain_name: string
375 :param domain_name: The name of the domain you want to describe.
376
377 :type analysis_scheme_names: list
378 :param analysis_scheme_names: The analysis schemes you want to
379 describe.
380
381 :type deployed: boolean
382 :param deployed: Whether to display the deployed configuration (
383 `True`) or include any pending changes ( `False`). Defaults to
384 `False`.
385
386 """
387 params = {'DomainName': domain_name, }
388 if analysis_scheme_names is not None:
389 self.build_list_params(params,
390 analysis_scheme_names,
391 'AnalysisSchemeNames.member')
392 if deployed is not None:
393 params['Deployed'] = str(
394 deployed).lower()
395 return self._make_request(
396 action='DescribeAnalysisSchemes',
397 verb='POST',
398 path='/', params=params)
399
400 def describe_availability_options(self, domain_name, deployed=None):
401 """
402 Gets the availability options configured for a domain. By
403 default, shows the configuration with any pending changes. Set
404 the `Deployed` option to `True` to show the active
405 configuration and exclude pending changes. For more
406 information, see `Configuring Availability Options`_ in the
407 Amazon CloudSearch Developer Guide .
408
409 :type domain_name: string
410 :param domain_name: The name of the domain you want to describe.
411
412 :type deployed: boolean
413 :param deployed: Whether to display the deployed configuration (
414 `True`) or include any pending changes ( `False`). Defaults to
415 `False`.
416
417 """
418 params = {'DomainName': domain_name, }
419 if deployed is not None:
420 params['Deployed'] = str(
421 deployed).lower()
422 return self._make_request(
423 action='DescribeAvailabilityOptions',
424 verb='POST',
425 path='/', params=params)
426
427 def describe_domains(self, domain_names=None):
428 """
429 Gets information about the search domains owned by this
430 account. Can be limited to specific domains. Shows all domains
431 by default. To get the number of searchable documents in a
432 domain, use the console or submit a `matchall` request to your
433 domain's search endpoint:
434 `q=matchall&q.parser=structured&size=0`. For more information,
435 see `Getting Information about a Search Domain`_ in the Amazon
436 CloudSearch Developer Guide .
437
438 :type domain_names: list
439 :param domain_names: The names of the domains you want to include in
440 the response.
441
442 """
443 params = {}
444 if domain_names is not None:
445 self.build_list_params(params,
446 domain_names,
447 'DomainNames.member')
448 return self._make_request(
449 action='DescribeDomains',
450 verb='POST',
451 path='/', params=params)
452
453 def describe_expressions(self, domain_name, expression_names=None,
454 deployed=None):
455 """
456 Gets the expressions configured for the search domain. Can be
457 limited to specific expressions by name. By default, shows all
458 expressions and includes any pending changes to the
459 configuration. Set the `Deployed` option to `True` to show the
460 active configuration and exclude pending changes. For more
461 information, see `Configuring Expressions`_ in the Amazon
462 CloudSearch Developer Guide .
463
464 :type domain_name: string
465 :param domain_name: The name of the domain you want to describe.
466
467 :type expression_names: list
468 :param expression_names: Limits the `DescribeExpressions` response to
469 the specified expressions. If not specified, all expressions are
470 shown.
471
472 :type deployed: boolean
473 :param deployed: Whether to display the deployed configuration (
474 `True`) or include any pending changes ( `False`). Defaults to
475 `False`.
476
477 """
478 params = {'DomainName': domain_name, }
479 if expression_names is not None:
480 self.build_list_params(params,
481 expression_names,
482 'ExpressionNames.member')
483 if deployed is not None:
484 params['Deployed'] = str(
485 deployed).lower()
486 return self._make_request(
487 action='DescribeExpressions',
488 verb='POST',
489 path='/', params=params)
490
491 def describe_index_fields(self, domain_name, field_names=None,
492 deployed=None):
493 """
494 Gets information about the index fields configured for the
495 search domain. Can be limited to specific fields by name. By
496 default, shows all fields and includes any pending changes to
497 the configuration. Set the `Deployed` option to `True` to show
498 the active configuration and exclude pending changes. For more
499 information, see `Getting Domain Information`_ in the Amazon
500 CloudSearch Developer Guide .
501
502 :type domain_name: string
503 :param domain_name: The name of the domain you want to describe.
504
505 :type field_names: list
506 :param field_names: A list of the index fields you want to describe. If
507 not specified, information is returned for all configured index
508 fields.
509
510 :type deployed: boolean
511 :param deployed: Whether to display the deployed configuration (
512 `True`) or include any pending changes ( `False`). Defaults to
513 `False`.
514
515 """
516 params = {'DomainName': domain_name, }
517 if field_names is not None:
518 self.build_list_params(params,
519 field_names,
520 'FieldNames.member')
521 if deployed is not None:
522 params['Deployed'] = str(
523 deployed).lower()
524 return self._make_request(
525 action='DescribeIndexFields',
526 verb='POST',
527 path='/', params=params)
528
529 def describe_scaling_parameters(self, domain_name):
530 """
531 Gets the scaling parameters configured for a domain. A
532 domain's scaling parameters specify the desired search
533 instance type and replication count. For more information, see
534 `Configuring Scaling Options`_ in the Amazon CloudSearch
535 Developer Guide .
536
537 :type domain_name: string
538 :param domain_name: A string that represents the name of a domain.
539 Domain names are unique across the domains owned by an account
540 within an AWS region. Domain names start with a letter or number
541 and can contain the following characters: a-z (lowercase), 0-9, and
542 - (hyphen).
543
544 """
545 params = {'DomainName': domain_name, }
546 return self._make_request(
547 action='DescribeScalingParameters',
548 verb='POST',
549 path='/', params=params)
550
551 def describe_service_access_policies(self, domain_name, deployed=None):
552 """
553 Gets information about the access policies that control access
554 to the domain's document and search endpoints. By default,
555 shows the configuration with any pending changes. Set the
556 `Deployed` option to `True` to show the active configuration
557 and exclude pending changes. For more information, see
558 `Configuring Access for a Search Domain`_ in the Amazon
559 CloudSearch Developer Guide .
560
561 :type domain_name: string
562 :param domain_name: The name of the domain you want to describe.
563
564 :type deployed: boolean
565 :param deployed: Whether to display the deployed configuration (
566 `True`) or include any pending changes ( `False`). Defaults to
567 `False`.
568
569 """
570 params = {'DomainName': domain_name, }
571 if deployed is not None:
572 params['Deployed'] = str(
573 deployed).lower()
574 return self._make_request(
575 action='DescribeServiceAccessPolicies',
576 verb='POST',
577 path='/', params=params)
578
579 def describe_suggesters(self, domain_name, suggester_names=None,
580 deployed=None):
581 """
582 Gets the suggesters configured for a domain. A suggester
583 enables you to display possible matches before users finish
584 typing their queries. Can be limited to specific suggesters by
585 name. By default, shows all suggesters and includes any
586 pending changes to the configuration. Set the `Deployed`
587 option to `True` to show the active configuration and exclude
588 pending changes. For more information, see `Getting Search
589 Suggestions`_ in the Amazon CloudSearch Developer Guide .
590
591 :type domain_name: string
592 :param domain_name: The name of the domain you want to describe.
593
594 :type suggester_names: list
595 :param suggester_names: The suggesters you want to describe.
596
597 :type deployed: boolean
598 :param deployed: Whether to display the deployed configuration (
599 `True`) or include any pending changes ( `False`). Defaults to
600 `False`.
601
602 """
603 params = {'DomainName': domain_name, }
604 if suggester_names is not None:
605 self.build_list_params(params,
606 suggester_names,
607 'SuggesterNames.member')
608 if deployed is not None:
609 params['Deployed'] = str(
610 deployed).lower()
611 return self._make_request(
612 action='DescribeSuggesters',
613 verb='POST',
614 path='/', params=params)
615
616 def index_documents(self, domain_name):
617 """
618 Tells the search domain to start indexing its documents using
619 the latest indexing options. This operation must be invoked to
620 activate options whose OptionStatus is
621 `RequiresIndexDocuments`.
622
623 :type domain_name: string
624 :param domain_name: A string that represents the name of a domain.
625 Domain names are unique across the domains owned by an account
626 within an AWS region. Domain names start with a letter or number
627 and can contain the following characters: a-z (lowercase), 0-9, and
628 - (hyphen).
629
630 """
631 params = {'DomainName': domain_name, }
632 return self._make_request(
633 action='IndexDocuments',
634 verb='POST',
635 path='/', params=params)
636
637 def list_domain_names(self):
638 """
639 Lists all search domains owned by an account.
640 """
641 params = {}
642 return self._make_request(
643 action='ListDomainNames',
644 verb='POST',
645 path='/', params=params)
646
647 def update_availability_options(self, domain_name, multi_az):
648 """
649 Configures the availability options for a domain. Enabling the
650 Multi-AZ option expands an Amazon CloudSearch domain to an
651 additional Availability Zone in the same Region to increase
652 fault tolerance in the event of a service disruption. Changes
653 to the Multi-AZ option can take about half an hour to become
654 active. For more information, see `Configuring Availability
655 Options`_ in the Amazon CloudSearch Developer Guide .
656
657 :type domain_name: string
658 :param domain_name: A string that represents the name of a domain.
659 Domain names are unique across the domains owned by an account
660 within an AWS region. Domain names start with a letter or number
661 and can contain the following characters: a-z (lowercase), 0-9, and
662 - (hyphen).
663
664 :type multi_az: boolean
665 :param multi_az: You expand an existing search domain to a second
666 Availability Zone by setting the Multi-AZ option to true.
667 Similarly, you can turn off the Multi-AZ option to downgrade the
668 domain to a single Availability Zone by setting the Multi-AZ option
669 to `False`.
670
671 """
672 params = {'DomainName': domain_name, 'MultiAZ': multi_az, }
673 return self._make_request(
674 action='UpdateAvailabilityOptions',
675 verb='POST',
676 path='/', params=params)
677
678 def update_scaling_parameters(self, domain_name, scaling_parameters):
679 """
680 Configures scaling parameters for a domain. A domain's scaling
681 parameters specify the desired search instance type and
682 replication count. Amazon CloudSearch will still automatically
683 scale your domain based on the volume of data and traffic, but
684 not below the desired instance type and replication count. If
685 the Multi-AZ option is enabled, these values control the
686 resources used per Availability Zone. For more information,
687 see `Configuring Scaling Options`_ in the Amazon CloudSearch
688 Developer Guide .
689
690 :type domain_name: string
691 :param domain_name: A string that represents the name of a domain.
692 Domain names are unique across the domains owned by an account
693 within an AWS region. Domain names start with a letter or number
694 and can contain the following characters: a-z (lowercase), 0-9, and
695 - (hyphen).
696
697 :type scaling_parameters: dict
698 :param scaling_parameters: The desired instance type and desired number
699 of replicas of each index partition.
700
701 """
702 params = {'DomainName': domain_name, }
703 self.build_complex_param(params, 'ScalingParameters',
704 scaling_parameters)
705 return self._make_request(
706 action='UpdateScalingParameters',
707 verb='POST',
708 path='/', params=params)
709
710 def update_service_access_policies(self, domain_name, access_policies):
711 """
712 Configures the access rules that control access to the
713 domain's document and search endpoints. For more information,
714 see ` Configuring Access for an Amazon CloudSearch Domain`_.
715
716 :type domain_name: string
717 :param domain_name: A string that represents the name of a domain.
718 Domain names are unique across the domains owned by an account
719 within an AWS region. Domain names start with a letter or number
720 and can contain the following characters: a-z (lowercase), 0-9, and
721 - (hyphen).
722
723 :type access_policies: string
724 :param access_policies: The access rules you want to configure. These
725 rules replace any existing rules.
726
727 """
728 params = {
729 'DomainName': domain_name,
730 'AccessPolicies': access_policies,
731 }
732 return self._make_request(
733 action='UpdateServiceAccessPolicies',
734 verb='POST',
735 path='/', params=params)
736
737 def build_complex_param(self, params, label, value):
738 """Serialize a structure.
739
740 For example::
741
742 param_type = 'structure'
743 label = 'IndexField'
744 value = {'IndexFieldName': 'a', 'IntOptions': {'DefaultValue': 5}}
745
746 would result in the params dict being updated with these params::
747
748 IndexField.IndexFieldName = a
749 IndexField.IntOptions.DefaultValue = 5
750
751 :type params: dict
752 :param params: The params dict. The complex list params
753 will be added to this dict.
754
755 :type label: str
756 :param label: String label for param key
757
758 :type value: any
759 :param value: The value to serialize
760 """
761 for k, v in value.items():
762 if isinstance(v, dict):
763 for k2, v2 in v.items():
764 self.build_complex_param(params, label + '.' + k, v)
765 elif isinstance(v, bool):
766 params['%s.%s' % (label, k)] = v and 'true' or 'false'
767 else:
768 params['%s.%s' % (label, k)] = v
769
770 def _make_request(self, action, verb, path, params):
771 params['ContentType'] = 'JSON'
772 response = self.make_request(action=action, verb='POST',
773 path='/', params=params)
774 body = response.read().decode('utf-8')
775 boto.log.debug(body)
776 if response.status == 200:
777 return json.loads(body)
778 else:
779 json_body = json.loads(body)
780 fault_name = json_body.get('Error', {}).get('Code', None)
781 exception_class = self._faults.get(fault_name, self.ResponseError)
782 raise exception_class(response.status, response.reason,
783 body=json_body)