
    a                     F    d Z ddlZddlZddlmZ ddlmZ  G d de      Zy)zInterconnect Attachment.    N)encoding)logc                   
   e Zd ZdZi dddddddd	d
ddddddddddddddddddddddddd	dddddddddd 	Z ej                  e      Zej                  d!d!d"       d#d$d%d&Z	d9d(Z
ed)        Zed*        Zd+ Z	 	 	 	 	 	 	 	 	 	 	 	 d:d,Zd- Zd. Zd/ Zd0 Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d;d1Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d<d2Zd=d3Zd>d4Zd?d5Zd=d6Z	 	 	 	 	 d@d7Z	 	 d>d8Zy')AInterconnectAttachmentz+Abstracts Interconnect attachment resource.zbps-50mBPS_50Mzbps-100mBPS_100Mzbps-200mBPS_200Mzbps-300mBPS_300Mzbps-400mBPS_400Mzbps-500mBPS_500Mzbps-1gBPS_1Gzbps-2gBPS_2Gzbps-5gBPS_5Gzbps-10gBPS_10Gzbps-20gBPS_20Gzbps-50gBPS_50Gzbps-100gBPS_100G50m100m200m300m)	400m500m1g2g5g10g20g50g100gBPS_400G)zbps-400g400gAVAILABILITY_DOMAIN_1AVAILABILITY_DOMAIN_2AVAILABILITY_DOMAIN_ANY)zavailability-domain-1zavailability-domain-2anyNc                      || _         || _        y N)ref_compute_client)selfr)   compute_clients      Flib/googlecloudsdk/api_lib/compute/interconnects/attachments/client.py__init__zInterconnectAttachment.__init__D   s    DH)D    c                 .    | j                   j                  S r(   )r*   apitools_clientr+   s    r-   _clientzInterconnectAttachment._clientH   s    ///r/   c                 .    | j                   j                  S r(   )r*   messagesr2   s    r-   	_messagesz InterconnectAttachment._messagesL   s    (((r/   c                 V   d}||j                         }d} ||j                         } | j                  j                  | j                  j	                         ||| ||||||	|
||      }!|||!_        |*| j                  j                  j                  |      |!_        |||!_        |*| j                  j                  j                  |      |!_
        |||!_        |||!_        |||!_        |||!_        |||!_        |||!_        |||!_        |||!_        |||!_        |J|!j(                  | j                  j+                         |!_        |j                         |!j(                  _        |<|!j(                  | j                  j+                         |!_        ||!j(                  _        |+| j                  j1                  |      |!j(                  _        |||!j(                  _        |^| j6                  j8                  d| j                  j;                  | j                  j<                  | j                  j>                  ||!      fS | j6                  j8                  d| j                  j;                  | j                  j<                  | j                  j>                  |!      fS )z/Make an interconnect attachment insert request.N)namedescriptioninterconnectroutertypeedgeAvailabilityDomainadminEnabled	bandwidth
pairingKeyvlanTag8021qcandidateSubnetspartnerMetadata
partnerAsnvniInsert)projectregionvalidateOnlyinterconnectAttachmentrH   rI   rK   ) SelfLinkr6   r   r)   NamemtuEncryptionValueValuesEnum
encryptionipsecInternalAddressesStackTypeValueValuesEnum	stackTypecandidateIpv6SubnetscloudRouterIpv6InterfaceIdcustomerRouterIpv6InterfaceIdsubnetLengthmulticastEnabledcandidateCloudRouterIpAddress candidateCustomerRouterIpAddresscandidateCloudRouterIpv6Address"candidateCustomerRouterIpv6Addressl2Forwarding"InterconnectAttachmentL2ForwardingnetworktunnelEndpointIpAddress.InterconnectAttachmentL2ForwardingGeneveHeadergeneveHeaderdefaultApplianceIpAddressr3   interconnectAttachments+ComputeInterconnectAttachmentsInsertRequestrH   rI   )"r+   r9   r:   r;   attachment_typeedge_availability_domainadmin_enabledr?   pairing_keyvlan_tag_802_1qcandidate_subnetspartner_metadatapartner_asnvalidate_onlyrO   rQ   ipsec_internal_addresses
stack_typecandidate_ipv6_subnetscloud_router_ipv6_interface_id!customer_router_ipv6_interface_idsubnet_lengthmulticast_enabled!candidate_cloud_router_ip_address$candidate_customer_router_ip_address#candidate_cloud_router_ipv6_address&candidate_customer_router_ipv6_addressr`   
geneve_vnidefault_appliance_ip_addresstunnel_endpoint_ip_addressinterconnect_self_linkrouter_self_link
attachments"                                     r-   _MakeCreateRequestTuplez.InterconnectAttachment._MakeCreateRequestTupleP   s   D "+446*66XX]]_+7"$*( 7  J jn
..
/
/
I
I   +*Bj'
..
/
/
H
H 
 )(>j%%1.Lj+(4
+ .   -j$$5j!(4
+ . ,7
. 1 +6
- 0 .9
0 3 		 	 	(NN==? 	 )0(8(8(:j%!-		 	 	(NN==? 	 % 5 
..
G
G H  *
 $/
& 7  ll22HnnHH((**,)3	 I 56 6 LL00(NNFF((xx'1 G 34 4r/   c                    | j                   j                  | j                  j                         ||||      }|||_        |*| j                   j                  j                  |      |_        |
|
|_        |||_        |||_	        |||_
        |	|	|_        |||_        |||_        |||_        |V|j                  J| j                   j!                         |_        | j                   j#                  |      |j                  _        |<|j                  | j                   j!                         |_        ||j                  _        | j(                  j*                  d| j                   j-                  | j                  j.                  | j                  j0                  | j                  j                         |      fS )z.Make an interconnect attachment patch request.)r8   r9   r>   r?   rC   rE   PatchrH   rI   rK   interconnectAttachmentResource)r6   r   r)   rN   rO   rS   rT   labelslabelFingerprintrU   rV   rW   rY   r\   r]   r^   r_   rb   rc   rd   r3   re   *ComputeInterconnectAttachmentsPatchRequestrH   rI   )r+   r9   ri   r?   rm   rO   rq   rr   rs   rt   r   label_fingerprintrv   ry   rz   r{   r|   interconnect_attachments                     r-   _MakePatchRequestTuplez-InterconnectAttachment._MakePatchRequestTuple   s   ( #nnCCXX]]_"( D * $'!
..
/
/
H
H '
 '-$$1B.)5K2%1
( 8 )4
+ ; $1B.*6
- = .9
0 @ 	 	-	-	5NN==? 	 , NNII J  	 ,,9
 $/	 	-	-	5NN==? 	 , ' **D LL00'NNEE((xx'+xx}}/F	 F HI Ir/   c                     | j                   j                  d| j                  j                  | j                  j
                  | j                  j                  | j                  j                               fS )NGetrL   )r3   re   r6   (ComputeInterconnectAttachmentsGetRequestr)   rH   rI   rN   r2   s    r-   _MakeDescribeRequestTuplez0InterconnectAttachment._MakeDescribeRequestTuple*  sX    LL00%NNCC((xx'+xx}} D 89 9r/   c                     | j                   j                  d| j                  j                  | j                  j
                  | j                  j                  | j                  j                               fS )NDeleterL   )r3   re   r6   +ComputeInterconnectAttachmentsDeleteRequestr)   rH   rI   rN   r2   s    r-   _MakeDeleteRequestTuplez.InterconnectAttachment._MakeDeleteRequestTuple1  sX    LL00(NNFF((xx'+xx}} G 89 9r/   c                 |   | j                   j                  | j                  j                         | j                   j	                  | j                   j                  j                  | j                   j                  j
                  j                  || j                   j                  |g |            g                  }|D ]  }|j                  j                  j                  d   j                  j                  j                  | j                   j                  |j                  dg       |j                  dd	      
              | j                   j"                  d| j                   j%                  | j                  j&                  | j                  j(                  | j                  j                         |      fS )>Make an interconnect attachment patch request for L2 mappings.applianceIpAddressinnerVlanToApplianceMappingsr8   keyvalueadditionalPropertiesapplianceMappingsr8   r^   r   innerVlanTagsinnerApplianceIpAddress r   r   r   r   )r6   r   r)   rN   r_   ApplianceMappingsValueAdditionalProperty2InterconnectAttachmentL2ForwardingApplianceMappingr^   r   r   r   r   appendMInterconnectAttachmentL2ForwardingApplianceMappingInnerVlanToApplianceMappinggetr3   re   r   rH   rI   )r+   vlan_keyappliance_nameappliance_ip_address inner_vlan_to_appliance_mappingsr   inner_mappings          r-   _MakePatchMappingRequestTuplez4InterconnectAttachment._MakePatchMappingRequestTuple8  s    66XX]]_^^FF"nnOOffNNEE\\oo$"nn__/C9;!/ `  p 	& g  G 
 7 J$ ://DD
**66
..
f
f)--orB&3&7&7+R' g , : 	,,AAHH$$88??#'88==?+5	 	B 	
	 	r/   c                     d } fd} t        j                  ||       j                  j                  j                          j                  j                   j                  j                          j                  j                   j                  j                  j	                   j                  j                  j                  j                  |d      g                  } j                  j                  d	 j                  j                   j                  j                   j                  j                   j                  j                         |
      fS )r   c           	          d }t        j                  | j                  D ci c]-  }|j                  |j                  r ||j                        nd / c}      S c c}w )Nc                 
   i }| j                   | j                   |d<   | j                  | j                  |d<   g |d<   | j                  D ]6  }|d   j                  t	        |j
                        |j                  d       8 |S )Nr   r8   r   r   )r   r8   r   r   listr   r   )messagemappingr   s      r-   _EncodeApplianceMappingszrInterconnectAttachment._MakeRemoveMappingRequestTuple.<locals>._NullValueEncoder.<locals>._EncodeApplianceMappingso  s    %%1*1*D*D'&
