Skip to content

Commit

Permalink
Merge pull request #3174 from sima-zhu/moveRepo
Browse files Browse the repository at this point in the history
Move autorest client to java sdk central repo
  • Loading branch information
weshaggard authored Mar 25, 2019
2 parents 3e1463a + 60304c1 commit 3daeede
Show file tree
Hide file tree
Showing 251 changed files with 25,879 additions and 0 deletions.
31 changes: 31 additions & 0 deletions common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
build
*.class
target
gen

# Mobile Tools for Java (J2ME)
.mtj.tmp/
tmp

# Package Files #
*.jar
*.war
*.ear
*.MF
.gitrevision
.gradle

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# ide
.idea
*.iml
.DS_Store
**/temp/

#eclipse
.project
.classpath
.settings

17 changes: 17 additions & 0 deletions common/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: android
android:
components:
- build-tools-23.0.1
- android-23
- platform-tools
- extra-android-support
- extra-google-m2repository
- extra-android-m2repository
sudo: false
env:
- TERM=dumb # Makes Gradle use plain console output
script:
- mvn clean install -B -Dstyle.color=always
- mvn checkstyle:check -B -Dstyle.color=always
# (ignore android build for now)
# - cd ./azure-android-client-authentication && ./gradlew check
15 changes: 15 additions & 0 deletions common/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
2.0.0-beta4 (2018-08-06)
- Added HttpRequest request() property to RestResponse
- Added isProxyHTTPS() property to HttpClientConfiguration

2.0.0-beta3 (2018-06-26)
- Added FlowableUtil.ensureLength() operator to better handle cases where the request body had an unexpected size

