Ë
    ûûàg‘  ã                   óâ   — d dl Z d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ  G d	„ d
«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)é    N)Úgettext_lazy)Ú
exceptions)Úunicode_http_header©Ú_reverse)Úapi_settings)Úreplace_query_param)Ú
_MediaTypec                   óh   — e Zd Zej                  Zej                  Zej                  Z	d„ Z
dd„Zd„ Zy)ÚBaseVersioningc                 ód   — d}t        |j                  | j                  j                  ¬«      «      ‚)Nz.{cls}.determine_version() must be implemented.)Úcls)ÚNotImplementedErrorÚformatÚ	__class__Ú__name__)ÚselfÚrequestÚargsÚkwargsÚmsgs        úW/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/rest_framework/versioning.pyÚdetermine_versionz BaseVersioning.determine_version   s1   € Ø>ˆÜ! #§*¡*Ø—‘×'Ñ'ð #-ó #
ó ð 	ó    Nc                 ó"   — t        |||||fi |¤ŽS ©Nr   )r   Úviewnamer   r   r   r   Úextras          r   ÚreversezBaseVersioning.reverse   s   € Ü˜ $¨°¸ÑIÀ5ÑIÐIr   c                 óf   — | j                   sy|d uxr || j                  k(  xs || j                   v S )NT)Úallowed_versionsÚdefault_version)r   Úversions     r   Úis_allowed_versionz!BaseVersioning.is_allowed_version   s>   € Ø×$Ò$ØØ Ð$ÒH¨°D×4HÑ4HÑ)Hò 3Ø˜D×1Ñ1Ð1ð	4r   ©NNNN)r   Ú
__module__Ú__qualname__r   ÚDEFAULT_VERSIONr"   ÚALLOWED_VERSIONSr!   ÚVERSION_PARAMÚversion_paramr   r   r$   © r   r   r   r      s4   „ Ø"×2Ñ2€OØ#×4Ñ4ÐØ ×.Ñ.€MòóJó4r   r   c                   ó&   — e Zd ZdZ ed«      Zd„ Zy)ÚAcceptHeaderVersioningzb
    GET /something/ HTTP/1.1
    Host: example.com
    Accept: application/json; version=1.0
    z#Invalid version in "Accept" header.c                 ó  — t        |j                  «      }|j                  j                  | j                  | j
                  «      }t        |«      }| j                  |«      st        j                  | j                  «      ‚|S r   )r
   Úaccepted_media_typeÚparamsÚgetr+   r"   r   r$   r   ÚNotAcceptableÚinvalid_version_message)r   r   r   r   Ú
media_typer#   s         r   r   z(AcceptHeaderVersioning.determine_version*   sj   € Ü × ;Ñ ;Ó<ˆ
Ø×#Ñ#×'Ñ'¨×(:Ñ(:¸D×<PÑ<PÓQˆÜ% gÓ.ˆØ×&Ñ& wÔ/Ü×*Ñ*¨4×+GÑ+GÓHÐHØˆr   N)r   r&   r'   Ú__doc__Ú_r4   r   r,   r   r   r.   r.   "   s   „ ññ
  Ð EÓFÐór   r.   c                   ó:   ‡ — e Zd ZdZ ed«      Zd„ Zdˆ fd„	Zˆ xZS )ÚURLPathVersioninga8  
    To the client this is the same style as `NamespaceVersioning`.
    The difference is in the backend - this implementation uses
    Django's URL keyword arguments to determine the version.

    An example URL conf for two views that accept two different versions.

    urlpatterns = [
        re_path(r'^(?P<version>[v1|v2]+)/users/$', users_list, name='users-list'),
        re_path(r'^(?P<version>[v1|v2]+)/users/(?P<pk>[0-9]+)/$', users_detail, name='users-detail')
    ]

    GET /1.0/something/ HTTP/1.1
    Host: example.com
    Accept: application/json
    zInvalid version in URL path.c                 óÎ   — |j                  | j                  | j                  «      }|€| j                  }| j                  |«      st	        j
                  | j                  «      ‚|S r   )r2   r+   r"   r$   r   ÚNotFoundr4   ©r   r   r   r   r#   s        r   r   z#URLPathVersioning.determine_versionI   sX   € Ø—*‘*˜T×/Ñ/°×1EÑ1EÓFˆØˆ?Ø×*Ñ*ˆGà×&Ñ& wÔ/Ü×%Ñ% d×&BÑ&BÓCÐCØˆr   c                 ó€   •— |j                   �| j                  |j                   i|xs i ¥}t        ‰| �  |||||fi |¤ŽS r   )r#   r+   Úsuperr   ©r   r   r   r   r   r   r   r   s          €r   r   zURLPathVersioning.reverseR   sU   ø€ Ø�?‰?Ð&à×"Ñ" G§O¡Oðà’<˜RðˆFô
 ‰w‰Ø�d˜F G¨Vñ
