
    w/                        d 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 dd	lmZ dd
lmZ ddlmZ ddlmZ ej&                   ej(                  ej*                  j,                         G d dej.                                      Z ej(                  ej*                  j2                  ej*                  j4                        ej&                   G d de                    Zddddde_        y)z$Command to update snapshot settings.    )absolute_import)division)unicode_literals)base_classes)poller)waiter)base)flags)log)
properties)	resourcesc                   0    e Zd ZdZed        Zd Z	 ddZy)UpdateUpdate snapshot settings.c                 d    t        j                  |        | j                  j                  d       y )NzIyaml(storageLocation.policy, storageLocation.locations.list(show="keys")))r
   -AddUpdateSnapshotSettingsStorageLocationFlagsdisplay_info	AddFormatparsers    /lib/surface/compute/snapshot_settings/update.pyArgszUpdate.Args%   s)    	77?
!!	8    c                 $    | j                  |      S )N_Runselfargss     r   Runz
Update.Run-   s    99T?r   c           
      4   t        j                  | j                               }|j                  }|r|j                  rg }|j
                  j                         }|j                  rk|j                  D ]\  }|j                  |j
                  j                  j                  j                  ||j
                  j                  |                   ^ |j                  ri|j                  D ]Z  }|j                  |j
                  j                  j                  j                  ||j
                  j                                      \ |j
                  j                  j                  |      |_        |j                  rT|j
                  j                  j                  |j                  j!                         j#                  dd            }||_        |j&                  j(                  }	|j
                  j+                  |j
                  j-                  |      t.        j0                  j2                  j4                  j7                         |j                  d      }
t8        j:                  j=                  d	j?                  t.        j0                  j2                  j4                  j7                                      |jA                  |	d
|
fgd      d   }tB        jD                  jG                  |jH                  t.        j0                  j2                  j4                  j7                         |j                  dd      }|jJ                  rt9        jL                  |ddd       |S |jB                  jG                  d t.        j0                  j2                  j4                  j6                  |j                  dd      }tO        jP                  |j                  j&                  j(                  |      }tS        jT                  ||dj?                  t.        j0                  j2                  j4                  j7                         |j                  |jW                                      t8        j:                  j=                  dj?                  t.        j0                  j2                  j4                  j7                                      |j&                  j(                  }	|j
                  jY                  t.        j0                  j2                  j4                  j7                         |j                        }|jA                  |	d|fgd      d   }|S |jZ                  rd}n|j\                  rd}nt_        d      |j
                  j-                         }|jZ                  rn|j
                  j`                  j                  |jZ                  j!                         j#                  dd            }|j
                  ja                  |      |_1        |j\                  rte        |j\                        dk7  rt_        d      |j
                  j`                  j                  j                  |j\                  d   |j
                  jg                  |j\                  d               g}|jb                  |j
                  ja                         |_1        |j
                  j`                  j                  |      |jb                  _        |j&                  jh                  }	|j
                  jk                  |t.        j0                  j2                  j4                  j7                         |      }
t8        j:                  j=                  d	j?                  t.        j0                  j2                  j4                  j7                                      |jA                  |	d
|
fgd      d   }tB        jD                  jG                  |jH                  d t.        j0                  j2                  j4                  j7                         id!      }|jJ                  rt9        jL                  |d"dd#       |S |jB                  jG                  d d t.        j0                  j2                  j4                  j6                  id$      }tO        jP                  |j                  j&                  jh                  |      }tS        jT                  ||d%j?                  t.        j0                  j2                  j4                  j7                         |jW                                      t8        j:                  j=                  dj?                  t.        j0                  j2                  j4                  j7                                      |j&                  jh                  }	|j
                  jm                  t.        j0                  j2                  j4                  j7                         &      }|jA                  |	d|fgd      d   }|S )'N)region)keyvalue)additionalProperties-_)accessLocationr(   )snapshotSettingsprojectr"   
updateMaskzRequest issued for: [{0}]PatchT)no_followupr   )r*   r"   zcompute.regionOperations)params
collectionzgce regional snapshot settingszpUse [gcloud compute snapshot-settings describe --region={region}] command to check the status of this operation.)kindis_asyncdetailszcompute.regionSnapshotSettingszJWaiting for operation [projects/{0}/region/{1}/operations/{2}] to completezUpdated compute_project [{0}].GetstorageLocationzstorageLocation.locationsz4Must specify at least one valid parameter to update.)policy   zaInvalid value for [storage_location_names]: only a single location name is permitted at this time)name)r)   r*   r+   r*   zcompute.globalOperationszgce global snapshot settingsz^Use [gcloud compute snapshot-settings describe] command to check the status of this operation.zcompute.snapshotSettingszFWaiting for operation [projects/{0}/global/operations/{1}] to complete)r*   )7r   ComputeApiHolderReleaseTrackclientr"   messagesSnapshotSettingsAccessLocationadd_access_locationsappendLocationsValueAdditionalProperty6SnapshotSettingsAccessLocationAccessLocationPreferenceremove_access_locations	locationsaccess_location_policyPolicyValueValuesEnumupperreplacer5   apitools_clientregionSnapshotSettings)ComputeRegionSnapshotSettingsPatchRequestSnapshotSettingsr   VALUEScorer*   	GetOrFailr   statusPrintformatMakeRequestsr   REGISTRYParser7   async_UpdatedResourcer   Pollerr   WaitForName'ComputeRegionSnapshotSettingsGetRequeststorage_location_policystorage_location_names
ValueError'SnapshotSettingsStorageLocationSettingsr4   len@SnapshotSettingsStorageLocationSettingsStorageLocationPreferencer)   #ComputeSnapshotSettingsPatchRequest!ComputeSnapshotSettingsGetRequest)r   r   support_regionholderr:   new_locations_valuesaccess_locationlocation
new_policyservicepatch_requestresultoperation_refsnap_settings_refoperation_pollerget_requestupdate_maskupdate_snapshot_settingss                     r   r   zUpdate._Run0   s   
 **4+<+<+>?F]]F$++  FFHo		"	"11H

%
%oo<<KK^^^^% _  _  2 
	%	%44H

%
%oo<<KK^^^^` _  5 //
8
8
G
G#7 H   
	$	$__CCYY''--/77SA

 ", &&==gooOO!??;;, <  ##((00::<% P m 
