forked from box/mojito
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I18N-1323 Update Mojito CLI to use OpenAPI spec for rest calls
Fixed schemas' issues
- Loading branch information
Showing
4 changed files
with
88 additions
and
45 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AssetWsApiHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.box.l10n.mojito.cli.apiclient; | ||
|
||
import com.box.l10n.mojito.cli.command.CommandException; | ||
import com.box.l10n.mojito.cli.model.AssetAssetSummary; | ||
import java.util.List; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.Assert; | ||
|
||
@Component | ||
public class AssetWsApiHelper { | ||
@Autowired AssetWsApi assetClient; | ||
|
||
public AssetAssetSummary getAssetByPathAndRepositoryId(String path, Long repositoryId) | ||
throws CommandException { | ||
Assert.notNull(path, "path must not be null"); | ||
Assert.notNull(repositoryId, "repository must not be null"); | ||
|
||
List<AssetAssetSummary> assets; | ||
try { | ||
assets = this.assetClient.getAssets(repositoryId, path, null, null, null); | ||
} catch (ApiException e) { | ||
throw new RuntimeException(e); | ||
} | ||
if (!assets.isEmpty()) { | ||
return assets.getFirst(); | ||
} else { | ||
throw new CommandException( | ||
"Could not find asset with path = [" + path + "] at repo id [" + repositoryId + "]"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters