class_docstr: Contains helper methods for scheduling events to EventBridge
class_docstr_tok: ["Contains","helper","methods","for","scheduling","events","to","EventBridge"]
docstr: Creates or updates a Schedule for the given pipeline_arn and schedule_expression.
  
  Args:
      schedule_name: The name of the schedule.
      pipeline_arn: The ARN of the sagemaker pipeline that needs to scheduled.
      schedule_expression: The schedule expression.
      state: Specifies whether the schedule is enabled or disabled. Can only
          be ENABLED or DISABLED.
      start_date: The date, in UTC, after which the schedule can begin invoking its target.
      role: The RoleArn used to execute the scheduled events.
  
  Returns:
      schedule_arn: The arn of the schedule.
docstr_tok: ["Creates","or","updates","a","Schedule","for","the","given","pipeline_arn","and","schedule_expression",".","Args",":","schedule_name",":","The","name","of","the","schedule",".","pipeline_arn",":","The","ARN","of","the","sagemaker","pipeline","that","needs","to","scheduled",".","schedule_expression",":","The","schedule","expression",".","state",":","Specifies","whether","the","schedule","is","enabled","or","disabled",".","Can","only","be","ENABLED","or","DISABLED",".","start_date",":","The","date",",","in","UTC",",","after","which","the","schedule","can","begin","invoking","its","target",".","role",":","The","RoleArn","used","to","execute","the","scheduled","events",".","Returns",":","schedule_arn",":","The","arn","of","the","schedule","."]
code: def upsert_schedule(
      self,
      schedule_name: str,
      pipeline_arn: str,
      schedule_expression: str,
      state: str,
      start_date: datetime,
      role: str,
  ) -> Dict:
      """Creates or updates a Schedule for the given pipeline_arn and schedule_expression.
  
      Args:
          schedule_name: The name of the schedule.
          pipeline_arn: The ARN of the sagemaker pipeline that needs to scheduled.
          schedule_expression: The schedule expression.
          state: Specifies whether the schedule is enabled or disabled. Can only
              be ENABLED or DISABLED.
          start_date: The date, in UTC, after which the schedule can begin invoking its target.
          role: The RoleArn used to execute the scheduled events.
  
      Returns:
          schedule_arn: The arn of the schedule.
      """
      pipeline_parameter = dict(
          PipelineParameterList=[
              dict(
                  Name=EXECUTION_TIME_PIPELINE_PARAMETER,
                  Value=EVENT_BRIDGE_INVOCATION_TIME,
              )
          ]
      )
      create_or_update_schedule_request_dict = dict(
          Name=schedule_name,
          ScheduleExpression=schedule_expression,
          FlexibleTimeWindow=NO_FLEXIBLE_TIME_WINDOW,
          Target=dict(
              Arn=pipeline_arn,
              SageMakerPipelineParameters=pipeline_parameter,
              RoleArn=role,
          ),
          State=state,
          StartDate=start_date,
      )
      try:
          return self.event_bridge_scheduler_client.update_schedule(
              **create_or_update_schedule_request_dict
          )
      except ClientError as e:
          if (
              RESOURCE_NOT_FOUND_EXCEPTION
              == e.response["Error"]["Code"]
          ):
              return self.event_bridge_scheduler_client.create_schedule(
                  **create_or_update_schedule_request_dict
              )
          raise e
  
file_path: sagemaker-python-sdk/src/sagemaker/feature_store/feature_processor/_event_bridge_scheduler_helper.py
imports: from __future__ import absolute_import
  import logging
  from datetime import datetime
  from typing import Dict, Optional, Any
  import attr
  from botocore.exceptions import ClientError
  from sagemaker import Session
  from sagemaker.feature_store.feature_processor._constants import EXECUTION_TIME_PIPELINE_PARAMETER, EVENT_BRIDGE_INVOCATION_TIME, NO_FLEXIBLE_TIME_WINDOW, RESOURCE_NOT_FOUND_EXCEPTION
label_desc: Use image node_id 1 for calling the EventBridgeSchedulerHelper obj's underlying member method code with example usage: obj.upsert_schedule(schedule_name, pipeline_arn, schedule_expression, state, start_date, role) and returns: self, self