| 390 | } |
| 391 | |
| 392 | func ProtoFromLifecycle(req PostLifecycleRequest) (*proto.Lifecycle, error) { |
| 393 | s, ok := proto.Lifecycle_State_value[strings.ToUpper(string(req.State))] |
| 394 | if !ok { |
| 395 | return nil, xerrors.Errorf("unknown lifecycle state: %s", req.State) |
| 396 | } |
| 397 | return &proto.Lifecycle{ |
| 398 | State: proto.Lifecycle_State(s), |
| 399 | ChangedAt: timestamppb.New(req.ChangedAt), |
| 400 | }, nil |
| 401 | } |
| 402 | |
| 403 | func LifecycleStateFromProto(s proto.Lifecycle_State) (codersdk.WorkspaceAgentLifecycle, error) { |
| 404 | caps, ok := proto.Lifecycle_State_name[int32(s)] |