'<<##LL'&/24./$AAM
0
1
8
8#M$?$?@)6)N)N:  B r/   )jsondumpsr   r   r   )r   r   propertys      r-   _NullValueEncoderzPInterconnectAttachment._MakeRemoveMappingRequestTuple.<locals>._NullValueEncodern  sg    " ZZ "66 7h ,, 'x~~6
 7 	 	 s   2Ac                 D   fd}t        j                  |       }j                  j                  j	                  |j                         D cg c]@  \  }}j                  j                  j                  j                  ||r ||      nd       B c}}      S c c}}w )Nc           
      ^   j                   j                  | j                  dd       g | j                  dd             }| j                  dg       D ]X  }|j                  j	                  j                   j                  |j                  dg       |j                  dd                   Z |S )	Nr   r8   r   r   r   r   r   r   )r6   r   r   r   r   r   )datar   r   r+   s      r-   _DecodeApplianceMappingszrInterconnectAttachment._MakeRemoveMappingRequestTuple.<locals>._NullValueDecoder.<locals>._DecodeApplianceMappings  s    NNMM#'88,@$#G-/XXfd+ N  	 "XX&DbIM

,
,
3
3nnjj - 1 1/2 F*7*;*;/+ k  J r/   r   r   )r   loadsr6   r_   r   itemsr   )r   r   	py_objectr   r   r+   s        r-   _NullValueDecoderzPInterconnectAttachment._MakeRemoveMappingRequestTuple.<locals>._NullValueDecoder  s    & **T"i^^>>UU !* 1 
 !2*#u	 nn??VVii;@07d j  !2  V   s   AB
)encoderdecoderNr   r   r   r   r   r   )r   RegisterCustomMessageCodecr6   r_   r   r   r)   rN   r   r3   re   r   rH   rI   )r+   r   r   r   r   s   `    r-   _MakeRemoveMappingRequestTuplez5InterconnectAttachment._MakeRemoveMappingRequestTuplei  s'   
	6>H''!+<
nn77NNP 66XX]]_^^FF"nnOOffNNEE\\oo$" p & g  G 	
 7 J 	,,AAHH$$88??#'88==?+5	 	B 	
	 	r/   c#                     |2| j                   j                  j                  | j                  |         }|B|"r| j                  n| j
                  }#| j                   j                  j                  |#|         }|%| j                   j                  j                  |      }|||| j                   j                  |||      }$nd}$|
g }
 | j                  |||||||||	|
|$|||||||||||||||||| |!      g}%|sA| j                  j                  |%      }&|rt        j                  j                  d       |&d   S |%S )z!Create an interconnectAttachment.NinterconnectNamepartnerName	portalUrlzValidation was successful.r   )r6   r   %EdgeAvailabilityDomainValueValuesEnum$_EDGE_AVAILABILITY_DOMAIN_CONVERSION_BANDWIDTH_CONVERSION_WITH_400G_BANDWIDTH_CONVERSIONBandwidthValueValuesEnumTypeValueValuesEnum%InterconnectAttachmentPartnerMetadatar   r*   MakeRequestsr   statusPrint)'r+   r9   r:   r;   rg   rh   ri   r?   rj   rk   rl   partner_namepartner_interconnectpartner_portal_urlrn   rO   rQ   rp   rq   rr   rs   rt   ru   rv   only_generate_requestro   rw   rx   ry   rz   r`   r{   r|   r}   supports_400gbandwidth_optionsrm   requests	resourcess'                                          r-   CreatezInterconnectAttachment.Create  s   L  +!%!F!F!l!l

