@@ -356,6 +356,90 @@ def unassign(
356356 cast_to = FloatingIP ,
357357 )
358358
359+ def create_and_poll (
360+ self ,
361+ * ,
362+ project_id : int | None = None ,
363+ region_id : int | None = None ,
364+ fixed_ip_address : Optional [str ] | NotGiven = NOT_GIVEN ,
365+ port_id : Optional [str ] | NotGiven = NOT_GIVEN ,
366+ tags : Dict [str , str ] | NotGiven = NOT_GIVEN ,
367+ polling_interval_seconds : int | NotGiven = NOT_GIVEN ,
368+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
369+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
370+ # The extra values given here take precedence over values defined on the client or passed to this method.
371+ extra_headers : Headers | None = None ,
372+ extra_query : Query | None = None ,
373+ extra_body : Body | None = None ,
374+ ) -> FloatingIP :
375+ """
376+ Create floating IP and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method.
377+ """
378+ response = self .create (
379+ project_id = project_id ,
380+ region_id = region_id ,
381+ fixed_ip_address = fixed_ip_address ,
382+ port_id = port_id ,
383+ tags = tags ,
384+ extra_headers = extra_headers ,
385+ extra_query = extra_query ,
386+ extra_body = extra_body ,
387+ timeout = timeout ,
388+ )
389+ if not response .tasks :
390+ raise ValueError ("Expected at least one task to be created" )
391+ task = self ._client .cloud .tasks .poll (
392+ task_id = response .tasks [0 ],
393+ extra_headers = extra_headers ,
394+ polling_interval_seconds = polling_interval_seconds ,
395+ )
396+ if task .created_resources is None or task .created_resources .floatingips is None :
397+ raise ValueError ("Task completed but created_resources or floatingips is missing" )
398+ floating_ip_id = task .created_resources .floatingips [0 ]
399+ return self .get (
400+ floating_ip_id = floating_ip_id ,
401+ project_id = project_id ,
402+ region_id = region_id ,
403+ extra_headers = extra_headers ,
404+ extra_query = extra_query ,
405+ extra_body = extra_body ,
406+ timeout = timeout ,
407+ )
408+
409+ def delete_and_poll (
410+ self ,
411+ floating_ip_id : str ,
412+ * ,
413+ project_id : int | None = None ,
414+ region_id : int | None = None ,
415+ polling_interval_seconds : int | NotGiven = NOT_GIVEN ,
416+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
417+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
418+ # The extra values given here take precedence over values defined on the client or passed to this method.
419+ extra_headers : Headers | None = None ,
420+ extra_query : Query | None = None ,
421+ extra_body : Body | None = None ,
422+ ) -> None :
423+ """
424+ Delete floating IP and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method.
425+ """
426+ response = self .delete (
427+ floating_ip_id = floating_ip_id ,
428+ project_id = project_id ,
429+ region_id = region_id ,
430+ extra_headers = extra_headers ,
431+ extra_query = extra_query ,
432+ extra_body = extra_body ,
433+ timeout = timeout ,
434+ )
435+ if not response .tasks :
436+ raise ValueError ("Expected at least one task to be created" )
437+ self ._client .cloud .tasks .poll (
438+ task_id = response .tasks [0 ],
439+ extra_headers = extra_headers ,
440+ polling_interval_seconds = polling_interval_seconds ,
441+ )
442+
359443
360444class AsyncFloatingIPsResource (AsyncAPIResource ):
361445 @cached_property
@@ -687,6 +771,90 @@ async def unassign(
687771 cast_to = FloatingIP ,
688772 )
689773
774+ async def create_and_poll (
775+ self ,
776+ * ,
777+ project_id : int | None = None ,
778+ region_id : int | None = None ,
779+ fixed_ip_address : Optional [str ] | NotGiven = NOT_GIVEN ,
780+ port_id : Optional [str ] | NotGiven = NOT_GIVEN ,
781+ tags : Dict [str , str ] | NotGiven = NOT_GIVEN ,
782+ polling_interval_seconds : int | NotGiven = NOT_GIVEN ,
783+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
784+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
785+ # The extra values given here take precedence over values defined on the client or passed to this method.
786+ extra_headers : Headers | None = None ,
787+ extra_query : Query | None = None ,
788+ extra_body : Body | None = None ,
789+ ) -> FloatingIP :
790+ """
791+ Create floating IP and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method.
792+ """
793+ response = await self .create (
794+ project_id = project_id ,
795+ region_id = region_id ,
796+ fixed_ip_address = fixed_ip_address ,
797+ port_id = port_id ,
798+ tags = tags ,
799+ extra_headers = extra_headers ,
800+ extra_query = extra_query ,
801+ extra_body = extra_body ,
802+ timeout = timeout ,
803+ )
804+ if not response .tasks :
805+ raise ValueError ("Expected at least one task to be created" )
806+ task = await self ._client .cloud .tasks .poll (
807+ task_id = response .tasks [0 ],
808+ extra_headers = extra_headers ,
809+ polling_interval_seconds = polling_interval_seconds ,
810+ )
811+ if task .created_resources is None or task .created_resources .floatingips is None :
812+ raise ValueError ("Task completed but created_resources or floatingips is missing" )
813+ floating_ip_id = task .created_resources .floatingips [0 ]
814+ return await self .get (
815+ floating_ip_id = floating_ip_id ,
816+ project_id = project_id ,
817+ region_id = region_id ,
818+ extra_headers = extra_headers ,
819+ extra_query = extra_query ,
820+ extra_body = extra_body ,
821+ timeout = timeout ,
822+ )
823+
824+ async def delete_and_poll (
825+ self ,
826+ floating_ip_id : str ,
827+ * ,
828+ project_id : int | None = None ,
829+ region_id : int | None = None ,
830+ polling_interval_seconds : int | NotGiven = NOT_GIVEN ,
831+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
832+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
833+ # The extra values given here take precedence over values defined on the client or passed to this method.
834+ extra_headers : Headers | None = None ,
835+ extra_query : Query | None = None ,
836+ extra_body : Body | None = None ,
837+ ) -> None :
838+ """
839+ Delete floating IP and poll for the result. Only the first task will be polled. If you need to poll more tasks, use the `tasks.poll` method.
840+ """
841+ response = await self .delete (
842+ floating_ip_id = floating_ip_id ,
843+ project_id = project_id ,
844+ region_id = region_id ,
845+ extra_headers = extra_headers ,
846+ extra_query = extra_query ,
847+ extra_body = extra_body ,
848+ timeout = timeout ,
849+ )
850+ if not response .tasks :
851+ raise ValueError ("Expected at least one task to be created" )
852+ await self ._client .cloud .tasks .poll (
853+ task_id = response .tasks [0 ],
854+ extra_headers = extra_headers ,
855+ polling_interval_seconds = polling_interval_seconds ,
856+ )
857+
690858
691859class FloatingIPsResourceWithRawResponse :
692860 def __init__ (self , floating_ips : FloatingIPsResource ) -> None :
@@ -710,6 +878,12 @@ def __init__(self, floating_ips: FloatingIPsResource) -> None:
710878 self .unassign = to_raw_response_wrapper (
711879 floating_ips .unassign ,
712880 )
881+ self .create_and_poll = to_raw_response_wrapper (
882+ floating_ips .create_and_poll ,
883+ )
884+ self .delete_and_poll = to_raw_response_wrapper (
885+ floating_ips .delete_and_poll ,
886+ )
713887
714888
715889class AsyncFloatingIPsResourceWithRawResponse :
@@ -734,6 +908,12 @@ def __init__(self, floating_ips: AsyncFloatingIPsResource) -> None:
734908 self .unassign = async_to_raw_response_wrapper (
735909 floating_ips .unassign ,
736910 )
911+ self .create_and_poll = async_to_raw_response_wrapper (
912+ floating_ips .create_and_poll ,
913+ )
914+ self .delete_and_poll = async_to_raw_response_wrapper (
915+ floating_ips .delete_and_poll ,
916+ )
737917
738918
739919class FloatingIPsResourceWithStreamingResponse :
@@ -758,6 +938,12 @@ def __init__(self, floating_ips: FloatingIPsResource) -> None:
758938 self .unassign = to_streamed_response_wrapper (
759939 floating_ips .unassign ,
760940 )
941+ self .create_and_poll = to_streamed_response_wrapper (
942+ floating_ips .create_and_poll ,
943+ )
944+ self .delete_and_poll = to_streamed_response_wrapper (
945+ floating_ips .delete_and_poll ,
946+ )
761947
762948
763949class AsyncFloatingIPsResourceWithStreamingResponse :
@@ -782,3 +968,9 @@ def __init__(self, floating_ips: AsyncFloatingIPsResource) -> None:
782968 self .unassign = async_to_streamed_response_wrapper (
783969 floating_ips .unassign ,
784970 )
971+ self .create_and_poll = async_to_streamed_response_wrapper (
972+ floating_ips .create_and_poll ,
973+ )
974+ self .delete_and_poll = async_to_streamed_response_wrapper (
975+ floating_ips .delete_and_poll ,
976+ )
0 commit comments