
                             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  e	j                  dd	ej                  d
e	j                  d      Zd Zd Zd Zd Zd Zd Zy)z=Flags and helpers for the compute os-config related commands.    )absolute_import)division)unicode_literals)
completers)flags)
exceptionsinstanceinstance_namezcompute.instancesF)resource_namename	completerzonal_collectionzone_explanationpluralc                     | j                  dt        dj                  |             | j                  dddj                  |      	       y
)z2Adds flags for os-config update command to parser.PATCH_DEPLOYMENT_IDz        Name of the patch deployment to update.

        To get a list of patch deployments that are available for update, run
        the `gcloud {release_track} compute os-config patch-deployments list`
        command.)release_tracktypehelp--fileTz        The JSON or YAML file with the patch deployment to update. For
        information about the patch deployment format, see https://cloud.google.com/compute/docs/osconfig/rest/{api_version}/projects.patchDeployments.api_versionrequiredr   Nadd_argumentstrformat)parserr   r   s      9lib/googlecloudsdk/command_lib/compute/os_config/flags.pyAddPatchDeploymentsUpdateFlagsr"   #   s]    
 FF7  	 	[ v+v&      c                 |    | j                  dt        d       | j                  dddj                  |             y	)
z2Adds flags for os-config create command to parser.r   z        Name of the patch deployment to create.

        This name must contain only lowercase letters, numbers, and hyphens,
        start with a letter, end with a number or a letter, be between 1-63
        characters, and unique within the project.r   r   Tz        The JSON or YAML file with the patch deployment to create. For
        information about the patch deployment format, see https://cloud.google.com/compute/docs/osconfig/rest/{api_version}/projects.patchDeployments.r   r   Nr   )r    r   s     r!   AddPatchDeploymentsCreateFlagsr%   9   sO    6  	 	[ v+v&  r#   c                     t        | |       | j                  d      } | j                  d      }t        |      dk(  rt	        d |D              ryt        j                  dj                  | |d            )	a  Performs basic syntax check on a zone; doesn't validate whether it exists.

  Args:
    value: str, the zone to validate
    flag_name: str, the flag's name; included in the exception's message

  Raises:
    exceptions.Error: if value is an invalid zone
  zu--   c              3   <   K   | ]  }|j                           y w)N)isalnum).0ps     r!   	<genexpr>zValidateZone.<locals>.<genexpr>\   s     8%QQYY[%s   NzIInvalid value `{value}` for flag {flag_name}. For valid values, see {url}z3https://cloud.google.com/compute/docs/regions-zones)value	flag_nameurl)ValidateFlagNotEmptyremoveprefixsplitlenallr   Errorr   )r.   r/   partss      r!   ValidateZoner8   O   sz     ui(


T
"%
++c
%Z1_8%88
$$*FC %+ %E	F Fr#   c                 8    | st        j                  d|z         y)zEnsures that value is not empty.

  Args:
    value: str, the value to check
    flag_name: str, the flag's name; included in the exception's message

  Raises:
    exceptions.Error: if value is empty
  zMissing required flag Nr   r6   )r.   r/   s     r!   r1   r1   f   s#     



3i?
@@ 
r#   c                 8    | st        j                  d|z         y)a  Performs syntax check on an instance value; doesn't check whether it exists.

  Args:
    value: str, the instance value to check
    param_name: str, the parameter's name; included in the exception's message

  Raises:
    exceptions.Error: if value is empty
  Missing required parameter Nr:   r.   
param_names     r!   ValidateInstancer?   t   #     



8:E
FF 
r#   c                 8    | st        j                  d|z         y)a  Check if os policy assignment id is non-null/empty; doesn't check whether it exists.

  Args:
    value: str, the os policy assignment id value to check
    param_name: str, the parameter's name; included in the exception's message

  Raises:
    exceptions.Error: if value is empty
  r<   Nr:   r=   s     r!   "ValidateInstanceOsPolicyAssignmentrB      r@   r#   N)__doc__
__future__r   r   r   "googlecloudsdk.command_lib.computer   compute_completersr   compute_flagsgooglecloudsdk.corer   ResourceArgumentInstancesCompleterZONE_PROPERTY_EXPLANATIONINSTANCES_ARG_FOR_OS_UPGRADEr"   r%   r8   r1   r?   rB    r#   r!   <module>rN      sr    D &  ' O E *  >}==	 33("<<  ,,F.AGGr#   