Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api/src/main/java/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,11 @@ public class EventTypes {
public static final String VM_LEASE_CANCELLED = "VM.LEASE.CANCELLED";
public static final String VM_LEASE_EXPIRING = "VM.LEASE.EXPIRING";

// GUI Theme
public static final String EVENT_GUI_THEME_CREATE = "GUI.THEME.CREATE";
public static final String EVENT_GUI_THEME_REMOVE = "GUI.THEME.REMOVE";
public static final String EVENT_GUI_THEME_UPDATE = "GUI.THEME.UPDATE";

static {

// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
Expand Down Expand Up @@ -1312,6 +1317,11 @@ public class EventTypes {
entityEventDetails.put(VM_LEASE_EXPIRING, VirtualMachine.class);
entityEventDetails.put(VM_LEASE_DISABLED, VirtualMachine.class);
entityEventDetails.put(VM_LEASE_CANCELLED, VirtualMachine.class);

// GUI theme
entityEventDetails.put(EVENT_GUI_THEME_CREATE, "GuiTheme");
entityEventDetails.put(EVENT_GUI_THEME_REMOVE, "GuiTheme");
entityEventDetails.put(EVENT_GUI_THEME_UPDATE, "GuiTheme");
}

public static boolean isNetworkEvent(String eventType) {
Expand Down
16 changes: 16 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,22 @@ public class ApiConstants {

public static final String VMWARE_DC = "vmwaredc";

public static final String CSS = "css";

public static final String JSON_CONFIGURATION = "jsonconfiguration";

public static final String COMMON_NAMES = "commonnames";

public static final String COMMON_NAME = "commonname";

public static final String DOMAIN_IDS = "domainids";

public static final String SHOW_PUBLIC = "showpublic";

public static final String LIST_ONLY_DEFAULT_THEME = "listonlydefaulttheme";

public static final String RECURSIVE_DOMAINS = "recursivedomains";

/**
* This enum specifies IO Drivers, each option controls specific policies on I/O.
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.apache.cloudstack.api.response.GuestOsMappingResponse;
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
import org.apache.cloudstack.api.response.GuestVlanResponse;
import org.apache.cloudstack.api.response.GuiThemeResponse;
import org.apache.cloudstack.api.response.HostForMigrationResponse;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
Expand Down Expand Up @@ -150,6 +151,7 @@
import org.apache.cloudstack.direct.download.DirectDownloadCertificate;
import org.apache.cloudstack.direct.download.DirectDownloadCertificateHostMap;
import org.apache.cloudstack.direct.download.DirectDownloadManager;
import org.apache.cloudstack.gui.theme.GuiThemeJoin;
import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
import org.apache.cloudstack.region.PortableIp;
Expand Down Expand Up @@ -579,4 +581,6 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine
SharedFSResponse createSharedFSResponse(ResponseView view, SharedFS sharedFS);

void updateTemplateIsoResponsesForIcons(List<TemplateResponse> responses, ResourceTag.ResourceObjectType type);

GuiThemeResponse createGuiThemeResponse(GuiThemeJoin guiThemeJoin);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.user.gui.theme;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.GuiThemeResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.gui.theme.GuiTheme;
import org.apache.cloudstack.gui.theme.GuiThemeJoin;
import org.apache.cloudstack.gui.theme.GuiThemeService;

import javax.inject.Inject;

@APICommand(name = "createGuiTheme", description = "Creates a customized GUI theme for a set of Common Names (fixed or wildcard), a set of domain UUIDs, and/or a set of " +
"account UUIDs.", responseObject = GuiThemeResponse.class, entityType = {GuiTheme.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
since = "4.21.0.0", authorized = {RoleType.Admin})
public class CreateGuiThemeCmd extends BaseCmd {

@Inject
GuiThemeService guiThemeService;

@Parameter(name = ApiConstants.NAME, required = true, type = CommandType.STRING, length = 2048, description = "A name to identify the theme.")
private String name;

@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, length = 4096, description = "A description for the theme.")
private String description;

@Parameter(name = ApiConstants.CSS, type = CommandType.STRING, length = 65535, description = "The CSS to be retrieved and imported into the GUI " +
"when matching the theme access configurations.")
private String css;

@Parameter(name = ApiConstants.JSON_CONFIGURATION, type = CommandType.STRING, length = 65535, description = "The JSON with the configurations to be " +
"retrieved and imported into the GUI when matching the theme access configurations.")
private String jsonConfiguration;

@Parameter(name = ApiConstants.COMMON_NAMES, type = CommandType.STRING, length = 65535, description = "A set of Common Names (CN) (fixed or " +
"wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com")
private String commonNames;

@Parameter(name = ApiConstants.DOMAIN_IDS, type = CommandType.STRING, length = 65535, description = "A set of domain UUIDs (also known as ID for " +
"the end-user) separated by comma that can retrieve the theme.")
private String domainIds;

@Parameter(name = ApiConstants.ACCOUNT_IDS, type = CommandType.STRING, length = 65535, description = "A set of account UUIDs (also known as ID for" +
" the end-user) separated by comma that can retrieve the theme.")
private String accountIds;

@Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN, description = "Defines whether a theme can be retrieved by anyone when only " +

Check warning on line 68 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L68

Added line #L68 was not covered by tests
"the `commonNames` is informed. If the `domainIds` or `accountIds` is informed, it is considered as `false`.")
private Boolean isPublic = true;

Check warning on line 70 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L70

Added line #L70 was not covered by tests

@Parameter(name = ApiConstants.RECURSIVE_DOMAINS, type = CommandType.BOOLEAN, description = "Defines whether the subdomains of the informed domains are considered. Default " +

Check warning on line 72 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L72

Added line #L72 was not covered by tests
"value is false.")
private Boolean recursiveDomains = false;

Check warning on line 74 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L74

Added line #L74 was not covered by tests

public String getName() {
return name;
}

Check warning on line 78 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L76-L78

Added lines #L76 - L78 were not covered by tests

public String getDescription() {
return description;
}

Check warning on line 82 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L80-L82

Added lines #L80 - L82 were not covered by tests

public String getCss() {
return css;
}

Check warning on line 86 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L84-L86

Added lines #L84 - L86 were not covered by tests

public String getJsonConfiguration() {
return jsonConfiguration;
}

Check warning on line 90 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L88-L90

Added lines #L88 - L90 were not covered by tests

public String getCommonNames() {
return commonNames;
}

Check warning on line 94 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L92-L94

Added lines #L92 - L94 were not covered by tests

public String getDomainIds() {
return domainIds;
}

Check warning on line 98 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L96-L98

Added lines #L96 - L98 were not covered by tests

public String getAccountIds() {
return accountIds;
}

Check warning on line 102 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L100-L102

Added lines #L100 - L102 were not covered by tests

public Boolean getPublic() {
return isPublic;
}

Check warning on line 106 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L104-L106

Added lines #L104 - L106 were not covered by tests

public Boolean getRecursiveDomains() {
return recursiveDomains;
}

Check warning on line 110 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L108-L110

Added lines #L108 - L110 were not covered by tests

@Override
public void execute() {
GuiThemeJoin guiThemeJoin = guiThemeService.createGuiTheme(this);

Check warning on line 114 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L113-L114

Added lines #L113 - L114 were not covered by tests

if (guiThemeJoin == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create the GUI theme.");

Check warning on line 117 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L117

Added line #L117 was not covered by tests
}

GuiThemeResponse response = _responseGenerator.createGuiThemeResponse(guiThemeJoin);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}

Check warning on line 123 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L120-L123

Added lines #L120 - L123 were not covered by tests

@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}

Check warning on line 128 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java#L126-L128

Added lines #L126 - L128 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.user.gui.theme;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.GuiThemeResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.gui.theme.GuiTheme;
import org.apache.cloudstack.gui.theme.GuiThemeService;

import javax.inject.Inject;

@APICommand(name = "listGuiThemes", description = "Lists GUI themes.", responseObject = GuiThemeResponse.class, entityType = {GuiTheme.class},
since = "4.21.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.User, RoleType.DomainAdmin,
RoleType.ResourceAdmin})
public class ListGuiThemesCmd extends BaseListCmd {

@Inject
GuiThemeService guiThemeService;

@Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The theme ID.", entityType = GuiThemeResponse.class)
private Long id;

@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the theme.")
private String name;

@Parameter(name = ApiConstants.COMMON_NAME, type = CommandType.STRING, description = "The internet Common Name (CN) to be filtered.")
private String commonName;

@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "The ID of the domain to be filtered.")
private Long domainId;

@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "The ID of the account to be filtered.")
private Long accountId;

@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "Whether to list all themes.")

Check warning on line 56 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L56

Added line #L56 was not covered by tests
private boolean listAll = false;

@Parameter(name = ApiConstants.SHOW_REMOVED, type = CommandType.BOOLEAN, description = "Whether to list removed themes.")

Check warning on line 59 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L59

Added line #L59 was not covered by tests
private boolean showRemoved = false;

@Parameter(name = ApiConstants.SHOW_PUBLIC, type = CommandType.BOOLEAN, description = "Whether to list public themes.")
private Boolean showPublic;

@Parameter(name = ApiConstants.LIST_ONLY_DEFAULT_THEME, type = CommandType.BOOLEAN, description = "Whether to only list the default theme.")

Check warning on line 65 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L65

Added line #L65 was not covered by tests
private boolean listOnlyDefaultTheme = false;

public Long getId() {
return id;
}

Check warning on line 70 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L68-L70

Added lines #L68 - L70 were not covered by tests

public String getName() {
return name;
}

Check warning on line 74 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L72-L74

Added lines #L72 - L74 were not covered by tests

public String getCommonName() {
return commonName;
}

Check warning on line 78 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L76-L78

Added lines #L76 - L78 were not covered by tests

public Long getDomainId() {
return domainId;
}

Check warning on line 82 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L80-L82

Added lines #L80 - L82 were not covered by tests

public Long getAccountId() {
return accountId;
}

Check warning on line 86 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L84-L86

Added lines #L84 - L86 were not covered by tests

public boolean getListAll() {
return listAll;
}

Check warning on line 90 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L88-L90

Added lines #L88 - L90 were not covered by tests

public boolean getShowRemoved() {
return showRemoved;
}

Check warning on line 94 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L92-L94

Added lines #L92 - L94 were not covered by tests

public Boolean getShowPublic() {
return showPublic;
}

Check warning on line 98 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L96-L98

Added lines #L96 - L98 were not covered by tests

public boolean getListOnlyDefaultTheme() {
return listOnlyDefaultTheme;
}

Check warning on line 102 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L100-L102

Added lines #L100 - L102 were not covered by tests

@Override
public void execute() {
ListResponse<GuiThemeResponse> response = guiThemeService.listGuiThemes(this);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}

Check warning on line 109 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java#L105-L109

Added lines #L105 - L109 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.user.gui.theme;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.GuiThemeResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.gui.theme.GuiTheme;
import org.apache.cloudstack.gui.theme.GuiThemeService;

import javax.inject.Inject;

@APICommand(name = "removeGuiTheme", description = "Removes an existing GUI theme.", responseObject = GuiThemeResponse.class, entityType = {GuiTheme.class},
since = "4.21.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin})
public class RemoveGuiThemeCmd extends BaseCmd {

@Inject
GuiThemeService guiThemeService;

@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuiThemeResponse.class, required = true,
description = "The unique identifier of the GUI theme to be removed.")
private Long id;

public Long getId() {
return id;
}

Check warning on line 45 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/RemoveGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/RemoveGuiThemeCmd.java#L43-L45

Added lines #L43 - L45 were not covered by tests

@Override
public void execute() {
guiThemeService.removeGuiTheme(this);
final SuccessResponse response = new SuccessResponse();
response.setResponseName(getCommandName());
response.setSuccess(true);
setResponseObject(response);
}

Check warning on line 54 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/RemoveGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/RemoveGuiThemeCmd.java#L48-L54

Added lines #L48 - L54 were not covered by tests

@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}

Check warning on line 59 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/RemoveGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/RemoveGuiThemeCmd.java#L57-L59

Added lines #L57 - L59 were not covered by tests
}
Loading
Loading