-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Service offering category feature #12144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e1e902d
6519904
55f622e
f6b5e15
8e751ce
e3f09e6
f345279
e964ad3
14724b7
64651c5
67e238b
77f821f
2cdf59a
969debd
4ff6cf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,4 +146,6 @@ enum StorageType { | |
| Long getVgpuProfileId(); | ||
|
|
||
| Integer getGpuCount(); | ||
|
|
||
| long getCategoryId(); | ||
| } | ||
| 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); | ||
| } |
| 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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; | ||||||
|
|
@@ -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") | ||||||
|
||||||
| since = "4.23") | |
| since = "4.23.0") |
| 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(); | ||||||
|
||||||
| return Account.Type.ADMIN.ordinal(); | |
| return Account.ACCOUNT_ID_SYSTEM; |
| 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); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
getEntityOwnerId()method returnsAccount.Type.ADMIN.ordinal(), which is incorrect. The ordinal() of an enum returns its position (0 for ADMIN), not an account ID. This should returnAccount.ACCOUNT_ID_SYSTEMto match the pattern used in similar commands likeUpdateServiceOfferingCategoryCmd(line 80-82).