jj
%
,
,$$,,668 ""Wm,
-4 # 	f  ((..
++#**//77AAC 0 / m 
1		
  **00
#**//77AA 6 1   
--
'
'
>
>
 nn

f$$,,668kk  "		 
jj
*
1
1$$,,668 &&==gOOKK##((00::< L k ""UK(
)t # 	f m 
	%	%'&&1OPP!'!A!A!C		%	%__LLbb((..088cB

 OOCC! D  	!0 
	$	$t**+q09 
 OOCCRRee//2ooff44Q7 g  f  
 $33;ooEEG #
2 >D__=t=t  >D  >D!5 >D >
 00:
 &&77gooII3##((00::<  J m
 
jj
%
,
,$$,,668
 ""Wm,
-4 # 	f  ((..
++**//77AAC 0 / m 
/7	
  **00
**//77AA 0 1   
--
'
'
8
8
 nn

f$$,,668-:L:L:N	 
jj
*
1
1$$,,668 &&77gOOEE##((00::< F k ""UK(
)t # 	f mr   N)F)__name__
__module____qualname____doc__staticmethodr   r    r    r   r   r   r       s)     "  nr   r   c                   &    e Zd ZdZed        Zd Zy)UpdateAlphaAndBetar   c                     t        j                  |        t        j                  |        t        j                  |        | j                  j                  d       y )Nzyaml(accessLocation.policy,accessLocation.locations.list(show="keys"),storageLocation.policy,storageLocation.locations.list(show="keys")))r
   ,AddUpdateSnapshotSettingsAccessLocationFlagsr   AddSnapshotSettingArgr   r   r   s    r   r   zUpdateAlphaAndBeta.Args&  sE    	66v>	77?	'
!!	7r   c                 (    | j                  |d      S )NT)rc   r   r   s     r   r    zUpdateAlphaAndBeta.Run1  s    99   r   N)rr   rs   rt   ru   rv   r   r    rw   r   r   ry   ry   !  s     " r   ry   r   z7      Update the snapshot settings of a project.
      a      To update the snapshot settings and set the storage location policy to the
    nearest multi-region as the source disk, run:

          $ {command} --storage-location-policy=nearest-multi-region

    To update the snapshot settings and set the storage location policy to the
    same region as the source disk, run:

          $ {command} --storage-location-policy=local-region

    To update the snapshot settings and set the storage location policy to
    store snapshots in a specific location like `us-west1`, run:

          $ {command} --storage-location-policy=specific-locations               --storage-location-names=us-west1
     z      This command uses the compute/alpha or compute/beta or compute/v1 API. The full documentation for this API
     can be found at: https://cloud.google.com/compute/)briefDESCRIPTIONEXAMPLESzAPI REFERENCEN)ru   
__future__r   r   r   googlecloudsdk.api_lib.computer   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   4googlecloudsdk.command_lib.compute.snapshot_settingsr
   googlecloudsdk.corer   r   r   UniverseCompatibleReleaseTracksr9   GAUpdateCommandr   ALPHABETAry   detailed_helprw   r   r   <module>r      s     + &  ' 7 < . ( F # * ) D%%(()|T | * |~ D%%++T->->-C-CD   E, )
	";- r   