3
34L
M"   
.
.))  ..
/
/
H
H	* 
 "
..
/
/
C
C  	(L,D&MM/"& N (
  $$$$$"*--0/2(&=	
!HD !&&33H=i	

56q\Or/   c                 b   |rB|r| j                   n| j                  }| j                  j                  j	                  ||         }|||| j                  j                  |||      }nd}| j                  ||||||	|
|||||||||      g}|s | j                  j                  |      }|d   S |S )z Patch an interconnectAttachment.Nr   r   )	r   r   r6   r   r   r   r   r*   r   )r+   r9   ri   r?   r   r   r   r   r   rq   rr   rs   rt   r   rO   rv   ry   rz   r{   r|   r   r   rm   r   r   s                            r-   r   zInterconnectAttachment.Patch1  s    0   
.
.))  ..
/
/
H
H	* 
 	(L,D&MM/"& N (
 ##"*-/2(!	
H( !&&33H=iq\Or/   c                 l    | j                         g}|s | j                  j                  |      }|d   S |S )Nr   )r   r*   r   )r+   r   r   r   s       r-   DescribezInterconnectAttachment.Describeu  s;    ..01H &&33H=iq\Or/   c                    | j                         g}|r|S t        | j                  j                  |      d   dd      }t        |dd      }t        |dg       }|0|D ]+  }|j                  |k(  s|j                  |j
                  ic S  i S )z5Describe an interconnect attachment L2 inner mapping.r   r^   Nr   r   )r   getattrr*   r   r   r   )r+   r   r   r   l2_forwardingappliance_mappingr   r   s           r-   DescribeMappingz&InterconnectAttachment.DescribeMapping|  s    ..01Ho))(3A6M  /BDI-/ErJM"';;("++w}}-
