#NEWLINE# @ check_resource #NEWLINE# @ minimum_version ( '1.21' ) #NEWLINE# def connect_container_to_network( self , container , net_id , ipv4_address = None , ipv6_address = None , aliases = None , links = None ) : #NEWLINE# #INDENT# data = { #NEWLINE# #INDENT# 'Container' : container , #NEWLINE# 'EndpointConfig' : { #NEWLINE# #INDENT# 'Aliases' : aliases , #NEWLINE# 'Links' : ( normalize_links ( links ) if links else None ) , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# if ( ipv4_address or ipv6_address ) : #NEWLINE# #INDENT# if version_lt ( net_id . _version , '1.22' ) : #NEWLINE# #INDENT# raise InvalidVersion ( 'IP address assignment is not supported in API version < 1.22' ) #NEWLINE# #UNINDENT# data [ 'EndpointConfig' ] [ 'IPAMConfig' ] = dict ( ) #NEWLINE# if ipv4_address : #NEWLINE# #INDENT# data [ 'EndpointConfig' ] [ 'IPAMConfig' ] [ 'IPv4Address' ] = ipv4_address #NEWLINE# #UNINDENT# if ipv6_address : #NEWLINE# #INDENT# data [ 'EndpointConfig' ] [ 'IPAMConfig' ] [ 'IPv6Address' ] = ipv6_address #NEWLINE# #UNINDENT# #UNINDENT# url = self . _url ( '/networks/{0}/connect' , net_id ) #NEWLINE# res = self . _post_json ( url , data = data ) #NEWLINE# self . _raise_for_status ( res )