go.uber.org/cadence@v1.2.9/internal/compatibility/proto/request.go (about)

     1  // Copyright (c) 2021 Uber Technologies, Inc.
     2  //
     3  // Permission is hereby granted, free of charge, to any person obtaining a copy
     4  // of this software and associated documentation files (the "Software"), to deal
     5  // in the Software without restriction, including without limitation the rights
     6  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     7  // copies of the Software, and to permit persons to whom the Software is
     8  // furnished to do so, subject to the following conditions:
     9  //
    10  // The above copyright notice and this permission notice shall be included in
    11  // all copies or substantial portions of the Software.
    12  //
    13  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    14  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    15  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    16  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    17  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    18  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    19  // THE SOFTWARE.
    20  
    21  package proto
    22  
    23  import (
    24  	"go.uber.org/cadence/.gen/go/shared"
    25  
    26  	apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
    27  )
    28  
    29  func CountWorkflowExecutionsRequest(t *shared.CountWorkflowExecutionsRequest) *apiv1.CountWorkflowExecutionsRequest {
    30  	if t == nil {
    31  		return nil
    32  	}
    33  	return &apiv1.CountWorkflowExecutionsRequest{
    34  		Domain: t.GetDomain(),
    35  		Query:  t.GetQuery(),
    36  	}
    37  }
    38  
    39  func DeprecateDomainRequest(t *shared.DeprecateDomainRequest) *apiv1.DeprecateDomainRequest {
    40  	if t == nil {
    41  		return nil
    42  	}
    43  	return &apiv1.DeprecateDomainRequest{
    44  		Name:          t.GetName(),
    45  		SecurityToken: t.GetSecurityToken(),
    46  	}
    47  }
    48  
    49  func DescribeDomainRequest(t *shared.DescribeDomainRequest) *apiv1.DescribeDomainRequest {
    50  	if t == nil {
    51  		return nil
    52  	}
    53  	if t.UUID != nil {
    54  		return &apiv1.DescribeDomainRequest{DescribeBy: &apiv1.DescribeDomainRequest_Id{Id: *t.UUID}}
    55  	}
    56  	if t.Name != nil {
    57  		return &apiv1.DescribeDomainRequest{DescribeBy: &apiv1.DescribeDomainRequest_Name{Name: *t.Name}}
    58  	}
    59  	panic("neither oneof field is set for DescribeDomainRequest")
    60  }
    61  
    62  func DescribeTaskListRequest(t *shared.DescribeTaskListRequest) *apiv1.DescribeTaskListRequest {
    63  	if t == nil {
    64  		return nil
    65  	}
    66  	return &apiv1.DescribeTaskListRequest{
    67  		Domain:                t.GetDomain(),
    68  		TaskList:              TaskList(t.TaskList),
    69  		TaskListType:          TaskListType(t.TaskListType),
    70  		IncludeTaskListStatus: t.GetIncludeTaskListStatus(),
    71  	}
    72  }
    73  
    74  func DescribeWorkflowExecutionRequest(t *shared.DescribeWorkflowExecutionRequest) *apiv1.DescribeWorkflowExecutionRequest {
    75  	if t == nil {
    76  		return nil
    77  	}
    78  	return &apiv1.DescribeWorkflowExecutionRequest{
    79  		Domain:            t.GetDomain(),
    80  		WorkflowExecution: WorkflowExecution(t.Execution),
    81  	}
    82  }
    83  
    84  func GetWorkflowExecutionHistoryRequest(t *shared.GetWorkflowExecutionHistoryRequest) *apiv1.GetWorkflowExecutionHistoryRequest {
    85  	if t == nil {
    86  		return nil
    87  	}
    88  	return &apiv1.GetWorkflowExecutionHistoryRequest{
    89  		Domain:                 t.GetDomain(),
    90  		WorkflowExecution:      WorkflowExecution(t.Execution),
    91  		PageSize:               t.GetMaximumPageSize(),
    92  		NextPageToken:          t.GetNextPageToken(),
    93  		WaitForNewEvent:        t.GetWaitForNewEvent(),
    94  		HistoryEventFilterType: EventFilterType(t.HistoryEventFilterType),
    95  		SkipArchival:           t.GetSkipArchival(),
    96  	}
    97  }
    98  
    99  func ListArchivedWorkflowExecutionsRequest(t *shared.ListArchivedWorkflowExecutionsRequest) *apiv1.ListArchivedWorkflowExecutionsRequest {
   100  	if t == nil {
   101  		return nil
   102  	}
   103  	return &apiv1.ListArchivedWorkflowExecutionsRequest{
   104  		Domain:        t.GetDomain(),
   105  		PageSize:      t.GetPageSize(),
   106  		NextPageToken: t.GetNextPageToken(),
   107  		Query:         t.GetQuery(),
   108  	}
   109  }
   110  
   111  func ListDomainsRequest(t *shared.ListDomainsRequest) *apiv1.ListDomainsRequest {
   112  	if t == nil {
   113  		return nil
   114  	}
   115  	return &apiv1.ListDomainsRequest{
   116  		PageSize:      t.GetPageSize(),
   117  		NextPageToken: t.NextPageToken,
   118  	}
   119  }
   120  
   121  func ListTaskListPartitionsRequest(t *shared.ListTaskListPartitionsRequest) *apiv1.ListTaskListPartitionsRequest {
   122  	if t == nil {
   123  		return nil
   124  	}
   125  	return &apiv1.ListTaskListPartitionsRequest{
   126  		Domain:   t.GetDomain(),
   127  		TaskList: TaskList(t.TaskList),
   128  	}
   129  }
   130  
   131  func ListWorkflowExecutionsRequest(t *shared.ListWorkflowExecutionsRequest) *apiv1.ListWorkflowExecutionsRequest {
   132  	if t == nil {
   133  		return nil
   134  	}
   135  	return &apiv1.ListWorkflowExecutionsRequest{
   136  		Domain:        t.GetDomain(),
   137  		PageSize:      t.GetPageSize(),
   138  		NextPageToken: t.NextPageToken,
   139  		Query:         t.GetQuery(),
   140  	}
   141  }
   142  
   143  func PollForActivityTaskRequest(t *shared.PollForActivityTaskRequest) *apiv1.PollForActivityTaskRequest {
   144  	if t == nil {
   145  		return nil
   146  	}
   147  	return &apiv1.PollForActivityTaskRequest{
   148  		Domain:           t.GetDomain(),
   149  		TaskList:         TaskList(t.TaskList),
   150  		Identity:         t.GetIdentity(),
   151  		TaskListMetadata: TaskListMetadata(t.TaskListMetadata),
   152  	}
   153  }
   154  
   155  func PollForDecisionTaskRequest(t *shared.PollForDecisionTaskRequest) *apiv1.PollForDecisionTaskRequest {
   156  	if t == nil {
   157  		return nil
   158  	}
   159  	return &apiv1.PollForDecisionTaskRequest{
   160  		Domain:         t.GetDomain(),
   161  		TaskList:       TaskList(t.TaskList),
   162  		Identity:       t.GetIdentity(),
   163  		BinaryChecksum: t.GetBinaryChecksum(),
   164  	}
   165  }
   166  
   167  func QueryWorkflowRequest(t *shared.QueryWorkflowRequest) *apiv1.QueryWorkflowRequest {
   168  	if t == nil {
   169  		return nil
   170  	}
   171  	return &apiv1.QueryWorkflowRequest{
   172  		Domain:                t.GetDomain(),
   173  		WorkflowExecution:     WorkflowExecution(t.Execution),
   174  		Query:                 WorkflowQuery(t.Query),
   175  		QueryRejectCondition:  QueryRejectCondition(t.QueryRejectCondition),
   176  		QueryConsistencyLevel: QueryConsistencyLevel(t.QueryConsistencyLevel),
   177  	}
   178  }
   179  
   180  func RecordActivityTaskHeartbeatByIdRequest(t *shared.RecordActivityTaskHeartbeatByIDRequest) *apiv1.RecordActivityTaskHeartbeatByIDRequest {
   181  	if t == nil {
   182  		return nil
   183  	}
   184  	return &apiv1.RecordActivityTaskHeartbeatByIDRequest{
   185  		Domain:            t.GetDomain(),
   186  		WorkflowExecution: WorkflowRunPair(t.GetWorkflowID(), t.GetRunID()),
   187  		ActivityId:        t.GetActivityID(),
   188  		Details:           Payload(t.Details),
   189  		Identity:          t.GetIdentity(),
   190  	}
   191  }
   192  
   193  func RecordActivityTaskHeartbeatRequest(t *shared.RecordActivityTaskHeartbeatRequest) *apiv1.RecordActivityTaskHeartbeatRequest {
   194  	if t == nil {
   195  		return nil
   196  	}
   197  	return &apiv1.RecordActivityTaskHeartbeatRequest{
   198  		TaskToken: t.TaskToken,
   199  		Details:   Payload(t.Details),
   200  		Identity:  t.GetIdentity(),
   201  	}
   202  }
   203  
   204  func RegisterDomainRequest(t *shared.RegisterDomainRequest) *apiv1.RegisterDomainRequest {
   205  	if t == nil {
   206  		return nil
   207  	}
   208  	return &apiv1.RegisterDomainRequest{
   209  		Name:                             t.GetName(),
   210  		Description:                      t.GetDescription(),
   211  		OwnerEmail:                       t.GetOwnerEmail(),
   212  		WorkflowExecutionRetentionPeriod: daysToDuration(t.WorkflowExecutionRetentionPeriodInDays),
   213  		Clusters:                         ClusterReplicationConfigurationArray(t.Clusters),
   214  		ActiveClusterName:                t.GetActiveClusterName(),
   215  		Data:                             t.Data,
   216  		SecurityToken:                    t.GetSecurityToken(),
   217  		IsGlobalDomain:                   t.GetIsGlobalDomain(),
   218  		HistoryArchivalStatus:            ArchivalStatus(t.HistoryArchivalStatus),
   219  		HistoryArchivalUri:               t.GetHistoryArchivalURI(),
   220  		VisibilityArchivalStatus:         ArchivalStatus(t.VisibilityArchivalStatus),
   221  		VisibilityArchivalUri:            t.GetVisibilityArchivalURI(),
   222  	}
   223  }
   224  
   225  func RequestCancelWorkflowExecutionRequest(t *shared.RequestCancelWorkflowExecutionRequest) *apiv1.RequestCancelWorkflowExecutionRequest {
   226  	if t == nil {
   227  		return nil
   228  	}
   229  	return &apiv1.RequestCancelWorkflowExecutionRequest{
   230  		Domain:            t.GetDomain(),
   231  		WorkflowExecution: WorkflowExecution(t.WorkflowExecution),
   232  		Identity:          t.GetIdentity(),
   233  		RequestId:         t.GetRequestId(),
   234  	}
   235  }
   236  
   237  func ResetStickyTaskListRequest(t *shared.ResetStickyTaskListRequest) *apiv1.ResetStickyTaskListRequest {
   238  	if t == nil {
   239  		return nil
   240  	}
   241  	return &apiv1.ResetStickyTaskListRequest{
   242  		Domain:            t.GetDomain(),
   243  		WorkflowExecution: WorkflowExecution(t.Execution),
   244  	}
   245  }
   246  
   247  func ResetWorkflowExecutionRequest(t *shared.ResetWorkflowExecutionRequest) *apiv1.ResetWorkflowExecutionRequest {
   248  	if t == nil {
   249  		return nil
   250  	}
   251  	return &apiv1.ResetWorkflowExecutionRequest{
   252  		Domain:                t.GetDomain(),
   253  		WorkflowExecution:     WorkflowExecution(t.WorkflowExecution),
   254  		Reason:                t.GetReason(),
   255  		DecisionFinishEventId: t.GetDecisionFinishEventId(),
   256  		RequestId:             t.GetRequestId(),
   257  		SkipSignalReapply:     t.GetSkipSignalReapply(),
   258  	}
   259  }
   260  
   261  func RespondActivityTaskCanceledByIdRequest(t *shared.RespondActivityTaskCanceledByIDRequest) *apiv1.RespondActivityTaskCanceledByIDRequest {
   262  	if t == nil {
   263  		return nil
   264  	}
   265  	return &apiv1.RespondActivityTaskCanceledByIDRequest{
   266  		Domain:            t.GetDomain(),
   267  		WorkflowExecution: WorkflowRunPair(t.GetWorkflowID(), t.GetRunID()),
   268  		ActivityId:        t.GetActivityID(),
   269  		Details:           Payload(t.Details),
   270  		Identity:          t.GetIdentity(),
   271  	}
   272  }
   273  
   274  func RespondActivityTaskCanceledRequest(t *shared.RespondActivityTaskCanceledRequest) *apiv1.RespondActivityTaskCanceledRequest {
   275  	if t == nil {
   276  		return nil
   277  	}
   278  	return &apiv1.RespondActivityTaskCanceledRequest{
   279  		TaskToken: t.TaskToken,
   280  		Details:   Payload(t.Details),
   281  		Identity:  t.GetIdentity(),
   282  	}
   283  }
   284  
   285  func RespondActivityTaskCompletedByIdRequest(t *shared.RespondActivityTaskCompletedByIDRequest) *apiv1.RespondActivityTaskCompletedByIDRequest {
   286  	if t == nil {
   287  		return nil
   288  	}
   289  	return &apiv1.RespondActivityTaskCompletedByIDRequest{
   290  		Domain:            t.GetDomain(),
   291  		WorkflowExecution: WorkflowRunPair(t.GetWorkflowID(), t.GetRunID()),
   292  		ActivityId:        t.GetActivityID(),
   293  		Result:            Payload(t.Result),
   294  		Identity:          t.GetIdentity(),
   295  	}
   296  }
   297  
   298  func RespondActivityTaskCompletedRequest(t *shared.RespondActivityTaskCompletedRequest) *apiv1.RespondActivityTaskCompletedRequest {
   299  	if t == nil {
   300  		return nil
   301  	}
   302  	return &apiv1.RespondActivityTaskCompletedRequest{
   303  		TaskToken: t.TaskToken,
   304  		Result:    Payload(t.Result),
   305  		Identity:  t.GetIdentity(),
   306  	}
   307  }
   308  
   309  func RespondActivityTaskFailedByIdRequest(t *shared.RespondActivityTaskFailedByIDRequest) *apiv1.RespondActivityTaskFailedByIDRequest {
   310  	if t == nil {
   311  		return nil
   312  	}
   313  	return &apiv1.RespondActivityTaskFailedByIDRequest{
   314  		Domain:            t.GetDomain(),
   315  		WorkflowExecution: WorkflowRunPair(t.GetWorkflowID(), t.GetRunID()),
   316  		ActivityId:        t.GetActivityID(),
   317  		Failure:           Failure(t.Reason, t.Details),
   318  		Identity:          t.GetIdentity(),
   319  	}
   320  }
   321  
   322  func RespondActivityTaskFailedRequest(t *shared.RespondActivityTaskFailedRequest) *apiv1.RespondActivityTaskFailedRequest {
   323  	if t == nil {
   324  		return nil
   325  	}
   326  	return &apiv1.RespondActivityTaskFailedRequest{
   327  		TaskToken: t.TaskToken,
   328  		Failure:   Failure(t.Reason, t.Details),
   329  		Identity:  t.GetIdentity(),
   330  	}
   331  }
   332  
   333  func RespondDecisionTaskCompletedRequest(t *shared.RespondDecisionTaskCompletedRequest) *apiv1.RespondDecisionTaskCompletedRequest {
   334  	if t == nil {
   335  		return nil
   336  	}
   337  	return &apiv1.RespondDecisionTaskCompletedRequest{
   338  		TaskToken:                  t.TaskToken,
   339  		Decisions:                  DecisionArray(t.Decisions),
   340  		ExecutionContext:           t.ExecutionContext,
   341  		Identity:                   t.GetIdentity(),
   342  		StickyAttributes:           StickyExecutionAttributes(t.StickyAttributes),
   343  		ReturnNewDecisionTask:      t.GetReturnNewDecisionTask(),
   344  		ForceCreateNewDecisionTask: t.GetForceCreateNewDecisionTask(),
   345  		BinaryChecksum:             t.GetBinaryChecksum(),
   346  		QueryResults:               WorkflowQueryResultMap(t.QueryResults),
   347  	}
   348  }
   349  
   350  func RespondDecisionTaskFailedRequest(t *shared.RespondDecisionTaskFailedRequest) *apiv1.RespondDecisionTaskFailedRequest {
   351  	if t == nil {
   352  		return nil
   353  	}
   354  	return &apiv1.RespondDecisionTaskFailedRequest{
   355  		TaskToken:      t.TaskToken,
   356  		Cause:          DecisionTaskFailedCause(t.Cause),
   357  		Details:        Payload(t.Details),
   358  		Identity:       t.GetIdentity(),
   359  		BinaryChecksum: t.GetBinaryChecksum(),
   360  	}
   361  }
   362  
   363  func RespondQueryTaskCompletedRequest(t *shared.RespondQueryTaskCompletedRequest) *apiv1.RespondQueryTaskCompletedRequest {
   364  	if t == nil {
   365  		return nil
   366  	}
   367  	return &apiv1.RespondQueryTaskCompletedRequest{
   368  		TaskToken: t.TaskToken,
   369  		Result: &apiv1.WorkflowQueryResult{
   370  			ResultType:   QueryTaskCompletedType(t.CompletedType),
   371  			Answer:       Payload(t.QueryResult),
   372  			ErrorMessage: t.GetErrorMessage(),
   373  		},
   374  		WorkerVersionInfo: WorkerVersionInfo(t.WorkerVersionInfo),
   375  	}
   376  }
   377  
   378  func ScanWorkflowExecutionsRequest(t *shared.ListWorkflowExecutionsRequest) *apiv1.ScanWorkflowExecutionsRequest {
   379  	if t == nil {
   380  		return nil
   381  	}
   382  	return &apiv1.ScanWorkflowExecutionsRequest{
   383  		Domain:        t.GetDomain(),
   384  		PageSize:      t.GetPageSize(),
   385  		NextPageToken: t.NextPageToken,
   386  		Query:         t.GetQuery(),
   387  	}
   388  }
   389  
   390  func SignalWithStartWorkflowExecutionRequest(t *shared.SignalWithStartWorkflowExecutionRequest) *apiv1.SignalWithStartWorkflowExecutionRequest {
   391  	if t == nil {
   392  		return nil
   393  	}
   394  	return &apiv1.SignalWithStartWorkflowExecutionRequest{
   395  		StartRequest: &apiv1.StartWorkflowExecutionRequest{
   396  			Domain:                       t.GetDomain(),
   397  			WorkflowId:                   t.GetWorkflowId(),
   398  			WorkflowType:                 WorkflowType(t.WorkflowType),
   399  			TaskList:                     TaskList(t.TaskList),
   400  			Input:                        Payload(t.Input),
   401  			ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds),
   402  			TaskStartToCloseTimeout:      secondsToDuration(t.TaskStartToCloseTimeoutSeconds),
   403  			Identity:                     t.GetIdentity(),
   404  			RequestId:                    t.GetRequestId(),
   405  			WorkflowIdReusePolicy:        WorkflowIdReusePolicy(t.WorkflowIdReusePolicy),
   406  			RetryPolicy:                  RetryPolicy(t.RetryPolicy),
   407  			CronSchedule:                 t.GetCronSchedule(),
   408  			Memo:                         Memo(t.Memo),
   409  			SearchAttributes:             SearchAttributes(t.SearchAttributes),
   410  			Header:                       Header(t.Header),
   411  			DelayStart:                   secondsToDuration(t.DelayStartSeconds),
   412  			JitterStart:                  secondsToDuration(t.JitterStartSeconds),
   413  		},
   414  		SignalName:  t.GetSignalName(),
   415  		SignalInput: Payload(t.SignalInput),
   416  		Control:     t.Control,
   417  	}
   418  }
   419  
   420  func SignalWorkflowExecutionRequest(t *shared.SignalWorkflowExecutionRequest) *apiv1.SignalWorkflowExecutionRequest {
   421  	if t == nil {
   422  		return nil
   423  	}
   424  	return &apiv1.SignalWorkflowExecutionRequest{
   425  		Domain:            t.GetDomain(),
   426  		WorkflowExecution: WorkflowExecution(t.WorkflowExecution),
   427  		SignalName:        t.GetSignalName(),
   428  		SignalInput:       Payload(t.Input),
   429  		Identity:          t.GetIdentity(),
   430  		RequestId:         t.GetRequestId(),
   431  		Control:           t.Control,
   432  	}
   433  }
   434  
   435  func StartWorkflowExecutionRequest(t *shared.StartWorkflowExecutionRequest) *apiv1.StartWorkflowExecutionRequest {
   436  	if t == nil {
   437  		return nil
   438  	}
   439  	return &apiv1.StartWorkflowExecutionRequest{
   440  		Domain:                       t.GetDomain(),
   441  		WorkflowId:                   t.GetWorkflowId(),
   442  		WorkflowType:                 WorkflowType(t.WorkflowType),
   443  		TaskList:                     TaskList(t.TaskList),
   444  		Input:                        Payload(t.Input),
   445  		ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds),
   446  		TaskStartToCloseTimeout:      secondsToDuration(t.TaskStartToCloseTimeoutSeconds),
   447  		Identity:                     t.GetIdentity(),
   448  		RequestId:                    t.GetRequestId(),
   449  		WorkflowIdReusePolicy:        WorkflowIdReusePolicy(t.WorkflowIdReusePolicy),
   450  		RetryPolicy:                  RetryPolicy(t.RetryPolicy),
   451  		CronSchedule:                 t.GetCronSchedule(),
   452  		Memo:                         Memo(t.Memo),
   453  		SearchAttributes:             SearchAttributes(t.SearchAttributes),
   454  		Header:                       Header(t.Header),
   455  		DelayStart:                   secondsToDuration(t.DelayStartSeconds),
   456  		JitterStart:                  secondsToDuration(t.JitterStartSeconds),
   457  	}
   458  }
   459  
   460  func TerminateWorkflowExecutionRequest(t *shared.TerminateWorkflowExecutionRequest) *apiv1.TerminateWorkflowExecutionRequest {
   461  	if t == nil {
   462  		return nil
   463  	}
   464  	return &apiv1.TerminateWorkflowExecutionRequest{
   465  		Domain:            t.GetDomain(),
   466  		WorkflowExecution: WorkflowExecution(t.WorkflowExecution),
   467  		Reason:            t.GetReason(),
   468  		Details:           Payload(t.Details),
   469  		Identity:          t.GetIdentity(),
   470  	}
   471  }
   472  
   473  const (
   474  	DomainUpdateDescriptionField              = "description"
   475  	DomainUpdateOwnerEmailField               = "owner_email"
   476  	DomainUpdateDataField                     = "data"
   477  	DomainUpdateRetentionPeriodField          = "workflow_execution_retention_period"
   478  	DomainUpdateBadBinariesField              = "bad_binaries"
   479  	DomainUpdateHistoryArchivalStatusField    = "history_archival_status"
   480  	DomainUpdateHistoryArchivalURIField       = "history_archival_uri"
   481  	DomainUpdateVisibilityArchivalStatusField = "visibility_archival_status"
   482  	DomainUpdateVisibilityArchivalURIField    = "visibility_archival_uri"
   483  	DomainUpdateActiveClusterNameField        = "active_cluster_name"
   484  	DomainUpdateClustersField                 = "clusters"
   485  	DomainUpdateDeleteBadBinaryField          = "delete_bad_binary"
   486  	DomainUpdateFailoverTimeoutField          = "failover_timeout"
   487  )
   488  
   489  func UpdateDomainRequest(t *shared.UpdateDomainRequest) *apiv1.UpdateDomainRequest {
   490  	if t == nil {
   491  		return nil
   492  	}
   493  	request := apiv1.UpdateDomainRequest{
   494  		Name:          t.GetName(),
   495  		SecurityToken: t.GetSecurityToken(),
   496  	}
   497  	var fields []string
   498  
   499  	if updatedInfo := t.GetUpdatedInfo(); updatedInfo != nil {
   500  		if updatedInfo.Description != nil {
   501  			request.Description = *updatedInfo.Description
   502  			fields = append(fields, DomainUpdateDescriptionField)
   503  		}
   504  		if updatedInfo.OwnerEmail != nil {
   505  			request.OwnerEmail = *updatedInfo.OwnerEmail
   506  			fields = append(fields, DomainUpdateOwnerEmailField)
   507  		}
   508  		if updatedInfo.Data != nil {
   509  			request.Data = updatedInfo.Data
   510  			fields = append(fields, DomainUpdateDataField)
   511  		}
   512  	}
   513  	if configuration := t.GetConfiguration(); configuration != nil {
   514  		if configuration.WorkflowExecutionRetentionPeriodInDays != nil {
   515  			request.WorkflowExecutionRetentionPeriod = daysToDuration(configuration.WorkflowExecutionRetentionPeriodInDays)
   516  			fields = append(fields, DomainUpdateRetentionPeriodField)
   517  		}
   518  		//if t.EmitMetric != nil {} - DEPRECATED
   519  		if configuration.BadBinaries != nil {
   520  			request.BadBinaries = BadBinaries(configuration.BadBinaries)
   521  			fields = append(fields, DomainUpdateBadBinariesField)
   522  		}
   523  		if configuration.HistoryArchivalStatus != nil {
   524  			request.HistoryArchivalStatus = ArchivalStatus(configuration.HistoryArchivalStatus)
   525  			fields = append(fields, DomainUpdateHistoryArchivalStatusField)
   526  		}
   527  		if configuration.HistoryArchivalURI != nil {
   528  			request.HistoryArchivalUri = *configuration.HistoryArchivalURI
   529  			fields = append(fields, DomainUpdateHistoryArchivalURIField)
   530  		}
   531  		if configuration.VisibilityArchivalStatus != nil {
   532  			request.VisibilityArchivalStatus = ArchivalStatus(configuration.VisibilityArchivalStatus)
   533  			fields = append(fields, DomainUpdateVisibilityArchivalStatusField)
   534  		}
   535  		if configuration.VisibilityArchivalURI != nil {
   536  			request.VisibilityArchivalUri = *configuration.VisibilityArchivalURI
   537  			fields = append(fields, DomainUpdateVisibilityArchivalURIField)
   538  		}
   539  	}
   540  	if replicationConfiguration := t.GetReplicationConfiguration(); replicationConfiguration != nil {
   541  		if replicationConfiguration.ActiveClusterName != nil {
   542  			request.ActiveClusterName = *replicationConfiguration.ActiveClusterName
   543  			fields = append(fields, DomainUpdateActiveClusterNameField)
   544  		}
   545  		if replicationConfiguration.Clusters != nil {
   546  			request.Clusters = ClusterReplicationConfigurationArray(replicationConfiguration.Clusters)
   547  			fields = append(fields, DomainUpdateClustersField)
   548  		}
   549  	}
   550  	if t.DeleteBadBinary != nil {
   551  		request.DeleteBadBinary = *t.DeleteBadBinary
   552  		fields = append(fields, DomainUpdateDeleteBadBinaryField)
   553  	}
   554  	if t.FailoverTimeoutInSeconds != nil {
   555  		request.FailoverTimeout = secondsToDuration(t.FailoverTimeoutInSeconds)
   556  		fields = append(fields, DomainUpdateFailoverTimeoutField)
   557  	}
   558  
   559  	request.UpdateMask = newFieldMask(fields)
   560  
   561  	return &request
   562  }
   563  
   564  func ListClosedWorkflowExecutionsRequest(r *shared.ListClosedWorkflowExecutionsRequest) *apiv1.ListClosedWorkflowExecutionsRequest {
   565  	if r == nil {
   566  		return nil
   567  	}
   568  	request := apiv1.ListClosedWorkflowExecutionsRequest{
   569  		Domain:          r.GetDomain(),
   570  		PageSize:        r.GetMaximumPageSize(),
   571  		NextPageToken:   r.NextPageToken,
   572  		StartTimeFilter: StartTimeFilter(r.StartTimeFilter),
   573  	}
   574  	if r.ExecutionFilter != nil {
   575  		request.Filters = &apiv1.ListClosedWorkflowExecutionsRequest_ExecutionFilter{
   576  			ExecutionFilter: WorkflowExecutionFilter(r.ExecutionFilter),
   577  		}
   578  	}
   579  	if r.TypeFilter != nil {
   580  		request.Filters = &apiv1.ListClosedWorkflowExecutionsRequest_TypeFilter{
   581  			TypeFilter: WorkflowTypeFilter(r.TypeFilter),
   582  		}
   583  	}
   584  	if r.StatusFilter != nil {
   585  		request.Filters = &apiv1.ListClosedWorkflowExecutionsRequest_StatusFilter{
   586  			StatusFilter: StatusFilter(r.StatusFilter),
   587  		}
   588  	}
   589  
   590  	return &request
   591  }
   592  
   593  func ListOpenWorkflowExecutionsRequest(r *shared.ListOpenWorkflowExecutionsRequest) *apiv1.ListOpenWorkflowExecutionsRequest {
   594  	if r == nil {
   595  		return nil
   596  	}
   597  	request := apiv1.ListOpenWorkflowExecutionsRequest{
   598  		Domain:          r.GetDomain(),
   599  		PageSize:        r.GetMaximumPageSize(),
   600  		NextPageToken:   r.NextPageToken,
   601  		StartTimeFilter: StartTimeFilter(r.StartTimeFilter),
   602  	}
   603  	if r.ExecutionFilter != nil {
   604  		request.Filters = &apiv1.ListOpenWorkflowExecutionsRequest_ExecutionFilter{
   605  			ExecutionFilter: WorkflowExecutionFilter(r.ExecutionFilter),
   606  		}
   607  	}
   608  	if r.TypeFilter != nil {
   609  		request.Filters = &apiv1.ListOpenWorkflowExecutionsRequest_TypeFilter{
   610  			TypeFilter: WorkflowTypeFilter(r.TypeFilter),
   611  		}
   612  	}
   613  
   614  	return &request
   615  }
   616  
   617  func RefreshWorkflowTasksRequest(r *shared.RefreshWorkflowTasksRequest) *apiv1.RefreshWorkflowTasksRequest {
   618  	if r == nil {
   619  		return nil
   620  	}
   621  	request := apiv1.RefreshWorkflowTasksRequest{
   622  		Domain:            r.GetDomain(),
   623  		WorkflowExecution: WorkflowExecution(r.Execution),
   624  	}
   625  	return &request
   626  }
   627  
   628  func RestartWorkflowExecutionRequest(r *shared.RestartWorkflowExecutionRequest) *apiv1.RestartWorkflowExecutionRequest {
   629  	if r == nil {
   630  		return nil
   631  	}
   632  	request := apiv1.RestartWorkflowExecutionRequest{
   633  		Domain:            r.GetDomain(),
   634  		WorkflowExecution: WorkflowExecution(r.GetWorkflowExecution()),
   635  		Identity:          r.GetIdentity(),
   636  		Reason:            r.GetReason(),
   637  	}
   638  
   639  	return &request
   640  }