
                            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
 Z e	j                   e	j"                  j$                         G d de	j&                               Z e	j                   e	j"                  j*                         G d de             Z e	j                   e	j"                  j.                         G d de             Zddde_        y)zCreate resource policy command.    )absolute_import)division)unicode_literals)base_classes)arg_parsers)base)flags)utilc                    t        j                         j                  |        t        j                  |        | j	                  dd       | j	                  dd       | j	                  dd       | j	                  dt
        j                  j                  d	
       | j	                  dt
        j                  j                  d
       y)zA helper function.z
--timezonez
      Timezone used in interpreting schedule. The value of this field must be
      a time zone name from the tz database
      http://en.wikipedia.org/wiki/Tz_database
    )helpz--vm-start-schedulezU
      Schedule for starting the instance, specified using standard CRON format.
    z--vm-stop-schedulezU
      Schedule for stopping the instance, specified using standard CRON format.
    z--initiation-datez`
     The start time of the schedule policy. The timestamp must be
     an RFC3339 valid string.)typer   z
--end-datezbThe expiration time of the schedule policy. The timestamp must be
        an RFC3339 valid string.N)r	   MakeResourcePolicyArgAddArgumentAddCommonArgsadd_argumentr   DatetimeParseparsers    Alib/surface/compute/resource_policies/create/instance_schedule.py_CommonArgsr      s     ++F3f  	 	  	
 	  	 	%%!  " 	%%$  %    c                   &    e Zd ZdZed        Zd Zy)CreateInstanceSchedulePolicy:Create a Compute Engine instance schedule resource policy.c                     t        |        y Nr   r   s    r   Argsz!CreateInstanceSchedulePolicy.ArgsF   
    r   c                    t        j                  | j                               }|j                  }t	        j
                         j                  ||j                  t        j                  |j                              }|j                  j                  }t        j                  |||      }|j                  ||j                  |j                        }|j                  j                   j"                  }|j%                  |d|fg      d   S )N)scope_lister)resourcePolicyprojectregionInsertr   )r   ComputeApiHolderReleaseTrackclientr	   r   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListermessagesr
   MakeInstanceSchedulePolicy$ComputeResourcePoliciesInsertRequestr$   r%   apitools_clientresourcePoliciesMakeRequests)	selfargsholderr)   
policy_refr.   resource_policycreate_requestservices	            r   Runz CreateInstanceSchedulePolicy.RunJ   s    **4+<+<+>?F]]F,,.@@"88G A IJ
 }}%%H55j$6>@OBB&""   C "N
 mm++<<G(N CDEaHHr   N)__name__
__module____qualname____doc__staticmethodr   r;    r   r   r   r   B   s    B Ir   r   c                        e Zd ZdZed        Zy) CreateInstanceSchedulePolicyBetar   c                     t        |        y r   r   r   s    r   r   z%CreateInstanceSchedulePolicyBeta.Argsc   r    r   Nr<   r=   r>   r?   r@   r   rA   r   r   rC   rC   _       B r   rC   c                        e Zd ZdZed        Zy)!CreateInstanceSchedulePolicyAlphar   c                     t        |        y r   r   r   s    r   r   z&CreateInstanceSchedulePolicyAlpha.Argsl   r    r   NrE   rA   r   r   rH   rH   h   rF   r   rH   z;Create a Compute Engine instance schedule resource policy.
a  To create an instance schedule resource policy that has a daily start operation at 8 AM and a daily stop operation at 5 PM for the UTC timezone, run:

  $ {command} my-resource-policy --description="daily policy" --vm-start-schedule="0 8 * * *" --vm-stop-schedule="0 17 * * *" --timezone="UTC" --region=REGION

Use the initiation date and end date to limit when the policy is active. To create an instance schedule resource policy with initiation and end dates, run:

  $ {command} my-resource-policy --description="limited daily policy" --vm-start-schedule="0 8 * * *" --vm-stop-schedule="0 17 * * *" --timezone="UTC" --region=REGION --initiation-date="2021-01-01T00:00:00.000Z" --end-date="2021-02-01T00:00:00.000Z"
)DESCRIPTIONEXAMPLESN)r?   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computer	   r,   4googlecloudsdk.command_lib.compute.resource_policiesr
   r   ReleaseTracksr(   GACreateCommandr   BETArC   ALPHArH   detailed_helprA   r   r   <module>rW      s    & &  ' 7 / ( E F E"%J D%%(()I4#5#5 I *I8 D%%**+'C  , D%%++,(H  -		.  *r   