-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into production
- Loading branch information
Showing
46 changed files
with
1,067 additions
and
327 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ on: | |
push: | ||
branches-ignore: | ||
- master | ||
- renovate/* | ||
tags-ignore: | ||
- v* | ||
jobs: | ||
|
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
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
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
46 changes: 46 additions & 0 deletions
46
...src/main/java/cz/metacentrum/perun/cli/commands/GetFacilityByAttributeWithAttributes.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,46 @@ | ||
package cz.metacentrum.perun.cli.commands; | ||
|
||
import cz.metacentrum.perun.cli.PerunCLI; | ||
import cz.metacentrum.perun.cli.PerunCommand; | ||
import cz.metacentrum.perun.openapi.model.FacilityWithAttributes; | ||
import org.apache.commons.cli.Option; | ||
import org.apache.commons.cli.Options; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Prints owners of facilities having the specified destination. | ||
* | ||
* @author Martin Kuba [email protected] | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class GetFacilityByAttributeWithAttributes extends PerunCommand { | ||
|
||
@Override | ||
public String getCommandDescription() { | ||
return "prints attributes of facilities found by attribute value"; | ||
} | ||
|
||
@Override | ||
public void addOptions(Options options) { | ||
options.addOption(Option.builder("a").required(true).hasArg(true).longOpt("attrName").desc("attribute name").build()); | ||
options.addOption(Option.builder("v").required(true).hasArg(true).longOpt("attrValue").desc("attribute value").build()); | ||
options.addOption(Option.builder("r").required(true).hasArg(true).longOpt("returnedAttributeNames").desc("names of returned attributes").build()); | ||
} | ||
|
||
@Override | ||
public void executeCommand(PerunCLI.CommandContext ctx) { | ||
String attributeName = ctx.getCommandLine().getOptionValue("a"); | ||
String attributeValue = ctx.getCommandLine().getOptionValue("v"); | ||
List<String> attrNames = Arrays.asList(ctx.getCommandLine().getOptionValue("r").split(",")); | ||
|
||
List<FacilityWithAttributes> facilities = ctx.getPerunRPC().getFacilitiesManager().getFacilitiesByAttributeWithAttributes(attributeName, attributeValue, attrNames); | ||
|
||
for (FacilityWithAttributes facility : facilities) { | ||
System.out.println(facility); | ||
} | ||
|
||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Optional | ||
from typer import Option | ||
from perun_openapi import ApiException | ||
from rich import print | ||
from rich.console import Console | ||
from rich.table import Table | ||
from perun.rpc import PerunException | ||
import perun.cli | ||
import typer | ||
|
||
from perun_openapi.model.facility import Facility | ||
|
||
|
||
def main(attr_name: str = Option(..., '-a', '--attributeName', help='attribute name (namespace + : + friendlyName)'), | ||
attr_value: str = Option(..., '-v', '--attributeValue', help='short name of VO'), | ||
sort_by_id: bool = typer.Option(False, '-i', '--orderById', help='order by id'), | ||
sort_by_name: bool = typer.Option(False, '-n', '--orderByName', help='order by short name') | ||
) -> None: | ||
""" search for facilities by attributeName and attributeValue """ | ||
rpc = perun.cli.rpc | ||
try: | ||
facilities: list[Facility] = rpc.facilities_manager.get_facilities_by_attribute(attr_name, attr_value) | ||
if sort_by_id: | ||
facilities.sort(key=lambda x: x.id) | ||
if sort_by_name: | ||
facilities.sort(key=lambda x: x.name) | ||
console = Console() | ||
# print user | ||
table = Table(title="facilities") | ||
table.add_column("id", justify="right") | ||
table.add_column("name") | ||
table.add_column("description") | ||
for facility in facilities: | ||
table.add_row(str(facility.id), str(facility.name), str(facility.description)) | ||
console.print(table) | ||
|
||
except ApiException as ex: | ||
print('error name:', PerunException(ex).name) | ||
print('error message:', PerunException(ex).message) | ||
raise typer.Exit(code=1) |
Oops, something went wrong.