GithubHelp home page GithubHelp logo

isabella232 / teamcity-rest-auto-kotlin-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jetbrains/teamcity-rest-auto-kotlin-client

0.0 0.0 0.0 116 KB

License: Apache License 2.0

Kotlin 100.00%

teamcity-rest-auto-kotlin-client's Introduction

official JetBrains projectLicense

TeamCity-Kotlin-REST-Client

A basic TeamCity REST API client written in Kotlin. Generated automatically with swagger-codegen and TeamCity REST generator.

Current issues

  • Locator logic may require some rework, e.g. to explicitly use Locator classes inside of the methods and other locators and cast them to String

Usage examples

import org.jetbrains.teamcity.rest.apis.BuildApi
import org.jetbrains.teamcity.rest.apis.BuildQueueApi
import org.jetbrains.teamcity.rest.infrastructure.ClientConfig
import org.jetbrains.teamcity.rest.models.Build
import org.jetbrains.teamcity.rest.models.BuildLocator
import org.jetbrains.teamcity.rest.models.BuildType

val clientConfig = ClientConfig.getTokenAuthConfig(
        "<your TeamCity instance URL>",
        "<your authentication token>"
)

// Define a locator
val locator = BuildLocator(
        id = <some build ID>
)

val buildApi = BuildApi(clientConfig)

// Find a build by using locator defined above
var build = buildApi.getBuild(locator.toString())
println(build)

// Access build agent
var agent = build6931.agent
println(agent)

val buildQueueApi = BuildQueueApi(clientConfig)

// Define a build stub
val buildStub = Build(
        buildType = BuildType(
                id = "<some build configuration ID>"
        )
)

// And start a new build
val queuedBuild = buildQueueApi.addBuildToQueue(buildStub)
println("Started new build: " + queuedBuild.id)

// Get a list of builds with locator specified to fetch 10 builds
val builds = buildApi.getAllBuilds(locator = "count:10")

// Builds is a PaginatedEntity, meaning it can be iterated as a simple iterator:
var iterator = builds.getIterator()
while (iterator.hasNext()) {
    println(iterator.next().id.toString() + " id, fetched with simple iterator")
}

// ...or as a paginated iterator:
var paginatedIterator = builds.getPaginatedIterator(clientConfig)
var count = 0

while (paginatedIterator.hasNext() && count < 100) { // precaution to not accidentally request every build available
    println(paginatedIterator.next().id.toString() + " id, fetched with paginated iterator")
    count++
}

teamcity-rest-auto-kotlin-client's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.