Ø7<ñ
ð 	
r   r%   ©	r   r&   r'   r6   r7   r4   r   r   Ú__classcell__©r   s   @r   r9   r9   6   s%   ø„ ññ   Ð >Ó?Ðò÷	
ñ 	
r   r9   c                   ó@   ‡ — e Zd ZdZ ed«      Zd„ Zdˆ fd„	Zd„ Zˆ xZ	S )ÚNamespaceVersioninga£  
    To the client this is the same style as `URLPathVersioning`.
    The difference is in the backend - this implementation uses
    Django's URL namespaces to determine the version.

    An example URL conf that is namespaced into two separate versions

    # users/urls.py
    urlpatterns = [
        path('/users/', users_list, name='users-list'),
        path('/users/<int:pk>/', users_detail, name='users-detail')
    ]

    # urls.py
    urlpatterns = [
        path('v1/', include('users.urls', namespace='v1')),
        path('v2/', include('users.urls', namespace='v2'))
    ]

    GET /1.0/something/ HTTP/1.1
    Host: example.com
    Accept: application/json
    zBInvalid version in URL path. Does not match any version namespace.c                 óü   — t        |dd «      }|�|j                  s| j                  S |j                  j                  d«      }|D ]  }| j	                  |«      sŒ|c S  t        j                  | j                  «      ‚)NÚresolver_matchú:)ÚgetattrÚ	namespacer"   Úsplitr$   r   r;   r4   )r   r   r   r   rF   Úpossible_versionsr#   s          r   r   z%NamespaceVersioning.determine_versionx   s   € Ü  Ð*:¸DÓAˆØÐ!¨×)AÒ)AØ×'Ñ'Ð'ð +×4Ñ4×:Ñ:¸3Ó?ÐØ(ò 	ˆGØ×&Ñ& wÕ/Ø’ð	ô ×!Ñ! $×">Ñ">Ó?Ð?r   c                 óh   •— |j                   �| j                  ||«      }t        ‰| �  |||||fi |¤ŽS r   )r#   Úget_versioned_viewnamer>   r   r?   s          €r   r   zNamespaceVersioning.reverse„   sC   ø€ Ø�?‰?Ð&Ø×2Ñ2°8¸WÓEˆHÜ‰w‰Ø�d˜F G¨Vñ
Ø7<ñ
ð 	
r   c                 ó&   — |j                   dz   |z   S )NrG   )r#   )r   r   r   s      r   rM   z*NamespaceVersioning.get_versioned_viewname‹   s   € Ø�‰ Ñ$ xÑ/Ð/r   r%   )
r   r&   r'   r6   r7   r4   r   r   rM   rA   rB   s   @r   rD   rD   ^   s&   ø„ ññ.  Ð dÓeÐò
@õ
ö0r   rD   c                   óJ   — e Zd ZdZ ej
                  d«      Z ed«      Zd„ Z	y)ÚHostNameVersioningzX
    GET /something/ HTTP/1.1
    Host: v1.example.com
    Accept: application/json
    z,^([a-zA-Z0-9]+)\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+$zInvalid version in hostname.c                 ó   — |j                  «       j                  d«      \  }}}| j                  j                  |«      }|s| j                  S |j                  d«      }| j                  |«      st        j                  | j                  «      ‚|S )NrG   é   )
Úget_hostÚ	partitionÚhostname_regexÚmatchr"   Úgroupr$   r   r;   r4   )	r   r   r   r   ÚhostnameÚ	separatorÚportrV   r#   s	            r   r   z$HostNameVersioning.determine_version˜   s~   € Ø$+×$4Ñ$4Ó$6×$@Ñ$@ÀÓ$EÑ!ˆ�)˜TØ×#Ñ#×)Ñ)¨(Ó3ˆÙØ×'Ñ'Ð'Ø—+‘+˜a“.ˆØ×&Ñ& wÔ/Ü×%Ñ% d×&BÑ&BÓCÐCØˆr   N)
r   r&   r'   r6   ÚreÚcompilerU   r7   r4   r   r,   r   r   rP   rP   �   s+   „ ñð
  �R—Z‘ZÐ OÓP€NÙÐ >Ó?Ðór   rP   c                   ó:   ‡ — e Zd ZdZ ed«      Zd„ Zdˆ fd„	Zˆ xZS )ÚQueryParameterVersioningza
    GET /something/?version=0.1 HTTP/1.1
    Host: example.com
    Accept: application/json
    z#Invalid version in query parameter.c                 óÆ   — |j                   j                  | j                  | j                  «      }| j	                  |«      st        j                  | j                  «      ‚|S r   )Úquery_paramsr2   r+   r"   r$   r   r;   r4   r<   s        r   r   z*QueryParameterVersioning.determine_version®   sP   € Ø×&Ñ&×*Ñ*¨4×+=Ñ+=¸t×?SÑ?SÓTˆØ×&Ñ& wÔ/Ü×%Ñ% d×&BÑ&BÓCÐCØˆr   c                 óŠ   •— t        ‰| �  |||||fi |¤Ž}|j                  �!t        || j                  |j                  «      S |S r   )r>   r   r#   r	   r+   )	r   r   r   r   r   r   r   Úurlr   s	           €r   r   z QueryParameterVersioning.reverse´   sN   ø€ Ü‰g‰oØ�d˜F G¨Vñ
Ø7<ñ
ˆð �?‰?Ð&Ü& s¨D×,>Ñ,>ÀÇÁÓPÐPØˆ
r   r%   r@   rB   s   @r   r^   r^   ¦   s%   ø„ ññ
  Ð EÓFÐò÷ñ r   r^   )r[   Údjango.utils.translationr   r7   Úrest_frameworkr   Úrest_framework.compatr   Úrest_framework.reverser   Úrest_framework.settingsr   Ú*rest_framework.templatetags.rest_frameworkr	   Úrest_framework.utils.mediatypesr
   r   r.   r9   rD   rP   r^   r,   r   r   ú<module>rj      se   ðÛ 	å 6å %Ý 5Ý +Ý 0Ý JÝ 6÷4ñ 4ô*˜^ô ô(%
˜ô %
ôP.0˜.ô .0ôb˜ô ô.˜~õ r   