2.0.0-beta2 (2018-04-23)
- Major refinements to HTTP content streaming, in large part thanks to contributions by [David Moten](https://github.com/davidmoten).
- Removed Joda Time in favor of Java 8 DateTime classes
- NettyClient.Factory now accepts a Netty Bootstrap object allowing for more user configuration of channel attributes, such as the receive buffer size and low/high write watermarks. Currently, specifying an EventLoopGroup or `Class<? extends Channel>` is not supported.
- Various other minor improvements

2.0.0-beta1 (2018-03-08)
- First beta featuring Netty and RxJava 2.
21 changes: 21 additions & 0 deletions common/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Microsoft Azure

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
124 changes: 124 additions & 0 deletions common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
[![Build Status](https://travis-ci.org/Azure/autorest-clientruntime-for-java.svg?branch=v2)](https://travis-ci.org/Azure/autorest-clientruntime-for-java)

# AutoRest Client Runtimes for Java
The runtime libraries for [AutoRest](https://github.com/azure/autorest) generated Java clients.

## Usage

### Prerequisites

- JDK 1.8

### Download

```xml
<dependencies>
<!-- For generic, non-Azure Resource Management users -->
<dependency>
<groupId>com.microsoft.rest.v3</groupId>
<artifactId>client-runtime</artifactId>
<version>2.0.0-beta4</version>
</dependency>

<!-- For Azure Resource Management users -->
<dependency>
<groupId>com.microsoft.azure.v3</groupId>
<artifactId>azure-client-runtime</artifactId>
<version>2.0.0-beta4</version>
</dependency>

<dependency>
<groupId>com.microsoft.azure.v3</groupId>
<artifactId>azure-client-authentication</artifactId>
<version>2.0.0-beta4</version>
</dependency>

<!-- Below are optional high-performance native dependencies -->

<!-- Available on Windows/Mac/Linux x86_64 -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.8.Final</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>

<!-- Only available on Linux -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>4.1.23.Final</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>

<!-- Only available on macOS/BSD -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>4.1.23.Final</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>
</dependencies>

<!-- Allows automatic detection of OS for native modules -->
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.0</version>
</extension>
</extensions>
</build>
```

### Usage

Non-Azure generated clients will have a constructor that takes no arguments for simple scenarios, while Azure generated clients will require a `ServiceClientCredentials` argument at a minimum.

If you want to have more control over configuration, consider using HttpPipeline. This enables performing transformations on all HTTP messages sent by a client, similar to interceptors or filters in other HTTP clients.

You can build an HttpPipeline out of a sequence of RequestPolicyFactories. These policies will get applied in-order to outgoing requests, and then in reverse order for incoming responses. HttpPipelineBuilder includes convenience methods for adding several built-in RequestPolicyFactories, including policies for credentials, logging, response decoding (deserialization), cookies support, and several others.

```java
// For Java generator
HttpPipeline pipeline = new HttpPipelineBuilder()
.withHostPolicy("http://localhost")
.withDecodingPolicy()
.build();
AutoRestJavaClient client = new AutoRestJavaClientImpl(pipeline);

// For Azure.Java generator
HttpPipeline azurePipeline = new HttpPipelineBuilder()
.withCredentialsPolicy(AzureCliCredentials.create())
.withHttpLoggingPolicy(HttpLogDetailLevel.HEADERS)
.withDecodingPolicy()
.build();
FooServiceClient azureClient = new FooServiceClientImpl(azurePipeline);
```

## Components

### client-runtime
This is the generic runtime. Add this package as a dependency if you are using `Java` generator in AutoRest. This package depends on [Netty](https://github.com/netty/netty), [Jackson](http://wiki.fasterxml.com/JacksonHome), and [RxJava](https://github.com/ReactiveX/RxJava) for making and processing REST requests.

### azure-client-runtime
This is the runtime with Azure Resource Management customizations. Add this package as a dependency if you are using `--azure-arm` or `--azure-arm --fluent` generator flags in AutoRest.

This combination provides a set of Azure specific behaviors, including long running operations, special handling of HEAD operations, and paginated `list()` calls.

### azure-client-authentication (beta)
This package provides access to Active Directory authentication on JDK using OrgId or application ID / secret combinations. There are currently 3 types of authentication provided:

- Service principal authentication: `ApplicationTokenCredentials`
- Username / password login without multi-factor auth: `UserTokenCredentials`
- Use the credentials logged in [Azure CLI](https://github.com/azure/azure-cli): `AzureCliCredentials`

### azure-android-client-authentication (beta)
This package provides access to Active Directory authentication on Android. You can login with Microsoft accounts, OrgId, with or without multi-factor auth.

## Build
To build this repository, you will need maven 2.0+ and gradle 1.6+.

## Contributing
This repository is for runtime & authentication specifically. For issues in the generated code, please report in [AutoRest](https://github.com/Azure/autorest). For bugs in the Azure SDK, please report in [Azure SDK for Java](https://github.com/Azure/azure-sdk-for-java). If you are unsure, please file here and state that clearly in the issue. Pull requests are welcomed with clear Javadocs.
117 changes: 117 additions & 0 deletions common/azure-android-client-authentication/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0.0-beta6-SNAPSHOT"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

lintOptions {
abortOnError false
}
}

configurations {
deployerJars
}

repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.microsoft.aad:adal:1.1.11'
compile 'com.microsoft.azure:azure-client-runtime:1.0.0-beta2'
testCompile 'junit:junit:4.12'
testCompile 'junit:junit-dep:4.11'
deployerJars "org.apache.maven.wagon:wagon-ftp:2.10"
}

uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
snapshotRepository(url: "ftp://waws-prod-bay-005.ftp.azurewebsites.windows.net/site/wwwroot/") {
authentication(userName: username, password: password)
}
repository(url: "file://$buildDir/repository")
pom.setArtifactId "azure-android-client-authentication"
pom.project {
name 'Microsoft Azure AutoRest Authentication Library for Java'
description 'This is the authentication library for AutoRest generated Azure Java clients.'
url 'https://github.com/Azure/autorest'

scm {
url 'scm:git:https://github.com/Azure/AutoRest'
connection 'scm:git:git://github.com/Azure/AutoRest.git'
}

licenses {
license {
name 'The MIT License (MIT)'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
}
}

developers {
developer {
id 'microsoft'
name 'Microsoft'
}
}
}
}
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
options.encoding = 'UTF-8'
}

task javadocJar(type: Jar, dependsOn: [javadoc]) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives sourcesJar
archives javadocJar
}
2 changes: 2 additions & 0 deletions common/azure-android-client-authentication/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
username = fake
password = fake
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Wed Nov 11 13:21:00 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-bin.zip
Loading

0 comments on commit 3daeede

Please sign in to comment.