Skip to content

Commit

Permalink
#1113 | Use CCv1 api to get subscription permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
mlytvyn authored May 11, 2024
1 parent 7c936e1 commit 5ef7923
Show file tree
Hide file tree
Showing 8 changed files with 394 additions and 171 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
- Added a browser link to Build name [#1110](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1110)
- Added a browser link to Deployment code [#1111](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1111)
- Filter out Environments by Status [#1112](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1112)
- Use `CCv1` api to get subscription permissions [#1113](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1113)

### `Project Import` enhancements
- Loading backoffice sources provided by SAP on project import [#1096](https://github.com/epam/sap-commerce-intellij-idea-plugin/issues/1096)

### Other
- Migrated to `IntelliJ Platform Gradle Plugin 2.x` [#1099](https://github.com/epam/sap-commerce-intellij-idea-plugin/issues/1099)
- Migrated to `IntelliJ Platform Gradle Plugin 2.beta1` [#1099](https://github.com/epam/sap-commerce-intellij-idea-plugin/issues/1099)

## [2024.1.1]

Expand Down
82 changes: 53 additions & 29 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
import org.jetbrains.intellij.platform.gradle.tasks.RunIdeTask
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask

fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)
Expand Down Expand Up @@ -79,35 +80,47 @@ changelog {
// https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-gradle-plugin
// OpenAPI - Kotlin generator
// https://openapi-generator.tech/docs/generators/kotlin/
openApiGenerate {
generatorName.set("kotlin")
inputSpec.set("$rootDir/resources/specs/commerce-cloud-management-api.yaml")
outputDir.set("$rootDir/ccv2")

apiPackage.set("com.intellij.idea.plugin.hybris.ccv2.api")
packageName.set("com.intellij.idea.plugin.hybris.ccv2.invoker")
modelPackage.set("com.intellij.idea.plugin.hybris.ccv2.model")

skipOperationExample.set(true)
cleanupOutput.set(true)
generateApiDocumentation.set(false)
generateApiTests.set(false)
generateModelTests.set(false)

globalProperties.set(
mapOf(
"modelDocs" to "false",
val ccv2OpenApiSpecs = listOf(
Triple("ccv1OpenApiGenerate", "commerce-cloud-management-api-v1.yaml", "com.intellij.idea.plugin.hybris.ccv1"),
Triple("ccv2OpenApiGenerate", "commerce-cloud-management-api-v2.yaml", "com.intellij.idea.plugin.hybris.ccv2"),
)
val ccv2OpenApiTasks = ccv2OpenApiSpecs.mapIndexed { index, (taskName, schema, packagePrefix) ->
tasks.register<GenerateTask>(taskName) {
group = "openapi tools"
generatorName.set("kotlin")
inputSpec.set("$rootDir/resources/specs/$schema")
outputDir.set("$rootDir/ccv2")

apiPackage.set("$packagePrefix.api")
packageName.set("$packagePrefix.invoker")
modelPackage.set("$packagePrefix.model")

cleanupOutput.set(index == 0)
skipOperationExample.set(true)
generateApiDocumentation.set(false)
generateApiTests.set(false)
generateModelTests.set(false)

globalProperties.set(
mapOf(
"modelDocs" to "false",
)
)
)
configOptions.set(
mapOf(
"useSettingsGradle" to "false",
"omitGradlePluginVersions" to "true",
"omitGradleWrapper" to "true",
"useCoroutines" to "true",
"sourceFolder" to "",
configOptions.set(
mapOf(
"useSettingsGradle" to "false",
"omitGradlePluginVersions" to "true",
"omitGradleWrapper" to "true",
"useCoroutines" to "true",
"sourceFolder" to "",
)
)
)

if (index > 0) {
val previousTaskName = ccv2OpenApiSpecs[index - 1].first
dependsOn(previousTaskName)
}
}
}

intellijPlatform {
Expand Down Expand Up @@ -185,6 +198,8 @@ tasks {
runIde {
jvmArgs = jvmArguments
maxHeapSize = properties("intellij.maxHeapSize").get()

applyRunIdeSystemSettings()
}

val runIdeCommunity by registering(RunIdeTask::class) {
Expand All @@ -193,6 +208,8 @@ tasks {

jvmArgs = jvmArguments
maxHeapSize = properties("intellij.maxHeapSize").get()

applyRunIdeSystemSettings()
}

clean {
Expand All @@ -206,11 +223,11 @@ tasks {
}

compileJava {
dependsOn(openApiGenerate)
dependsOn(ccv2OpenApiTasks)
}

compileKotlin {
dependsOn(openApiGenerate)
dependsOn(ccv2OpenApiTasks)
}

printProductsReleases {
Expand Down Expand Up @@ -276,3 +293,10 @@ dependencies {
plugin("JRebelPlugin:2024.2.0")
}
}

fun RunIdeTask.applyRunIdeSystemSettings() {
systemProperty("ide.experimental.ui", "true")
systemProperty("ide.show.tips.on.startup.default.value", false)
systemProperty("idea.trust.all.projects", true)
systemProperty("jb.consents.confirmation.enabled", false)
}
243 changes: 243 additions & 0 deletions resources/specs/commerce-cloud-management-api-v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
openapi: 3.0.2
info:
version: 1.0.0
title: 'SAP Commerce Cloud - Management API'
description: 'The API to manage your SAP Commerce environments in the cloud, including provisioning, building releases, deploying, operating and more.'
license:
name: 'Use of this file is subject to the terms of your agreement with SAP SE or its affiliates respecting the use of the SAP product for which this file relates.'

x-sap-api-type: REST
x-sap-shortText: Manage Commerce Cloud Automation.
x-sap-stateInfo:
state: Beta
servers:
- url: https://{uri}/{version}
description: Environment URL
variables:
uri:
default: 'portalrotapi.hana.ondemand.com'
description: Environment URI
version:
default: 'v1'
description: API version
tags:
- name: permissions
description: Endpoints for managing permissions
- name: environment
description: Endpoints for managing environments
paths:
/permissions:
get:
tags:
- permissions
description: Get subscription permissions
operationId: getPermissions
parameters:
- $ref: '#/components/parameters/EndpointWebProxyFilter'
- $ref: '#/components/parameters/EndpointServiceFilter'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PermissionsDetailDTO'
'4XX':
$ref: '#/components/responses/DefaultResponse'
'5XX':
$ref: '#/components/responses/DefaultResponse'
/subscriptions/{subscriptionCode}/environments/{environmentCode}:
parameters:
- name: subscriptionCode
in: path
description: Customer subscription code
required: true
schema:
type: string
- name: environmentCode
in: path
description: Environment in the subscription
required: true
schema:
type: string
get:
tags:
- environment
description: Get environment details
operationId: getEnvironment
parameters:
- $ref: '#/components/parameters/EndpointWebProxyFilter'
- $ref: '#/components/parameters/EndpointServiceFilter'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentDetailDTO'
'4XX':
$ref: '#/components/responses/DefaultResponse'
'5XX':
$ref: '#/components/responses/DefaultResponse'
/subscriptions/{subscriptionCode}/environments/{environmentCode}/health:
parameters:
- name: subscriptionCode
in: path
description: Customer subscription code
required: true
schema:
type: string
- name: environmentCode
in: path
description: Environment in the subscription
required: true
schema:
type: string
get:
tags:
- environment
description: Get environment health
operationId: getEnvironmentHealth
parameters:
- $ref: '#/components/parameters/EndpointWebProxyFilter'
- $ref: '#/components/parameters/EndpointServiceFilter'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentHealthDTO'
'4XX':
$ref: '#/components/responses/DefaultResponse'
'5XX':
$ref: '#/components/responses/DefaultResponse'
security:
- OAuth2: [ ]
components:
securitySchemes:
OAuth2:
type: oauth2
flows:
authorizationCode:
scopes:
{ }
authorizationUrl: 'https://oauthasservices-a9f746d57.hana.ondemand.com/oauth2/api/v1/authorize'
tokenUrl: 'https://oauthasservices-a9f746d57.hana.ondemand.com/oauth2/api/v1/token'
parameters:
EndpointWebProxyFilter:
name: webProxy
in: query
description: The web proxy by which to filter endpoints, possible values are "public", "private" or "nat"
required: false
schema:
type: string
EndpointServiceFilter:
name: service
in: query
description: The service by which to filter endpoints
required: false
schema:
type: string
responses:
DefaultResponse:
description: Generic error
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ErrorDTO'
schemas:
ErrorDTO:
description: Problem detail message (https://tools.ietf.org/html/rfc7807)
type: object
properties:
title:
description: Human-readable summary of the problem type
type: string
readOnly: true
detail:
description: Human-readable explanation specific to this occurrence of the problem
type: string
readOnly: true
EnvironmentDetailDTO:
description: Entity to represent an environment
type: object
properties:
subscriptionCode:
description: Subscription code
type: string
name:
description: Environment name
type: string
code:
description: Environment code
type: string
live:
description: Live
type: boolean
loggingUrl:
description: Logging URL
type: string
dynatraceUrl:
description: Dynatrace URL
type: string
mediaStorages:
description: Media Storages
type: array
items:
$ref: '#/components/schemas/MediaStorageDTO'
EnvironmentHealthDTO:
description: Entity to represent problems of the environment
type: object
properties:
problems:
description: Dynatrace problems
type: integer
MediaStorageDTO:
description: Entity to represent a media storage
type: object
properties:
code:
description: Description
type: string
name:
description: Name
type: string
accountName:
description: Account Name
type: string
publicUrl:
description: Public URL
type: string
PermissionsDetailDTO:
description: Entity to represent permissions to all subscriptions of the current user
type: object
properties:
username:
description: User name
type: string
permissionDTOS:
description: Permissions for each subscription
type: array
items:
$ref: '#/components/schemas/PermissionDTO'
PermissionDTO:
description: Entity to represent permissions to a specific subscription
type: object
required:
- scopeName
- permissions
- environments
properties:
scopeName:
description: Subscription id
type: string
permissions:
type: array
items:
type: string
environments:
description: List of environment codes current user has access
type: array
items:
type: string
Loading

0 comments on commit 5ef7923

Please sign in to comment.