Ë
    ‹c×eK  ã                   ó„   — d Z ddlZddlZddlmZ ddlmZ  G d„ dej                  «      Z G d„ dej                  «      Z	y)	aÈ  
Remote File
-----------

The **remote_file** backend driver is the first driver implemented by
oslo.config. It extends the previous limit of only accessing local files
to a new scenario where it is possible to access configuration data over
the network. The **remote_file** driver is based on the **requests** module
and is capable of accessing remote files through **HTTP** or **HTTPS**.

To definition of a remote_file configuration data source can be as minimal as::

    [DEFAULT]
    config_source = external_config_group

    [external_config_group]
    driver = remote_file
    uri = http://mydomain.com/path/to/config/data.conf

Or as complete as::

    [DEFAULT]
    config_source = external_config_group

    [external_config_group]
    driver = remote_file
    uri = https://mydomain.com/path/to/config/data.conf
    ca_path = /path/to/server/ca.pem
    client_key = /path/to/my/key.pem
    client_cert = /path/to/my/cert.pem

On the following sessions, you can find more information about this driver's
classes and its options.

The Driver Class
================

.. autoclass:: URIConfigurationSourceDriver

The Configuration Source Class
==============================

.. autoclass:: URIConfigurationSource

é    N)Úcfg)Úsourcesc            	       óî   — e Zd ZdZ ej
                  dddgddd¬«       ej                  d	d
d¬«       ej                  ddd¬«       ej                  dd¬«       ej                  ddd¬«      gZd„ Zd„ Z	y)ÚURIConfigurationSourceDriveraU  A backend driver for remote files served through http[s].

    Required options:
      - uri: URI containing the file location.

    Non-required options:
      - ca_path: The path to a CA_BUNDLE file or directory with
                 certificates of trusted CAs.

      - client_cert: Client side certificate, as a single file path
                     containing either the certificate only or the
                     private key and the certificate.

      - client_key: Client side private key, in case client_cert is
                    specified but does not includes the private key.
    ÚuriÚhttpÚhttpsTz(https://example.com/my-configuration.inizHRequired option with the URI of the extra configuration file's location.)ÚschemesÚrequiredÚsample_defaultÚhelpÚca_pathz/etc/ca-certificateszKThe path to a CA_BUNDLE file or directory with certificates of trusted CAs.)r   r   Úclient_certz,/etc/ca-certificates/service-client-keystorez}Client side certificate, as a single file path containing either the certificate only or the private key and the certificate.Ú
client_keyz`Client side private key, in case client_cert is specified but does not includes the private key.)r   Útimeouté<   zˆTimeout is the number of seconds the request will wait for your client to establish a connection to a remote machine call on the socket.)Údefaultr   c                 ó   — | j                   S ©N)Ú_uri_driver_opts)Úselfs    ú:/usr/lib/python3/dist-packages/oslo_config/sources/_uri.pyÚlist_options_for_discoveryz7URIConfigurationSourceDriver.list_options_for_discoveryw   s   € Ø×$Ñ$Ð$ó    c                 óÚ   — |j                  | j                  |«       t        ||   j                  ||   j                  ||   j
                  ||   j                  ||   j                  «      S r   )Úregister_optsr   ÚURIConfigurationSourcer   r   r   r   r   )r   ÚconfÚ
group_names      r   Úopen_source_from_opt_groupz7URIConfigurationSourceDriver.open_source_from_opt_groupz   sk   € Ø×Ñ˜4×0Ñ0°*Ô=ä%ØÑ× Ñ ØÑ×$Ñ$ØÑ×(Ñ(ØÑ×'Ñ'ØÑ×$Ñ$ó&ð 	&r   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚURIOptÚStrOptr   r   r    © r   r   r   r   A   sª   „ ñð$ 	ˆ
‰
ØØ˜WÐ%ØØEð:ô	
ð 	ˆ
‰
ØØ1ð6ô	
ð 	ˆ
‰
ØØIð5ô	
ð 	ˆ
‰
ØðEô	
ð
 	ˆ
‰
ØØð0ô	
ð7"ÐòH%ó&r   r   c                   ó(   — e Zd ZdZ	 	 dd„Zd„ Zd„ Zy)r   aY  A configuration source for remote files served through http[s].

    :param uri: The Uniform Resource Identifier of the configuration to be
          retrieved.

    :param ca_path: The path to a CA_BUNDLE file or directory with
              certificates of trusted CAs.

    :param client_cert: Client side certificate, as a single file path
                  containing either the certificate only or the
                  private key and the certificate.

    :param client_key: Client side private key, in case client_cert is
                 specified but does not includes the private key.
    Nc                 ó®  — || _         t        j                  t        j                  «       «      | _        | j                  |||||«      }t        j                  «       5 }|j                  |j                  d«      «       |j                  «        t        j                  j                  |j                  | j                  «       d d d «       y # 1 sw Y   y xY w)Nzutf-8)Ú_urir   Ú
_NamespaceÚ
ConfigOptsÚ
_namespaceÚ
_fetch_uriÚtempfileÚNamedTemporaryFileÚwriteÚencodeÚflushÚConfigParserÚ_parse_fileÚname)r   r   r   r   r   r   ÚdataÚtmpfiles           r   Ú__init__zURIConfigurationSource.__init__–   s™   € àˆŒ	ÜŸ.™.¬¯©Ó)9Ó:ˆŒà‰˜s G¨[¸*ÀgÓNˆä×(Ñ(Ó*ð 	H¨gØM‰M˜$Ÿ+™+ gÓ.Ô/ØM‰MŒOä×Ñ×(Ñ(¨¯©°t·±ÔG÷		H÷ 	Hñ 	Hús   ÁA%CÃCc                 ó¸   — |r|nd}|r|r||fn|}t        j                  ||||¬«      5 }|j                  «        |j                  cd d d «       S # 1 sw Y   y xY w)NT)ÚverifyÚcertr   )ÚrequestsÚgetÚraise_for_statusÚtext)	r   r   r   r   r   r   r;   r<   Úresponses	            r   r.   z!URIConfigurationSource._fetch_uri£   sa   € á#‘¨ˆÙ,7¹J˜ZÑ(Øð 	ô \‰\˜# f°4Ø")ô+ð 	!Ø.6Ø×%Ñ%Ô'à—=‘=÷		!÷ 	!ò 	!ús   ªAÁAc                 óš   — 	 | j                   j                  ||fg|j                  ¬«      S # t        $ r t        j
                  d fcY S w xY w)N)Úmulti)r-   Ú
_get_valuerC   ÚKeyErrorr   Ú_NoValue)r   r   Úoption_nameÚopts       r   r>   zURIConfigurationSource.get¯   sW   € ð	,Ø—?‘?×-Ñ-Ø˜kÐ*Ð+Ø—i‘ið .ó !ð !øô ò 	,Ü×$Ñ$ dÐ+Ò+ð	,ús   ‚), ¬A
Á	A
)NNNr   )r!   r"   r#   r$   r9   r.   r>   r'   r   r   r   r   …   s!   „ ñð  HLØóHò
!ó,r   r   )
r$   r=   r/   Úoslo_configr   r   ÚConfigurationSourceDriverr   ÚConfigurationSourcer   r'   r   r   ú<module>rL      s@   ðñ,ó\ Û å Ý ôA& 7×#DÑ#Dô A&ôH0,˜W×8Ñ8õ 0,r   