Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
import org.apache.cloudstack.api.command.admin.network.UpdatePodManagementNetworkIpRangeCmd;
import org.apache.cloudstack.api.command.admin.offering.CreateDiskOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCategoryCmd;
import org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCategoryCmd;
import org.apache.cloudstack.api.command.admin.offering.IsAccountAllowedToCreateOfferingsWithTagsCmd;
import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCategoryCmd;
import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
import org.apache.cloudstack.api.command.admin.region.CreatePortableIpRangeCmd;
Expand Down Expand Up @@ -72,6 +75,7 @@
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.offering.ServiceOfferingCategory;
import com.cloud.user.Account;
import com.cloud.utils.Pair;

Expand Down Expand Up @@ -127,6 +131,30 @@ public interface ConfigurationService {
*/
List<Long> getServiceOfferingZones(Long serviceOfferingId);

/**
* Creates a service offering category
*
* @param cmd - the command specifying name and sort key
* @return the newly created service offering category
*/
ServiceOfferingCategory createServiceOfferingCategory(CreateServiceOfferingCategoryCmd cmd);

/**
* Deletes a service offering category
*
* @param cmd - the command specifying category id
* @return true if successful, false otherwise
*/
boolean deleteServiceOfferingCategory(DeleteServiceOfferingCategoryCmd cmd);

/**
* Updates a service offering category
*
* @param cmd - the command specifying category id, name, and/or sort key
* @return updated service offering category
*/
ServiceOfferingCategory updateServiceOfferingCategory(UpdateServiceOfferingCategoryCmd cmd);

/**
* Updates a disk offering
*
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/offering/ServiceOffering.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@ enum StorageType {
Long getVgpuProfileId();

Integer getGpuCount();

long getCategoryId();
}
31 changes: 31 additions & 0 deletions api/src/main/java/com/cloud/offering/ServiceOfferingCategory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 com.cloud.offering;

import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;

public interface ServiceOfferingCategory extends Identity, InternalIdentity {

String getName();

void setName(String name);

int getSortKey();

void setSortKey(int sortKey);
}
2 changes: 2 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 @@ -529,6 +529,8 @@ public class ApiConstants {
public static final String SENT_BYTES = "sentbytes";
public static final String SERIAL = "serial";
public static final String SERVICE_IP = "serviceip";
public static final String SERVICE_OFFERING_CATEGORY_ID = "serviceofferingcategoryid";
public static final String SERVICE_OFFERING_CATEGORY_NAME = "serviceofferingcategoryname";
public static final String SERVICE_OFFERING_ID = "serviceofferingid";
public static final String SERVICE_OFFERING_NAME = "serviceofferingname";
public static final String SESSIONKEY = "sessionkey";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
import org.apache.cloudstack.api.response.SecondaryStorageHeuristicsResponse;
import org.apache.cloudstack.api.response.SecurityGroupResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.ServiceOfferingCategoryResponse;
import org.apache.cloudstack.api.response.ServiceResponse;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
Expand Down Expand Up @@ -220,6 +221,7 @@
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.offering.ServiceOfferingCategory;
import com.cloud.org.Cluster;
import com.cloud.projects.Project;
import com.cloud.projects.ProjectAccount;
Expand Down Expand Up @@ -267,6 +269,8 @@ public interface ResponseGenerator {

ServiceOfferingResponse createServiceOfferingResponse(ServiceOffering offering);

ServiceOfferingCategoryResponse createServiceOfferingCategoryResponse(ServiceOfferingCategory category);

ConfigurationResponse createConfigurationResponse(Configuration cfg);

ConfigurationGroupResponse createConfigurationGroupResponse(ConfigurationGroup cfgGroup);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// 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.admin.offering;

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.ServiceOfferingCategoryResponse;

import com.cloud.offering.ServiceOfferingCategory;
import com.cloud.user.Account;

@APICommand(name = "createServiceOfferingCategory",
description = "Creates a service offering category.",
responseObject = ServiceOfferingCategoryResponse.class,
since = "4.23.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false)
public class CreateServiceOfferingCategoryCmd extends BaseCmd {

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.NAME,
type = CommandType.STRING,
required = true,
description = "the name of the service offering category")
private String name;

@Parameter(name = ApiConstants.SORT_KEY,
type = CommandType.INTEGER,
description = "sort key of the service offering category, default is 0")
private Integer sortKey;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public String getName() {
return name;
}

public Integer getSortKey() {
return sortKey;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public void execute() {
ServiceOfferingCategory result = _configService.createServiceOfferingCategory(this);
if (result != null) {
ServiceOfferingCategoryResponse response = _responseGenerator.createServiceOfferingCategoryResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create service offering category");
}
}

@Override
public long getEntityOwnerId() {
return Account.Type.ADMIN.ordinal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.cloudstack.api.response.ServiceOfferingCategoryResponse;
import org.apache.cloudstack.api.response.VgpuProfileResponse;
import org.apache.cloudstack.api.response.VsphereStoragePoliciesResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
Expand Down Expand Up @@ -289,6 +290,14 @@ public class CreateServiceOfferingCmd extends BaseCmd {
since = "4.21.0")
private Map externalDetails;

@Parameter(name = ApiConstants.SERVICE_OFFERING_CATEGORY_ID,
type = CommandType.UUID,
entityType = ServiceOfferingCategoryResponse.class,
required = false,
description = "the ID of the service offering category to associate with this offering",
since = "4.23")
private Long serviceOfferingCategoryId;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -561,6 +570,10 @@ public Boolean getGpuDisplay() {
return Boolean.TRUE.equals(gpuDisplay);
}

public Long getServiceOfferingCategoryId() {
return serviceOfferingCategoryId;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// 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.admin.offering;

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.ServiceOfferingCategoryResponse;
import org.apache.cloudstack.api.response.SuccessResponse;

import com.cloud.user.Account;

@APICommand(name = "deleteServiceOfferingCategory",
description = "Deletes a service offering category.",
responseObject = SuccessResponse.class,
since = "4.23.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false)
public class DeleteServiceOfferingCategoryCmd extends BaseCmd {

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
entityType = ServiceOfferingCategoryResponse.class,
required = true,
description = "the ID of the service offering category")
private Long id;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getId() {
return id;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public void execute() {
boolean result = _configService.deleteServiceOfferingCategory(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete service offering category");
}
}

@Override
public long getEntityOwnerId() {
return Account.Type.ADMIN.ordinal();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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.admin.offering;

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.ListResponse;
import org.apache.cloudstack.api.response.ServiceOfferingCategoryResponse;

@APICommand(name = "listServiceOfferingCategories",
description = "Lists service offering categories.",
responseObject = ServiceOfferingCategoryResponse.class,
since = "4.23.0",
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false)
public class ListServiceOfferingCategoriesCmd extends BaseListCmd {

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
entityType = ServiceOfferingCategoryResponse.class,
description = "ID of the service offering category")
private Long id;

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

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getId() {
return id;
}

public String getName() {
return name;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public void execute() {
ListResponse<ServiceOfferingCategoryResponse> response = _queryService.listServiceOfferingCategories(this);
response.setResponseName(getCommandName());
setResponseObject(response);
}
}
Loading
Loading