-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
315 additions
and
85 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetPools.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,67 @@ | ||
/* | ||
* VM-Operator | ||
* Copyright (C) 2024 Michael N. Lipp | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.jdrupes.vmoperator.manager.events; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.jdrupes.vmoperator.common.VmPool; | ||
import org.jgrapes.core.Event; | ||
|
||
/** | ||
* Gets the known pools' definitions. | ||
*/ | ||
@SuppressWarnings("PMD.DataClass") | ||
public class GetPools extends Event<List<VmPool>> { | ||
|
||
private String user; | ||
private List<String> roles = Collections.emptyList(); | ||
|
||
/** | ||
* Return only {@link VmPool}s that are accessible by | ||
* the given user or roles. | ||
* | ||
* @param user the user | ||
* @param roles the roles | ||
* @return the event | ||
*/ | ||
public GetPools accessibleFor(String user, List<String> roles) { | ||
this.user = user; | ||
this.roles = roles; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the user filter criterion, if set. | ||
* | ||
* @return the optional | ||
*/ | ||
public Optional<String> forUser() { | ||
return Optional.ofNullable(user); | ||
} | ||
|
||
/** | ||
* Returns the roles criterion. | ||
* | ||
* @return the list | ||
*/ | ||
public List<String> forRoles() { | ||
return roles; | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetVms.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,97 @@ | ||
/* | ||
* VM-Operator | ||
* Copyright (C) 2024 Michael N. Lipp | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.jdrupes.vmoperator.manager.events; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.jdrupes.vmoperator.common.VmDefinition; | ||
import org.jgrapes.core.Event; | ||
|
||
/** | ||
* Gets the known VMs' definitions and channels. | ||
*/ | ||
@SuppressWarnings("PMD.DataClass") | ||
public class GetVms extends Event<List<GetVms.VmData>> { | ||
|
||
private String name; | ||
private String user; | ||
private List<String> roles = Collections.emptyList(); | ||
|
||
/** | ||
* Return only the VMs with the given name. | ||
* | ||
* @param name the name | ||
* @return the returns the vms | ||
*/ | ||
public GetVms withName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
/** | ||
* Return only {@link VmDefinition}s that are accessible by | ||
* the given user or roles. | ||
* | ||
* @param user the user | ||
* @param roles the roles | ||
* @return the event | ||
*/ | ||
public GetVms accessibleFor(String user, List<String> roles) { | ||
this.user = user; | ||
this.roles = roles; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the name filter criterion, if set. | ||
* | ||
* @return the optional | ||
*/ | ||
public Optional<String> name() { | ||
return Optional.ofNullable(name); | ||
} | ||
|
||
/** | ||
* Returns the user filter criterion, if set. | ||
* | ||
* @return the optional | ||
*/ | ||
public Optional<String> user() { | ||
return Optional.ofNullable(user); | ||
} | ||
|
||
/** | ||
* Returns the roles criterion. | ||
* | ||
* @return the list | ||
*/ | ||
public List<String> roles() { | ||
return roles; | ||
} | ||
|
||
/** | ||
* Return tuple. | ||
* | ||
* @param definition the definition | ||
* @param channel the channel | ||
*/ | ||
public record VmData(VmDefinition definition, VmChannel channel) { | ||
} | ||
} |
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
Oops, something went wrong.