-
Notifications
You must be signed in to change notification settings - Fork 0
feat: onboard resource manager #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
21388ec
generate resource manager
marceljk de9ea32
review feedback
marceljk fdcd1c5
review feedback - update gitignore
marceljk 2ebf14d
review feedback
marceljk 1a33aaf
removed generated docs
marceljk 34150a0
remove not needed build.sbt
marceljk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,41 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
|
||
# Gradle | ||
.gradle | ||
**/build/ | ||
!**/src/**/build/ | ||
|
||
# Ignore Gradle GUI config | ||
gradle-app.setting | ||
|
||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | ||
!gradle-wrapper.jar | ||
|
||
# Avoid ignore Gradle wrappper properties | ||
!gradle-wrapper.properties | ||
|
||
# Cache of project | ||
.gradletasknamecache | ||
|
||
# Eclipse Gradle plugin generated files | ||
# Eclipse Core | ||
.project | ||
# JDT-specific (Eclipse Java Development Tools) | ||
.classpath |
This file contains hidden or 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,133 @@ | ||
# stackit-sdk-resourcemanager | ||
|
||
Resource Manager API | ||
|
||
- API version: 2.0 | ||
|
||
API v2 to manage resource containers - organizations, folders, projects incl. labels | ||
|
||
### Resource Management | ||
STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, | ||
folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. | ||
|
||
### Organizations | ||
STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. | ||
- Organizations are always the root node in resource hierarchy and do not have a parent | ||
|
||
### Projects | ||
STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. | ||
- Projects are optional, but mandatory for cloud-resource usage | ||
- A project can be created having either an organization, or a folder as parent | ||
- A project must not have a project as parent | ||
- Project names under the same parent must not be unique | ||
- Root organization cannot be changed | ||
|
||
### Label | ||
STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. | ||
- Policy-based, immutable labels may exists | ||
|
||
For more information, please visit [https://support.stackit.cloud/servicedesk](https://support.stackit.cloud/servicedesk) | ||
|
||
This package is part of the STACKIT Java SDK. For additional information, please visit the [GitHub repository](https://github.com/stackitcloud/stackit-sdk-java) of the SDK. | ||
|
||
|
||
## Requirements | ||
|
||
Building the API client library requires: | ||
1. Java 1.8+ | ||
|
||
## Installation | ||
|
||
To install the API client library to your local Maven repository, simply execute: | ||
|
||
```shell | ||
./gradlew publishToMavenLocal | ||
``` | ||
|
||
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: | ||
|
||
```shell | ||
# TODO: follow up story | ||
# ./gradlew publishToMavenCentral | ||
``` | ||
|
||
Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. | ||
|
||
### Maven users | ||
|
||
Add this dependency to your project's POM: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>cloud.stackit</groupId> | ||
<artifactId>stackit-sdk-resourcemanager</artifactId> | ||
<version><SDK_VERSION></version> | ||
<scope>compile</scope> | ||
</dependency> | ||
``` | ||
|
||
### Gradle users | ||
|
||
Add this dependency to your project's build file: | ||
|
||
```groovy | ||
repositories { | ||
mavenCentral() // Needed if the 'stackit-sdk-resourcemanager' jar has been published to maven central. | ||
mavenLocal() // Needed if the 'stackit-sdk-resourcemanager' jar has been published to the local maven repo. | ||
} | ||
|
||
dependencies { | ||
implementation "cloud.stackit:stackit-sdk-resourcemanager:<SDK_VERSION>" | ||
} | ||
``` | ||
|
||
### Others | ||
|
||
At first generate the JAR by executing: | ||
|
||
```shell | ||
mvn clean package | ||
``` | ||
|
||
Then manually install the following JARs: | ||
|
||
- `target/stackit-sdk-resourcemanager-<SDK_VERSION>.jar` | ||
- `target/lib/*.jar` | ||
|
||
## Getting Started | ||
|
||
Please follow the [installation](#installation) instruction and execute the following Java code: | ||
|
||
```java | ||
|
||
import cloud.stackit.sdk.resourcemanager.*; | ||
import cloud.stackit.sdk.resourcemanager.auth.*; | ||
import cloud.stackit.sdk.resourcemanager.model.*; | ||
import cloud.stackit.sdk.resourcemanager.api.DefaultApi; | ||
|
||
public class DefaultApiExample { | ||
|
||
public static void main(String[] args) { | ||
ApiClient defaultClient = Configuration.getDefaultApiClient(); | ||
defaultClient.setBasePath("https://resource-manager.api.stackit.cloud"); | ||
|
||
DefaultApi apiInstance = new DefaultApi(defaultClient); | ||
CreateFolderPayload createFolderPayload = new CreateFolderPayload(); // CreateFolderPayload | | ||
try { | ||
FolderResponse result = apiInstance.createFolder(createFolderPayload); | ||
System.out.println(result); | ||
} catch (ApiException e) { | ||
System.err.println("Exception when calling DefaultApi#createFolder"); | ||
System.err.println("Status code: " + e.getCode()); | ||
System.err.println("Reason: " + e.getResponseBody()); | ||
System.err.println("Response headers: " + e.getResponseHeaders()); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
## Recommendation | ||
|
||
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. |
This file contains hidden or 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,166 @@ | ||
apply plugin: 'idea' | ||
apply plugin: 'eclipse' | ||
apply plugin: 'java' | ||
apply plugin: 'com.diffplug.spotless' | ||
|
||
group = 'cloud.stackit' | ||
version = '2.0' | ||
|
||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.3.+' | ||
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' | ||
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
sourceSets { | ||
main.java.srcDirs = ['src/main/java'] | ||
} | ||
|
||
if(hasProperty('target') && target == 'android') { | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.github.dcendents.android-maven' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '25.0.2' | ||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 25 | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
// Rename the aar correctly | ||
libraryVariants.all { variant -> | ||
variant.outputs.each { output -> | ||
def outputFile = output.outputFile | ||
if (outputFile != null && outputFile.name.endsWith('.aar')) { | ||
def fileName = "${project.name}-${variant.baseName}-${version}.aar" | ||
output.outputFile = new File(outputFile.parent, fileName) | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" | ||
} | ||
} | ||
|
||
afterEvaluate { | ||
android.libraryVariants.all { variant -> | ||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar | ||
task.description = "Create jar artifact for ${variant.name}" | ||
task.dependsOn variant.javaCompile | ||
task.from variant.javaCompile.destinationDirectory | ||
task.destinationDirectory = project.file("${project.buildDir}/outputs/jar") | ||
task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" | ||
artifacts.add('archives', task) | ||
} | ||
} | ||
|
||
task sourcesJar(type: Jar) { | ||
from android.sourceSets.main.java.srcDirs | ||
classifier = 'sources' | ||
} | ||
|
||
artifacts { | ||
archives sourcesJar | ||
} | ||
|
||
} else { | ||
|
||
apply plugin: 'java' | ||
apply plugin: 'maven-publish' | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
artifactId = 'stackit-sdk-resourcemanager' | ||
from components.java | ||
} | ||
} | ||
} | ||
|
||
task execute(type:JavaExec) { | ||
main = System.getProperty('mainClass') | ||
classpath = sourceSets.main.runtimeClasspath | ||
} | ||
} | ||
|
||
ext { | ||
jakarta_annotation_version = "1.3.5" | ||
} | ||
|
||
dependencies { | ||
implementation "com.google.code.findbugs:jsr305:3.0.2" | ||
implementation 'com.squareup.okhttp3:okhttp:4.12.0' | ||
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' | ||
implementation 'com.google.code.gson:gson:2.9.1' | ||
implementation 'io.gsonfire:gson-fire:1.9.0' | ||
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6' | ||
implementation 'org.openapitools:jackson-databind-nullable:0.2.6' | ||
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0' | ||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" | ||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' | ||
testImplementation 'org.mockito:mockito-core:3.12.4' | ||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' | ||
} | ||
|
||
javadoc { | ||
options.tags = [ "http.response.details:a:Http Response Details" ] | ||
} | ||
|
||
// Use spotless plugin to automatically format code, remove unused import, etc | ||
// To apply changes directly to the file, run `gradlew spotlessApply` | ||
// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle | ||
spotless { | ||
marceljk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// comment out below to run spotless as part of the `check` task | ||
enforceCheck false | ||
|
||
format 'misc', { | ||
// define the files (e.g. '*.gradle', '*.md') to apply `misc` to | ||
target '.gitignore' | ||
|
||
// define the steps to apply to those files | ||
trimTrailingWhitespace() | ||
indentWithSpaces() // Takes an integer argument if you don't like 4 | ||
endWithNewline() | ||
} | ||
java { | ||
// don't need to set target, it is inferred from java | ||
|
||
// apply a specific flavor of google-java-format | ||
googleJavaFormat('1.8').aosp().reflowLongStrings() | ||
|
||
removeUnusedImports() | ||
importOrder() | ||
} | ||
} | ||
|
||
test { | ||
// Enable JUnit 5 (Gradle 4.6+). | ||
useJUnitPlatform() | ||
|
||
// Always run tests, even when nothing changed. | ||
dependsOn 'cleanTest' | ||
|
||
// Show test results. | ||
testLogging { | ||
events "passed", "skipped", "failed" | ||
} | ||
|
||
} |
This file contains hidden or 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,6 @@ | ||
# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). | ||
# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option. | ||
# | ||
# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties | ||
# For example, uncomment below to build for Android | ||
#target = android |
7 changes: 7 additions & 0 deletions
7
services/resourcemanager/gradle/wrapper/gradle-wrapper.properties
This file contains hidden or 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,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.