-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add project/duplicate endpoint #10407
Changes from 5 commits
c760882
cc7613b
8c4e5fb
7ac0a9c
6f30301
2ce0e3d
d3d11b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ transport formats, please look [here](./protocol-architecture.md). | |
- [`project/delete`](#projectdelete) | ||
- [`project/listSample`](#projectlistsample) | ||
- [`project/status`](#projectstatus) | ||
- [`project/duplicate`](#projectduplicate) | ||
- [Action Progress Reporting](#action-progress-reporting) | ||
- [`task/started`](#taskstarted) | ||
- [`task/progress-update`](#taskprogress-update) | ||
|
@@ -750,6 +751,50 @@ interface ProjectStatusResponse { | |
} | ||
``` | ||
|
||
### `project/duplicate` | ||
|
||
This message requests to make a copy of the project. | ||
|
||
- **Type:** Request | ||
- **Direction:** Client -> Server | ||
- **Connection:** Protocol | ||
- **Visibility:** Public | ||
|
||
#### Parameters | ||
|
||
```typescript | ||
interface ProjectDuplicateRequest { | ||
/** | ||
* The project to duplicate. | ||
*/ | ||
projectId: UUID; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the message support (optional) suggested name for the newly created project? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the cloud, the project with the |
||
|
||
/** | ||
* Custom directory with the user projects. | ||
*/ | ||
projectsDirectory?: string; | ||
} | ||
``` | ||
|
||
#### Result | ||
|
||
```typescript | ||
interface ProjectDuplicateResponse { | ||
projectId: UUID; | ||
projectName: string; | ||
projectNormalizedName: string; | ||
} | ||
``` | ||
|
||
#### Errors | ||
|
||
- [`ProjectDataStoreError`](#projectdatastoreerror) to signal problems with | ||
underlying data store. | ||
- [`ProjectNotFoundError`](#projectnotfounderror) to signal that the project | ||
doesn't exist. | ||
- [`ServiceError`](./protocol-common.md#serviceerror) to signal that the the | ||
operation timed out. | ||
|
||
## Action Progress Reporting | ||
|
||
Some actions, especially those related to installation of new components may | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,15 +59,15 @@ abstract class JsonRpcServerTestKit | |
|
||
def clientControllerFactory(): ClientControllerFactory | ||
|
||
var _clientControllerFactory: ClientControllerFactory = _ | ||
private var _clientControllerFactory: ClientControllerFactory = _ | ||
|
||
override def beforeEach(): Unit = { | ||
super.beforeEach() | ||
val factory = protocolFactory | ||
factory.init() | ||
_clientControllerFactory = clientControllerFactory() | ||
server = new JsonRpcServer(factory, _clientControllerFactory) | ||
binding = Await.result(server.bind(interface, port = 0), 3.seconds) | ||
binding = Await.result(server.bind(interface, port = 0), 5.seconds.dilated) | ||
address = s"ws://$interface:${binding.localAddress.getPort}" | ||
} | ||
|
||
|
@@ -174,10 +174,12 @@ abstract class JsonRpcServerTestKit | |
def fuzzyExpectJson( | ||
json: Json, | ||
timeout: FiniteDuration = 5.seconds.dilated | ||
)(implicit pos: Position): Assertion = { | ||
)(implicit pos: Position): Json = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we leave There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the JSON does not match the expected |
||
val parsed = parse(expectMessage(timeout)) | ||
|
||
parsed should fuzzyMatchJson(json) | ||
|
||
inside(parsed) { case Right(json) => json } | ||
} | ||
|
||
def expectNoMessage(): Unit = outActor.expectNoMessage() | ||
|
@@ -191,9 +193,10 @@ abstract class JsonRpcServerTestKit | |
trait FuzzyJsonMatchers { self: Matchers => | ||
class JsonEquals(expected: Json) | ||
extends Matcher[Either[io.circe.ParsingFailure, Json]] { | ||
val patch = inferPatch(expected) | ||
|
||
def apply(left: Either[io.circe.ParsingFailure, Json]) = { | ||
private val patch = inferPatch(expected) | ||
|
||
def apply(left: Either[io.circe.ParsingFailure, Json]): MatchResult = { | ||
val leftFormatted = patch[scala.util.Try](left.getOrElse(Json.Null)) | ||
val expectedFormatted = patch[scala.util.Try](expected) | ||
MatchResult( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,20 @@ class BlockingFileSystem[F[+_, +_]: Sync: ErrorChannel]( | |
} | ||
.mapError(toFsFailure) | ||
|
||
/** @inheritdoc */ | ||
override def copy(from: File, to: File): F[FileSystemFailure, Unit] = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See! It is called |
||
Sync[F] | ||
.blockingOp { | ||
if (to.isDirectory) { | ||
FileUtils.copyToDirectory(from, to) | ||
} else if (from.isDirectory) { | ||
FileUtils.copyDirectory(from, to) | ||
} else { | ||
FileUtils.copyFile(from, to) | ||
} | ||
} | ||
.mapError(toFsFailure) | ||
|
||
/** @inheritdoc */ | ||
override def exists(file: File): F[FileSystemFailure, Boolean] = | ||
Sync[F] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be called duplicate? Why not
copy
orfork
?