- # Ir/   c                 ^   | j                         g}|r|S t        | j                  j                  |      d   dd      }t        |dd      }t        |dg       }|r|S g }|D ]I  }|j	                  |j
                  |j                  j                  |j                  j                  d       K |S )z3List all interconnect attachment L2 inner mappings.r   r^   Nr   r   )r   r8   r   )	r   r   r*   r   r   r   r   r8   r   )	r+   is_jsonr   r   r   r   r   list_resultsr   s	            r-   ListMappingz"InterconnectAttachment.ListMapping  s    ..01Ho))(3A6M  /BDI-/ErJML --$$%,]]%E%E 	 ! r/   c                 b    | j                         g}|s| j                  j                  |      S |S r(   )r   r*   r   )r+   r   r   s      r-   r   zInterconnectAttachment.Delete  s2    ,,./H !!..x88Or/   c                 |    |g }| j                  ||||      g}|s | j                  j                  |      }|d   S |S )z2Add an interconnectAttachmen L2 appliance mapping.r   )r   r*   r   )r+   r   r   r   r   r   r   r   s           r-   UpdateMappingz$InterconnectAttachment.UpdateMapping  s[     (/)+&** ,		
H !&&33H=iq\Or/   c                 n    | j                  |      g}|s | j                  j                  |      }|d   S |S )z6Remove an interconnectAttachment L2 appliance mapping.r   )r   r*   r   )r+   r   r   r   r   s        r-   RemoveMappingz$InterconnectAttachment.RemoveMapping  sF     	++	
H
 !&&33H=iq\Or/   r(   )NNNNNNNNNNNN)"r   NNNNNNNNNNNNNNNNNNNNNNFNNNNNNNNNF)r   NNNNNNNNNNNFNNNNNNF)F)NF)FF)NNNNF)__name__
__module____qualname____doc__r   copydeepcopyr   updater   r.   r   r3   r6   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r/   r-   r   r      s   3* * *	
 * *       * Y j  j!" j#$ 5: %2DMM2G$H!!((*   76&*&* 0 0 ) )E4Z !%)(,*.-1#'#QIf99/bZ| #
#!%)(,!(,+/*.-1#'!%Gj\ !%)(,!
*.-1#'+BH". '+!4 !r/   r   )	r   r   r   apitools.base.pyr   googlecloudsdk.corer   objectr   r   r/   r-   <module>r      s$       % #x
V x
r/   