
                         J   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 ej                   Ze	j"                  Zd
ddZej&                   ej(                  ej*                  j,                         G d dej.                                      Zee_        y)z'Create command for Workbench Schedules.    )util)	schedules)base)parser_arguments)parser_extensions)endpoint_util)flags)logzJ
        Create a schedule to run a Workbench notebook execution job.
    al  
      To create a schedule in region `us-central1` with the following schedule properties:
        - display name: `my-schedule`,
        - cron schedule: `TZ=America/Los_Angeles * * * * *`,
        - maximum concurrent runs allowed: 1,
        - start time: 2025-01-01T00:00:00-06:00,

      for a notebook execution job:
        - with display name `my-execution`,
        - running notebook file from Cloud Storage URI `gs://my-bucket/my-notebook.ipynb`,
        - running with service account `my-service-account@my-project.iam.gserviceaccount.com`,
        - with results uploaded to Cloud Storage bucket `gs://my-bucket/results`
        - with machine type `n1-standard-4`,

      Run the following command:
        $ {command} --region=us-central1 --display-name=my-schedule --cron-schedule='TZ=America/Los_Angeles * * * * *' --max-concurrent-runs=1 --start-time=2025-01-01T00:00:00-06:00 --execution-display-name=my-execution --gcs-notebook-uri=gs://my-bucket/my-notebook.ipynb --service-account=my-service-account@my-project.iam.gserviceaccount.com --gcs-output-uri=gs://my-bucket/results --machine-type=n1-standard-4
    )DESCRIPTIONEXAMPLESc                   2    e Zd ZdZedefd       ZdefdZy)CreatezCreate a schedule.parserc                 4    t        j                  | dd       y)z^Register flags for this command.

    Args:
      parser: argparse parser for the command
    FT)	is_updatefor_workbenchN)r	   AddCreateOrUpdateScheduleFlags)r   s    )lib/surface/workbench/schedules/create.pyArgszCreate.Args<   s     
((%t    argsc                    | j                         }t        j                  | j                               }|j                  j                  j                         }|j                         d   }t        j                  d|      5  t        j                  |      }|j                  }|j                  t        j                  ||d            }t        j                  |j                   d       |cddd       S # 1 sw Y   yxY w)	zThis is what gets called when the user runs this command.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      The API response for creating the schedule.
    locationsIdBETA)versionregionT)r   schedule)resourcekindN)ReleaseTrackr   GetMessagesCONCEPTSr   ParseAsDictr   AiplatformEndpointOverrides	GetClientprojects_locations_schedulesr   schedules_utilCreateScheduleCreateRequestr
   CreatedResourcename)	selfr   release_trackmessages
region_refr   
api_clientschedules_servicer   s	            r   Runz
Create.RunG   s     %%'M 1 1 34H%%++-J /F		2	2v
 >>-0j$AA"))

4
4HDh
 
8==zB
 
 
s   A+C77D N)	__name__
__module____qualname____doc__staticmethodArgumentInterceptorr   	Namespacer2    r   r   r   r   7   s-     &  i r   r   N)r6   'googlecloudsdk.api_lib.colab_enterpriser   (googlecloudsdk.api_lib.notebook_executorr   r(   googlecloudsdk.callioper   r   r   googlecloudsdk.command_lib.air   ,googlecloudsdk.command_lib.notebook_executorr	   googlecloudsdk.corer
   r8   r9   _DETAILED_HELPDefaultUniverseOnlyReleaseTracksr    r   CreateCommandr   detailed_helpr:   r   r   <module>rF      s     . 8 P ( 4 5 7 > # ':: ''		0 D%%**+'T ' , 'T & r   