From ca954b53ea51f3b95e52fa14e085bbf0d82fe335 Mon Sep 17 00:00:00 2001 From: anuchan Date: Mon, 31 Oct 2016 17:42:34 -0700 Subject: [PATCH 01/27] Fluent models for record set and record sets --- .../azure/management/dns/ARecordSet.java | 91 +++++++++++++ .../azure/management/dns/ARecordSets.java | 7 + .../azure/management/dns/AaaaRecordSet.java | 91 +++++++++++++ .../azure/management/dns/AaaaRecordSets.java | 7 + .../azure/management/dns/CnameRecordSet.java | 91 +++++++++++++ .../azure/management/dns/CnameRecordSets.java | 7 + .../azure/management/dns/DnsRecordSet.java | 22 +++ .../azure/management/dns/DnsZone.java | 128 ++++++++++++++++++ .../azure/management/dns/MxRecordSet.java | 91 +++++++++++++ .../azure/management/dns/MxRecordSets.java | 7 + .../azure/management/dns/NsRecordSet.java | 88 ++++++++++++ .../azure/management/dns/NsRecordSets.java | 7 + .../azure/management/dns/PtrRecordSet.java | 91 +++++++++++++ .../azure/management/dns/PtrRecordSets.java | 7 + .../azure/management/dns/SoaRecordSet.java | 13 ++ .../azure/management/dns/SoaRecordSets.java | 7 + .../azure/management/dns/SrvRecordSet.java | 91 +++++++++++++ .../azure/management/dns/SrvRecordSets.java | 7 + .../azure/management/dns/TxtRecordSet.java | 91 +++++++++++++ .../azure/management/dns/TxtRecordSets.java | 7 + .../dns/implementation/DnsRecordSetImpl.java | 71 ++++++++++ .../dns/implementation/DnsZoneImpl.java | 7 + .../fluentcore/arm/models/HasTags.java | 67 +++++++++ .../fluentcore/arm/models/Resource.java | 47 +------ 24 files changed, 1100 insertions(+), 43 deletions(-) create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java create mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/HasTags.java diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java new file mode 100644 index 0000000000000..f9fe0fb05476b --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java @@ -0,0 +1,91 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; + +import java.util.List; + +/** + * An immutable client-side representation of a A record set in Azure Dns Zone. + */ +public interface ARecordSet extends DnsRecordSet { + /** + * @return the IPv4 addresses of A records in this record set + */ + List ipv4Addresses(); + + /** + * The entirety of the Aaaa record set definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithCreate { + } + + /** + * Grouping of A record set definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a A record set definition. + */ + interface Blank { + // TODO + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithCreate withTimeToLive(long ttlInSeconds); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + HasTags.DefinitionWithTags, + DefinitionStages.WithTtl { + } + } + + /** + * Grouping of A record set update stages. + */ + interface UpdateStages { + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } + } + + /** + * The template for an update operation, containing all the settings that + * can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + HasTags.UpdateWithTags, + UpdateStages.WithTtl { + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java new file mode 100644 index 0000000000000..c8e8464637ea7 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public interface ARecordSets { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java new file mode 100644 index 0000000000000..5ed33e7fbc8f1 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java @@ -0,0 +1,91 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; + +import java.util.List; + +/** + * An immutable client-side representation of a Aaaa record set in Azure Dns Zone. + */ +public interface AaaaRecordSet extends DnsRecordSet { + /** + * @return the IPv6 addresses of Aaaa records in this record set + */ + List ipv6Addresses(); + + /** + * The entirety of the Aaaa record set definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithCreate { + } + + /** + * Grouping of Aaaa record set definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a Aaaa record set definition. + */ + interface Blank { + // TODO + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithCreate withTimeToLive(long ttlInSeconds); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + HasTags.DefinitionWithTags, + DefinitionStages.WithTtl { + } + } + + /** + * Grouping of Aaaa record set update stages. + */ + interface UpdateStages { + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } + } + + /** + * The template for an update operation, containing all the settings that + * can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + HasTags.UpdateWithTags, + UpdateStages.WithTtl { + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java new file mode 100644 index 0000000000000..2b2412f58b0e8 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public interface AaaaRecordSets { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java new file mode 100644 index 0000000000000..105cab8c72deb --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java @@ -0,0 +1,91 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; + +import java.util.List; + +/** + * An immutable client-side representation of a CName record set in Azure Dns Zone. + */ +public interface CnameRecordSet extends DnsRecordSet { + /** + * @return the canonical names (without a terminating dot) of CNAME records in this record set + */ + List canonicalNames(); + + /** + * The entirety of the CName record set definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithCreate { + } + + /** + * Grouping of CName record set definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a CName record set definition. + */ + interface Blank { + // TODO + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithCreate withTimeToLive(long ttlInSeconds); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + HasTags.DefinitionWithTags, + DefinitionStages.WithTtl { + } + } + + /** + * Grouping of CName record set update stages. + */ + interface UpdateStages { + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } + } + + /** + * The template for an update operation, containing all the settings that + * can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + HasTags.UpdateWithTags, + UpdateStages.WithTtl { + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java new file mode 100644 index 0000000000000..a96c0af257bb1 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public interface CnameRecordSets { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java new file mode 100644 index 0000000000000..daa2e633b1601 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -0,0 +1,22 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.dns.implementation.RecordSetInner; +import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; + +public interface DnsRecordSet extends + ExternalChildResource, + HasTags, + Wrapper { + + /** + * @return the type of records in this record set + */ + String recordType(); + + /** + * @return TTL of the records in this record set + */ + long timeToLive(); +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java new file mode 100644 index 0000000000000..93ce1fd466377 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java @@ -0,0 +1,128 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.dns.implementation.ZoneInner; +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; + + +/** + * An immutable client-side representation of an Azure DNS Zone. + */ +@Fluent +public interface DnsZone extends + GroupableResource, + Refreshable, + Wrapper, + Updatable { + /** + * @return the maximum number of record sets that can be created in this zone. + */ + long maxNumberOfRecordSets(); + + /** + * @return the current number of record sets in this zone. + */ + long numberOfRecordSets(); + + /** + * @return name servers assigned for this zone. + */ + List nameServers(); + + /** + * @return entry point to manage record sets in this zone containing A (Ipv4 address) records + */ + ARecordSets aRecordSets(); + + /** + * @return entry point to manage record sets in this zone containing AAAA (IPv6 address) records + */ + AaaaRecordSets aaaaRecordSets(); + + /** + * @return entry point to manage record sets in this zone containing CName (canonical name) records + */ + CnameRecordSets cnameRecordSets(); + + /** + * @return entry point to manage record sets in this zone containing Mx (mail exchange) records + */ + MxRecordSets mxRecordSets(); + + /** + * @return entry point to manage record sets in this zone containing Ns (name server) records + */ + NsRecordSets nsRecordSets(); + + /** + * @return entry point to manage record sets in this zone containing Ptr (pointer) records + */ + PtrRecordSets ptrRecordSets(); + + /** + * @return entry point to manage record sets in this zone containing Srv (service) records + */ + SrvRecordSets srvRecordSets(); + + /** + * @return entry point to manage record sets in this zone containing Txt (text) records + */ + TxtRecordSets txtRecordSets(); + + /** + * @return entry point to manage record sets in this zone containing Soa (start of authority) records + */ + SoaRecordSets soaRecordSets(); + + /** + * The entirety of the Dns zone definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithCreate { + } + + /** + * Grouping of Dns zone definition stages. + */ + interface DefinitionStages { + /** + * The stage of the Dns zone definition allowing to specify the resource group. + */ + interface Blank extends GroupableResource.DefinitionStages.WithGroupAndRegion { + } + + /** + * The stage of the definition which contains all the minimum required inputs for the resource to be created + * (via {@link WithCreate#create()}), but also allows for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + Resource.DefinitionWithTags { + } + } + + /** + * Grouping of Dns zone update stages. + */ + interface UpdateStages { + } + + /** + * The template for an update operation, containing all the settings that can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + Resource.UpdateWithTags { + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java new file mode 100644 index 0000000000000..4adf5d9f01463 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java @@ -0,0 +1,91 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; + +import java.util.List; + +/** + * An immutable client-side representation of a Mx record set in Azure Dns Zone. + */ +public interface MxRecordSet extends DnsRecordSet { + /** + * @return the Mx records in this record set + */ + List records(); + + /** + * The entirety of the CName record set definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithCreate { + } + + /** + * Grouping of Mx record set definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a Mx record set definition. + */ + interface Blank { + // TODO + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithCreate withTimeToLive(long ttlInSeconds); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + HasTags.DefinitionWithTags, + DefinitionStages.WithTtl { + } + } + + /** + * Grouping of Mx record set update stages. + */ + interface UpdateStages { + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } + } + + /** + * The template for an update operation, containing all the settings that + * can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + HasTags.UpdateWithTags, + UpdateStages.WithTtl { + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java new file mode 100644 index 0000000000000..7266af6e40c30 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public interface MxRecordSets { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java new file mode 100644 index 0000000000000..f78a97706f5f6 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java @@ -0,0 +1,88 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; + +import java.util.List; + +public interface NsRecordSet extends DnsRecordSet { + /** + * @return the name server names of Ns records in this record set + */ + List nameServers(); + + /** + * The entirety of the Ns record set definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithCreate { + } + + /** + * Grouping of Ns record set definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a Ns record set definition. + */ + interface Blank { + // TODO + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithCreate withTimeToLive(long ttlInSeconds); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + HasTags.DefinitionWithTags, + DefinitionStages.WithTtl { + } + } + + /** + * Grouping of Ns record set update stages. + */ + interface UpdateStages { + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } + } + + /** + * The template for an update operation, containing all the settings that + * can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + HasTags.UpdateWithTags, + UpdateStages.WithTtl { + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java new file mode 100644 index 0000000000000..52eff66349131 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public interface NsRecordSets { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java new file mode 100644 index 0000000000000..cbd93c5898d95 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java @@ -0,0 +1,91 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; + +import java.util.List; + +/** + * An immutable client-side representation of a Ptr record set in Azure Dns Zone. + */ +public interface PtrRecordSet extends DnsRecordSet { + /** + * @return the target domain names of Ptr records in this record set + */ + List targetDomainNames(); + + /** + * The entirety of the Ns record set definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithCreate { + } + + /** + * Grouping of Ptr record set definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a Ptr record set definition. + */ + interface Blank { + // TODO + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithCreate withTimeToLive(long ttlInSeconds); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + HasTags.DefinitionWithTags, + DefinitionStages.WithTtl { + } + } + + /** + * Grouping of Ptr record set update stages. + */ + interface UpdateStages { + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } + } + + /** + * The template for an update operation, containing all the settings that + * can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + HasTags.UpdateWithTags, + UpdateStages.WithTtl { + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java new file mode 100644 index 0000000000000..463cf497ba991 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public interface PtrRecordSets { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java new file mode 100644 index 0000000000000..f2554b8484e55 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java @@ -0,0 +1,13 @@ +package com.microsoft.azure.management.dns; + +import java.util.List; + +/** + * An immutable client-side representation of a Soa record set in Azure Dns Zone. + */ +public interface SoaRecordSet extends DnsRecordSet { + /** + * @return the Soa records in this record set + */ + List records(); +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java new file mode 100644 index 0000000000000..4b296a89700ca --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public class SoaRecordSets { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java new file mode 100644 index 0000000000000..128bcbcc3b0ae --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java @@ -0,0 +1,91 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; + +import java.util.List; + +/** + * An immutable client-side representation of a Srv record set in Azure Dns Zone. + */ +public interface SrvRecordSet extends DnsRecordSet { + /** + * @return the Srv records in this record set + */ + List records(); + + /** + * The entirety of the Srv record set definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithCreate { + } + + /** + * Grouping of Srv record set definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a Srv record set definition. + */ + interface Blank { + // TODO + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithCreate withTimeToLive(long ttlInSeconds); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + HasTags.DefinitionWithTags, + DefinitionStages.WithTtl { + } + } + + /** + * Grouping of Srv record set update stages. + */ + interface UpdateStages { + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } + } + + /** + * The template for an update operation, containing all the settings that + * can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + HasTags.UpdateWithTags, + UpdateStages.WithTtl { + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java new file mode 100644 index 0000000000000..a050695f2c3c0 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public interface SrvRecordSets { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java new file mode 100644 index 0000000000000..b2b9af2dbd2ed --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java @@ -0,0 +1,91 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; + +import java.util.List; + +/** + * An immutable client-side representation of a Txt record set in Azure Dns Zone. + */ +public interface TxtRecordSet extends DnsRecordSet { + /** + * @return the Txt records in this record set + */ + List records(); + + /** + * The entirety of the Txt record set definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithCreate { + } + + /** + * Grouping of Txt record set definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a Txt record set definition. + */ + interface Blank { + // TODO + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithCreate withTimeToLive(long ttlInSeconds); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + HasTags.DefinitionWithTags, + DefinitionStages.WithTtl { + } + } + + /** + * Grouping of Txt record set update stages. + */ + interface UpdateStages { + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } + } + + /** + * The template for an update operation, containing all the settings that + * can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + HasTags.UpdateWithTags, + UpdateStages.WithTtl { + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java new file mode 100644 index 0000000000000..3a0573ad3aa60 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public interface TxtRecordSets { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java new file mode 100644 index 0000000000000..0cde3d3ce38c3 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -0,0 +1,71 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.DnsRecordSet; +import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Implementation of {@link DnsRecordSet}. + * + * @param The record set fluent model type + * @param the implementation type of the fluent model type + */ +abstract class DnsRecordSetImpl> + extends CreatableUpdatableImpl + implements DnsRecordSet { + protected final DnsZoneImpl dnsZone; + protected final RecordSetsInner client; + + DnsRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(innerModel.name(), innerModel); + this.dnsZone = parentDnsZone; + this.client = client; + } + + @Override + public String id() { + return inner().id(); + } + + @Override + public String recordType() { + return this.inner().type(); + } + + @Override + public long timeToLive() { + return this.inner().tTL(); + } + + @Override + public Map tags() { + if (this.inner().metadata() == null) { + return Collections.unmodifiableMap(new LinkedHashMap()); + } + return Collections.unmodifiableMap(this.inner().metadata()); + } + + public final FluentModelImplT withTags(Map tags) { + this.inner().withMetadata(new HashMap<>(tags)); + return (FluentModelImplT) this; + } + + public final FluentModelImplT withTag(String key, String value) { + this.inner().metadata().put(key, value); + return (FluentModelImplT) this; + } + + public final FluentModelImplT withoutTag(String key) { + this.inner().metadata().remove(key); + return (FluentModelImplT) this; + } + + public FluentModelImplT withTimeToLive(long ttlInSeconds) { + this.inner().withTTL(ttlInSeconds); + return (FluentModelImplT) this; + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java new file mode 100644 index 0000000000000..9547b1812f025 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.management.dns.implementation; + +/** + * Created by anuthomaschandy on 10/31/16. + */ +public class DnsZoneImpl { +} diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/HasTags.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/HasTags.java new file mode 100644 index 0000000000000..52ee19953ed35 --- /dev/null +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/HasTags.java @@ -0,0 +1,67 @@ +package com.microsoft.azure.management.resources.fluentcore.arm.models; + +import com.microsoft.azure.management.apigeneration.Fluent; + +import java.util.Map; + +/** + * An interface representing a resource that has tags. + */ +@Fluent +public interface HasTags { + /** + * @return the tags associated with the resource + */ + Map tags(); + + /** + * A resource definition allowing tags to be modified for the resource. + * + * @param the type of the next stage resource definition + */ + interface DefinitionWithTags { + /** + * Specifies tags for the resource as a {@link Map}. + * @param tags a {@link Map} of tags + * @return the next stage of the resource definition + */ + T withTags(Map tags); + + /** + * Adds a tag to the resource. + * @param key the key for the tag + * @param value the value for the tag + * @return the next stage of the resource definition + */ + T withTag(String key, String value); + } + + /** + * An update allowing tags to be modified for the resource. + * + * @param the type of the next stage resource update + */ + interface UpdateWithTags { + /** + * Specifies tags for the resource as a {@link Map}. + * @param tags a {@link Map} of tags + * @return the next stage of the resource update + */ + T withTags(Map tags); + + /** + * Adds a tag to the resource. + * @param key the key for the tag + * @param value the value for the tag + * @return the next stage of the resource update + */ + T withTag(String key, String value); + + /** + * Removes a tag from the resource. + * @param key the key of the tag to remove + * @return the next stage of the resource update + */ + T withoutTag(String key); + } +} diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java index d309286c561bc..1c6cf5b10a55c 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java @@ -19,7 +19,8 @@ public interface Resource extends Indexable, HasId, - HasName { + HasName, + HasTags { /** * @return the type of the resource @@ -36,11 +37,6 @@ public interface Resource extends */ Region region(); - /** - * @return the tags for the resource - */ - Map tags(); - /** * A resource definition allowing a location be selected for the resource. * @@ -69,21 +65,7 @@ interface DefinitionWithRegion { * @param the type of the next stage resource definition */ @LangDefinition(ContainerName = "Resource.Definition", ContainerFileName = "IDefinition") - interface DefinitionWithTags { - /** - * Specifies tags for the resource as a {@link Map}. - * @param tags a {@link Map} of tags - * @return the next stage of the resource definition - */ - T withTags(Map tags); - - /** - * Adds a tag to the resource. - * @param key the key for the tag - * @param value the value for the tag - * @return the next stage of the resource definition - */ - T withTag(String key, String value); + interface DefinitionWithTags extends HasTags.DefinitionWithTags { } /** @@ -92,27 +74,6 @@ interface DefinitionWithTags { * @param the type of the next stage resource update */ @LangDefinition(ContainerName = "Resource.Update", ContainerFileName = "IUpdate") - interface UpdateWithTags { - /** - * Specifies tags for the resource as a {@link Map}. - * @param tags a {@link Map} of tags - * @return the next stage of the resource update - */ - T withTags(Map tags); - - /** - * Adds a tag to the resource. - * @param key the key for the tag - * @param value the value for the tag - * @return the next stage of the resource update - */ - T withTag(String key, String value); - - /** - * Removes a tag from the resource. - * @param key the key of the tag to remove - * @return the next stage of the resource update - */ - T withoutTag(String key); + interface UpdateWithTags extends HasTags.UpdateWithTags { } } From b3efe160413cfc917df27db4f16c0aa7e788a86e Mon Sep 17 00:00:00 2001 From: anuchan Date: Tue, 1 Nov 2016 15:00:21 -0700 Subject: [PATCH 02/27] Adding definition and update stages for various record set models --- .../azure/management/dns/ARecordSet.java | 46 ++++++- .../azure/management/dns/AaaaRecordSet.java | 42 +++++- .../azure/management/dns/CnameRecordSet.java | 44 +++++- .../azure/management/dns/DnsRecordSet.java | 3 + .../azure/management/dns/MxRecordSet.java | 45 ++++++- .../azure/management/dns/NsRecordSet.java | 42 +++++- .../azure/management/dns/PtrRecordSet.java | 42 +++++- .../azure/management/dns/SoaRecordSet.java | 126 +++++++++++++++++- .../azure/management/dns/TxtRecordSet.java | 42 +++++- 9 files changed, 403 insertions(+), 29 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java index f9fe0fb05476b..181582aa69ec6 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java @@ -7,16 +7,16 @@ import java.util.List; /** - * An immutable client-side representation of a A record set in Azure Dns Zone. + * An immutable client-side representation of a A (Ipv4) record set in Azure Dns Zone. */ public interface ARecordSet extends DnsRecordSet { /** - * @return the IPv4 addresses of A records in this record set + * @return the Ipv4 addresses of A records in this record set */ List ipv4Addresses(); /** - * The entirety of the Aaaa record set definition. + * The entirety of the A record set definition. */ interface Definition extends DefinitionStages.Blank, @@ -28,10 +28,22 @@ interface Definition extends */ interface DefinitionStages { /** - * The first stage of a A record set definition. + * The first stage of an A record set definition. */ - interface Blank { - // TODO + interface Blank extends WithIpv4Address { + } + + /** + * The stage of the A record set definition allowing to add a record. + */ + interface WithIpv4Address { + /** + * Creates an A record with the provided Ipv4 address in this record set. + * + * @param ipv4Address the Ipv4 address + * @return the next stage of the record set definition + */ + WithCreate withIpv4Address(String ipv4Address); } /** @@ -63,6 +75,27 @@ interface WithCreate extends * Grouping of A record set update stages. */ interface UpdateStages { + /** + * The stage of the Aaaa record set update allowing to add or remove a record. + */ + interface WithIpv4Address { + /** + * Creates an A record with the provided Ipv4 address in this record set. + * + * @param ipv4Address the Ipv4 address + * @return the next stage of the record set update + */ + Update withIpv4Address(String ipv4Address); + + /** + * Removes an A record with the provided Ipv4 address from this record set. + * + * @param ipv4Address the Ipv4 address + * @return the next stage of the record set update + */ + Update withoutIpv4Address(String ipv4Address); + } + /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ @@ -86,6 +119,7 @@ interface WithTtl { interface Update extends Appliable, HasTags.UpdateWithTags, + UpdateStages.WithIpv4Address, UpdateStages.WithTtl { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java index 5ed33e7fbc8f1..483b12b8294b6 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java @@ -7,7 +7,7 @@ import java.util.List; /** - * An immutable client-side representation of a Aaaa record set in Azure Dns Zone. + * An immutable client-side representation of a Aaaa (Ipv6) record set in Azure Dns Zone. */ public interface AaaaRecordSet extends DnsRecordSet { /** @@ -20,6 +20,7 @@ public interface AaaaRecordSet extends DnsRecordSet { */ interface Definition extends DefinitionStages.Blank, + DefinitionStages.WithIpv6Address, DefinitionStages.WithCreate { } @@ -30,8 +31,20 @@ interface DefinitionStages { /** * The first stage of a Aaaa record set definition. */ - interface Blank { - // TODO + interface Blank extends WithIpv6Address { + } + + /** + * The stage of the Aaaa record set definition allowing to add a record. + */ + interface WithIpv6Address { + /** + * Creates an Aaaa record with the provided Ipv6 address in this record set. + * + * @param ipv6Address the Ipv6 address + * @return the next stage of the record set definition + */ + WithCreate withIp6Address(String ipv6Address); } /** @@ -55,6 +68,7 @@ interface WithTtl { interface WithCreate extends Creatable, HasTags.DefinitionWithTags, + DefinitionStages.WithIpv6Address, DefinitionStages.WithTtl { } } @@ -63,6 +77,27 @@ interface WithCreate extends * Grouping of Aaaa record set update stages. */ interface UpdateStages { + /** + * The stage of the Aaaa record set update allowing to add or remove a record. + */ + interface WithIpv6Address { + /** + * Creates an Aaaa record with the provided Ipv6 address in this record set. + * + * @param ipv6Address the Ipv6 address + * @return the next stage of the record set update + */ + Update withIpv6Address(String ipv6Address); + + /** + * Removes an Aaaa record with the provided Ipv6 address from this record set. + * + * @param ipv6Address the Ipv6 address + * @return the next stage of the record set update + */ + Update withoutIpv6Address(String ipv6Address); + } + /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ @@ -86,6 +121,7 @@ interface WithTtl { interface Update extends Appliable, HasTags.UpdateWithTags, + UpdateStages.WithIpv6Address, UpdateStages.WithTtl { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java index 105cab8c72deb..9b0fbc426556e 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java @@ -7,11 +7,11 @@ import java.util.List; /** - * An immutable client-side representation of a CName record set in Azure Dns Zone. + * An immutable client-side representation of a CName (canonical name) record set in Azure Dns Zone. */ public interface CnameRecordSet extends DnsRecordSet { /** - * @return the canonical names (without a terminating dot) of CNAME records in this record set + * @return the canonical names (without a terminating dot) of CName records in this record set */ List canonicalNames(); @@ -20,6 +20,7 @@ public interface CnameRecordSet extends DnsRecordSet { */ interface Definition extends DefinitionStages.Blank, + DefinitionStages.WithCanonicalName, DefinitionStages.WithCreate { } @@ -30,8 +31,20 @@ interface DefinitionStages { /** * The first stage of a CName record set definition. */ - interface Blank { - // TODO + interface Blank extends WithCanonicalName { + } + + /** + * The stage of the CName record set definition allowing to add a record. + */ + interface WithCanonicalName { + /** + * Creates a CName record with the provided canonical name in this record set. + * + * @param canonicalName the canonical name + * @return the next stage of the record set definition + */ + WithCreate withCanonicalName(String canonicalName); } /** @@ -55,6 +68,7 @@ interface WithTtl { interface WithCreate extends Creatable, HasTags.DefinitionWithTags, + DefinitionStages.WithCanonicalName, DefinitionStages.WithTtl { } } @@ -63,6 +77,27 @@ interface WithCreate extends * Grouping of CName record set update stages. */ interface UpdateStages { + /** + * The stage of the CName record set update allowing to add or remove a record. + */ + interface WithCanonicalName { + /** + * Creates a CName record with the provided canonical name in this record set. + * + * @param canonicalName the canonical name + * @return the next stage of the record set update + */ + Update withCanonicalName(String canonicalName); + + /** + * Removes a CName record with the provided canonical name from this record set. + * + * @param canonicalName the canonical name + * @return the next stage of the record set update + */ + Update withoutCanonicalName(String canonicalName); + } + /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ @@ -86,6 +121,7 @@ interface WithTtl { interface Update extends Appliable, HasTags.UpdateWithTags, + UpdateStages.WithCanonicalName, UpdateStages.WithTtl { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index daa2e633b1601..727480069bd72 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -5,6 +5,9 @@ import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; +/** + * An immutable client-side representation of a record set in Azure Dns Zone. + */ public interface DnsRecordSet extends ExternalChildResource, HasTags, diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java index 4adf5d9f01463..86741c7bc591d 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java @@ -7,7 +7,7 @@ import java.util.List; /** - * An immutable client-side representation of a Mx record set in Azure Dns Zone. + * An immutable client-side representation of a Mx (mail exchange) record set in Azure Dns Zone. */ public interface MxRecordSet extends DnsRecordSet { /** @@ -20,6 +20,7 @@ public interface MxRecordSet extends DnsRecordSet { */ interface Definition extends DefinitionStages.Blank, + DefinitionStages.WithMailExchange, DefinitionStages.WithCreate { } @@ -30,8 +31,21 @@ interface DefinitionStages { /** * The first stage of a Mx record set definition. */ - interface Blank { - // TODO + interface Blank extends WithMailExchange { + } + + /** + * The stage of the Mx record set definition allowing to add a record. + */ + interface WithMailExchange { + /** + * Creates and assigns priority to a Mx record with the provided mail exchange server in this record set. + * + * @param priority the priority for the mail exchange host, lower the value higher the priority + * @param mailExchangeHostName the host name of the mail exchange server + * @return the next stage of the record set definition + */ + WithCreate withMailExchange(int priority, String mailExchangeHostName); } /** @@ -55,6 +69,7 @@ interface WithTtl { interface WithCreate extends Creatable, HasTags.DefinitionWithTags, + DefinitionStages.WithMailExchange, DefinitionStages.WithTtl { } } @@ -63,6 +78,29 @@ interface WithCreate extends * Grouping of Mx record set update stages. */ interface UpdateStages { + /** + * The stage of the Mx record set definition allowing to add or remove a record. + */ + interface WithMailExchange { + /** + * Creates and assigns priority to a Mx record with the provided mail exchange server in this record set. + * + * @param priority the priority for the mail exchange host, lower the value higher the priority + * @param mailExchangeHostName the host name of the mail exchange server + * @return the next stage of the record set update + */ + Update withMailExchange(int priority, String mailExchangeHostName); + + /** + * Removes a Mx record with the provided priority and mail exchange server from this record set. + * + * @param priority the priority for the mail exchange host + * @param mailExchangeHostName the host name of the mail exchange server + * @return the next stage of the record set update + */ + Update withoutMailExchange(int priority, String mailExchangeHostName); + } + /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ @@ -86,6 +124,7 @@ interface WithTtl { interface Update extends Appliable, HasTags.UpdateWithTags, + UpdateStages.WithMailExchange, UpdateStages.WithTtl { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java index f78a97706f5f6..527537db4ad29 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java @@ -8,7 +8,7 @@ public interface NsRecordSet extends DnsRecordSet { /** - * @return the name server names of Ns records in this record set + * @return the name server names of Ns (name server) records in this record set */ List nameServers(); @@ -17,6 +17,7 @@ public interface NsRecordSet extends DnsRecordSet { */ interface Definition extends DefinitionStages.Blank, + DefinitionStages.WithNameServer, DefinitionStages.WithCreate { } @@ -27,8 +28,20 @@ interface DefinitionStages { /** * The first stage of a Ns record set definition. */ - interface Blank { - // TODO + interface Blank extends WithNameServer { + } + + /** + * The stage of the Ns record set definition allowing to add a record. + */ + interface WithNameServer { + /** + * Creates a Ns record with the provided name server in this record set. + * + * @param nameServerHostName the name server host name + * @return the next stage of the record set definition + */ + WithCreate withNameServer(String nameServerHostName); } /** @@ -52,6 +65,7 @@ interface WithTtl { interface WithCreate extends Creatable, HasTags.DefinitionWithTags, + DefinitionStages.WithNameServer, DefinitionStages.WithTtl { } } @@ -60,6 +74,27 @@ interface WithCreate extends * Grouping of Ns record set update stages. */ interface UpdateStages { + /** + * The stage of the Ns record set definition allowing to add or remove a record. + */ + interface WithNameServer { + /** + * Creates a Ns record with the provided name server in this record set. + * + * @param nameServerHostName the name server host name + * @return the next stage of the record set definition + */ + Update withNameServer(String nameServerHostName); + + /** + * Removes a Ns record with the provided name server from this record set. + * + * @param nameServerHostName the name server host name + * @return the next stage of the record set definition + */ + Update withoutNameServer(String nameServerHostName); + } + /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ @@ -83,6 +118,7 @@ interface WithTtl { interface Update extends Appliable, HasTags.UpdateWithTags, + UpdateStages.WithNameServer, UpdateStages.WithTtl { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java index cbd93c5898d95..8049b1601dd8f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java @@ -7,7 +7,7 @@ import java.util.List; /** - * An immutable client-side representation of a Ptr record set in Azure Dns Zone. + * An immutable client-side representation of a Ptr (pointer) record set in Azure Dns Zone. */ public interface PtrRecordSet extends DnsRecordSet { /** @@ -20,6 +20,7 @@ public interface PtrRecordSet extends DnsRecordSet { */ interface Definition extends DefinitionStages.Blank, + DefinitionStages.WithTargetDomain, DefinitionStages.WithCreate { } @@ -30,8 +31,20 @@ interface DefinitionStages { /** * The first stage of a Ptr record set definition. */ - interface Blank { - // TODO + interface Blank extends WithTargetDomain { + } + + /** + * The stage of the Ptr record set definition allowing to add a record. + */ + interface WithTargetDomain { + /** + * Creates a Ptr record with the provided target domain in this record set. + * + * @param targetDomainName the name of the target domain + * @return the next stage of the record set definition + */ + WithCreate withTargetDomain(String targetDomainName); } /** @@ -55,6 +68,7 @@ interface WithTtl { interface WithCreate extends Creatable, HasTags.DefinitionWithTags, + DefinitionStages.WithTargetDomain, DefinitionStages.WithTtl { } } @@ -63,6 +77,27 @@ interface WithCreate extends * Grouping of Ptr record set update stages. */ interface UpdateStages { + /** + * The stage of the Ptr record set definition allowing to add or remove a record. + */ + interface WithTargetDomain { + /** + * Creates a Ptr record with the provided target domain in this record set. + * + * @param targetDomainName the name of the target domain + * @return the next stage of the record set update + */ + Update withTargetDomain(String targetDomainName); + + /** + * Removes a Ptr record with the provided target domain from this record set. + * + * @param targetDomainName the name of the target domain + * @return the next stage of the record set update + */ + Update withoutTargetDomain(String targetDomainName); + } + /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ @@ -86,6 +121,7 @@ interface WithTtl { interface Update extends Appliable, HasTags.UpdateWithTags, + UpdateStages.WithTargetDomain, UpdateStages.WithTtl { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java index f2554b8484e55..f9e917aa03d96 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java @@ -1,13 +1,131 @@ package com.microsoft.azure.management.dns; -import java.util.List; +import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; /** - * An immutable client-side representation of a Soa record set in Azure Dns Zone. + * An immutable client-side representation of a Soa (start of authority) record set in Azure Dns Zone. */ public interface SoaRecordSet extends DnsRecordSet { /** - * @return the Soa records in this record set + * @return the Soa record in this record set */ - List records(); + SoaRecord record(); + + /** + * Grouping of Soa record set update stages. + */ + interface UpdateStages { + /** + * The stage of the Soa record set definition allowing specify the email server. + */ + interface WithEmailServer { + /** + * Specifies the email server associated with the Soa record. + * + * @param emailServerHostName the email server + * @return the next stage of the record set update + */ + Update withEmailServer(String emailServerHostName); + } + + /** + * The stage of the Soa record set definition allowing to specify the refresh time. + */ + interface WithRefreshTime { + /** + * Specifies time in seconds that a secondary name server should wait before trying to contact the + * the primary name server for a zone file update. + * + * @param refreshTimeInSeconds the refresh time in seconds + * @return the next stage of the record set update + */ + Update withRefreshTimeInSeconds(int refreshTimeInSeconds); + } + + /** + * The stage of the Soa record set definition allowing to specify the retry time. + */ + interface WithRetryTime { + /** + * Specifies the time in seconds that a secondary name server should wait before trying to contact + * the primary name server again after a failed attempt to check for a zone file update. + * + * @param refreshTimeInSeconds the retry time in seconds + * @return the next stage of the record set update + */ + Update withRetryTimeInSeconds(int refreshTimeInSeconds); + } + + /** + * The stage of the Soa record set definition allowing to specify the expire time. + */ + interface WithExpireTime { + /** + * Specifies the time in seconds that a secondary name server will treat its cached zone file as valid + * when the primary name server cannot be contacted. + * + * @param expireTimeInSeconds the expire time in seconds + * @return the next stage of the record set update + */ + Update withExpireTimeInSeconds(int expireTimeInSeconds); + } + + /** + * The stage of the Soa record set definition allowing to specify the Ttl for cached negative response. + */ + interface WithNegativeCachingTtl { + /** + * Specifies the time in seconds that any name server or resolver should cache a negative response. + * + * @param negativeCachingTimeToLive the Ttl for cached negative response + * @return the next stage of the record set update + */ + Update withNegativeCachingTimeToLiveInSeconds(int negativeCachingTimeToLive); + } + + /** + * The stage of the Soa record set definition allowing to specify the serial number. + */ + interface WithSerialNumber { + /** + * Specifies the serial number for the zone file. + * + * @param serialNumber the serial number + * @return the next stage of the record set update + */ + Update withSerialNumber(int serialNumber); + } + + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } + } + + /** + * The template for an update operation, containing all the settings that + * can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + HasTags.UpdateWithTags, + UpdateStages.WithEmailServer, + UpdateStages.WithRefreshTime, + UpdateStages.WithRetryTime, + UpdateStages.WithExpireTime, + UpdateStages.WithNegativeCachingTtl, + UpdateStages.WithSerialNumber, + UpdateStages.WithTtl { + } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java index b2b9af2dbd2ed..e23b167e67681 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java @@ -7,7 +7,7 @@ import java.util.List; /** - * An immutable client-side representation of a Txt record set in Azure Dns Zone. + * An immutable client-side representation of a Txt (text) record set in Azure Dns Zone. */ public interface TxtRecordSet extends DnsRecordSet { /** @@ -20,6 +20,7 @@ public interface TxtRecordSet extends DnsRecordSet { */ interface Definition extends DefinitionStages.Blank, + DefinitionStages.WithText, DefinitionStages.WithCreate { } @@ -30,8 +31,20 @@ interface DefinitionStages { /** * The first stage of a Txt record set definition. */ - interface Blank { - // TODO + interface Blank extends WithText { + } + + /** + * The stage of the Txt record set definition allowing to add a record. + */ + interface WithText { + /** + * Creates a Txt record with the given text in this record set. + * + * @param text the text value + * @return the next stage of the record set definition + */ + WithCreate withText(String text); } /** @@ -55,6 +68,7 @@ interface WithTtl { interface WithCreate extends Creatable, HasTags.DefinitionWithTags, + DefinitionStages.WithText, DefinitionStages.WithTtl { } } @@ -63,6 +77,27 @@ interface WithCreate extends * Grouping of Txt record set update stages. */ interface UpdateStages { + /** + * The stage of the Txt record set definition allowing to add or remove a record. + */ + interface WithText { + /** + * Creates a Txt record with the given text in this record set. + * + * @param text the text value + * @return the next stage of the record set update + */ + Update withText(String text); + + /** + * Removes Txt record with the given text from this record set. + * + * @param text the text value + * @return the next stage of the record set update + */ + Update withoutText(String text); + } + /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ @@ -86,6 +121,7 @@ interface WithTtl { interface Update extends Appliable, HasTags.UpdateWithTags, + UpdateStages.WithText, UpdateStages.WithTtl { } } From d60b6f480ab3dadf1fbd269a0719ba49220763a3 Mon Sep 17 00:00:00 2001 From: anuchan Date: Tue, 1 Nov 2016 15:52:21 -0700 Subject: [PATCH 03/27] extending record sets collection interface from various operation interfaces --- .../azure/management/dns/ARecordSets.java | 16 ++++++++++++++-- .../azure/management/dns/AaaaRecordSets.java | 16 ++++++++++++++-- .../azure/management/dns/CnameRecordSets.java | 16 ++++++++++++++-- .../azure/management/dns/DnsRecordSets.java | 19 +++++++++++++++++++ .../azure/management/dns/DnsZone.java | 5 ++--- .../azure/management/dns/MxRecordSets.java | 18 +++++++++++++++--- .../azure/management/dns/NsRecordSets.java | 18 +++++++++++++++--- .../azure/management/dns/PtrRecordSets.java | 16 ++++++++++++++-- .../azure/management/dns/SoaRecordSets.java | 13 +++++++++++-- .../azure/management/dns/SrvRecordSets.java | 18 +++++++++++++++--- .../azure/management/dns/TxtRecordSets.java | 18 +++++++++++++++--- 11 files changed, 148 insertions(+), 25 deletions(-) create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java index c8e8464637ea7..dbae95b48a512 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java @@ -1,7 +1,19 @@ package com.microsoft.azure.management.dns; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + /** - * Created by anuthomaschandy on 10/31/16. + * Entry point to Dns zone A record set management API. */ -public interface ARecordSets { +@Fluent +public interface ARecordSets extends + DnsRecordSets, + SupportsListing, + SupportsGettingById, + SupportsCreating, + SupportsDeletingById { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java index 2b2412f58b0e8..e7d3236745b8f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java @@ -1,7 +1,19 @@ package com.microsoft.azure.management.dns; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + /** - * Created by anuthomaschandy on 10/31/16. + * Entry point to Dns zone Aaaa record set management API. */ -public interface AaaaRecordSets { +@Fluent +public interface AaaaRecordSets extends + DnsRecordSets, + SupportsListing, + SupportsGettingById, + SupportsCreating, + SupportsDeletingById { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java index a96c0af257bb1..b5f1d7720830a 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java @@ -1,7 +1,19 @@ package com.microsoft.azure.management.dns; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + /** - * Created by anuthomaschandy on 10/31/16. + * Entry point to Dns zone CName record set management API. */ -public interface CnameRecordSets { +@Fluent +public interface CnameRecordSets extends + DnsRecordSets, + SupportsListing, + SupportsGettingById, + SupportsCreating, + SupportsDeletingById { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java new file mode 100644 index 0000000000000..3fe3a5900ec25 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java @@ -0,0 +1,19 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.apigeneration.Fluent; + +/** + * Base interface for various Dns record sets. + * + * @param the type of the record set + */ +@Fluent +public interface DnsRecordSets { + /** + * Gets the information about a Dns record set from Azure based on name. + * + * @param name the name of the record set + * @return the record set + */ + FluentRecordSetModelT getByName(String name); +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java index 93ce1fd466377..cc4a2d8bb414a 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java @@ -12,7 +12,6 @@ import java.util.List; - /** * An immutable client-side representation of an Azure DNS Zone. */ @@ -78,9 +77,9 @@ public interface DnsZone extends TxtRecordSets txtRecordSets(); /** - * @return entry point to manage record sets in this zone containing Soa (start of authority) records + * @return the Soa (start of authority) record associated with this Dns zone */ - SoaRecordSets soaRecordSets(); + SoaRecord getSoaRecord(); /** * The entirety of the Dns zone definition. diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java index 7266af6e40c30..6a7aa036e2303 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java @@ -1,7 +1,19 @@ package com.microsoft.azure.management.dns; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + /** - * Created by anuthomaschandy on 10/31/16. + * Entry point to Dns zone Mx record set management API. */ -public interface MxRecordSets { -} +@Fluent +public interface MxRecordSets extends + DnsRecordSets, + SupportsListing, + SupportsGettingById, + SupportsCreating, + SupportsDeletingById { +} \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java index 52eff66349131..66541056cb632 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java @@ -1,7 +1,19 @@ package com.microsoft.azure.management.dns; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + /** - * Created by anuthomaschandy on 10/31/16. + * Entry point to Dns zone Ns record set management API. */ -public interface NsRecordSets { -} +@Fluent +public interface NsRecordSets extends + DnsRecordSets, + SupportsListing, + SupportsGettingById, + SupportsCreating, + SupportsDeletingById { +} \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java index 463cf497ba991..7e8fb2c1cfea2 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java @@ -1,7 +1,19 @@ package com.microsoft.azure.management.dns; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + /** - * Created by anuthomaschandy on 10/31/16. + * Entry point to Dns zone Ptr record set management API. */ -public interface PtrRecordSets { +@Fluent +public interface PtrRecordSets extends + DnsRecordSets, + SupportsListing, + SupportsGettingById, + SupportsCreating, + SupportsDeletingById { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java index 4b296a89700ca..b7ef30ed1bba2 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java @@ -1,7 +1,16 @@ package com.microsoft.azure.management.dns; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + /** - * Created by anuthomaschandy on 10/31/16. + * Entry point to Dns zone Soa record set management API. */ -public class SoaRecordSets { +@Fluent +public interface SoaRecordSets extends + DnsRecordSets, + SupportsListing, + SupportsGettingById { } + diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java index a050695f2c3c0..d3a3b7576da4d 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java @@ -1,7 +1,19 @@ package com.microsoft.azure.management.dns; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + /** - * Created by anuthomaschandy on 10/31/16. + * Entry point to Dns zone Srv record set management API. */ -public interface SrvRecordSets { -} +@Fluent +public interface SrvRecordSets extends + DnsRecordSets, + SupportsListing, + SupportsGettingById, + SupportsCreating, + SupportsDeletingById { +} \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java index 3a0573ad3aa60..d6b39a41be6a9 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java @@ -1,7 +1,19 @@ package com.microsoft.azure.management.dns; +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + /** - * Created by anuthomaschandy on 10/31/16. + * Entry point to Dns zone Txt record set management API. */ -public interface TxtRecordSets { -} +@Fluent +public interface TxtRecordSets extends + DnsRecordSets, + SupportsListing, + SupportsGettingById, + SupportsCreating, + SupportsDeletingById { +} \ No newline at end of file From 3551fb6583adc7635a60594e30344a046274b672 Mon Sep 17 00:00:00 2001 From: anuchan Date: Tue, 1 Nov 2016 17:40:51 -0700 Subject: [PATCH 04/27] Adding dns manager and couple of impls --- .../azure/management/dns/DnsZone.java | 4 +- .../azure/management/dns/DnsZones.java | 26 ++++ .../dns/implementation/DnsRecordSetImpl.java | 2 +- .../dns/implementation/DnsZoneImpl.java | 133 +++++++++++++++++- .../dns/implementation/DnsZoneManager.java | 94 +++++++++++++ .../dns/implementation/DnsZonesImpl.java | 71 ++++++++++ 6 files changed, 325 insertions(+), 5 deletions(-) create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZones.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZonesImpl.java diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java index cc4a2d8bb414a..a8ffb08d92887 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java @@ -77,9 +77,9 @@ public interface DnsZone extends TxtRecordSets txtRecordSets(); /** - * @return the Soa (start of authority) record associated with this Dns zone + * @return the record set containing Soa (start of authority) record associated with this Dns zone */ - SoaRecord getSoaRecord(); + SoaRecordSet getSoaRecordSet(); /** * The entirety of the Dns zone definition. diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZones.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZones.java new file mode 100644 index 0000000000000..e1af3df423806 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZones.java @@ -0,0 +1,26 @@ +package com.microsoft.azure.management.dns; + +import com.microsoft.azure.management.apigeneration.Fluent; +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.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + +/** + * Entry point to Dns zone management API in Azure. + */ +@Fluent() +public interface DnsZones extends + SupportsCreating, + SupportsListing, + SupportsListingByGroup, + SupportsGettingByGroup, + SupportsGettingById, + SupportsDeletingById, + SupportsDeletingByGroup, + SupportsBatchCreation { +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index 0cde3d3ce38c3..5e67fd74ee2f2 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -20,7 +20,7 @@ abstract class DnsRecordSetImpl + implements + DnsZone, + DnsZone.Definition, + DnsZone.Update { + private final ZonesInner innerCollection; + private final RecordSetsInner recordSetsClient; + + private ARecordSets aRecordSets; + private AaaaRecordSets aaaaRecordSets; + private CnameRecordSets cnameRecordSets; + private MxRecordSets mxRecordSets; + private NsRecordSets nsRecordSets; + private PtrRecordSets ptrRecordSets; + private SrvRecordSets srvRecordSets; + private TxtRecordSets txtRecordSets; + + DnsZoneImpl(String name, + final ZoneInner innerModel, + final ZonesInner innerCollection, + final RecordSetsInner recordSetsClient, + final DnsZoneManager trafficManager) { + super(name, innerModel, trafficManager); + this.innerCollection = innerCollection; + this.recordSetsClient = recordSetsClient; + initRecordSets(); + } + + @Override + public long maxNumberOfRecordSets() { + return this.inner().maxNumberOfRecordSets(); + } + + @Override + public long numberOfRecordSets() { + return this.inner().numberOfRecordSets(); + } + + @Override + public List nameServers() { + return this.inner().nameServers(); + } + + @Override + public ARecordSets aRecordSets() { + return this.aRecordSets; + } + + @Override + public AaaaRecordSets aaaaRecordSets() { + return this.aaaaRecordSets; + } + + @Override + public CnameRecordSets cnameRecordSets() { + return this.cnameRecordSets; + } + + @Override + public MxRecordSets mxRecordSets() { + return this.mxRecordSets; + } + + @Override + public NsRecordSets nsRecordSets() { + return this.nsRecordSets; + } + + @Override + public PtrRecordSets ptrRecordSets() { + return this.ptrRecordSets; + } + + @Override + public SrvRecordSets srvRecordSets() { + return this.srvRecordSets; + } + + @Override + public TxtRecordSets txtRecordSets() { + return this.txtRecordSets; + } + + @Override + public SoaRecordSet getSoaRecordSet() { + // TODO: Do HTTP GET + return null; + } + + @Override + public Observable createResourceAsync() { + return null; + } + + @Override + public DnsZone refresh() { + return null; + } + + private void initRecordSets() { + this.aRecordSets = null; + this.aaaaRecordSets = null; + this.cnameRecordSets = null; + this.mxRecordSets = null; + this.nsRecordSets = null; + this.ptrRecordSets = null; + this.srvRecordSets = null; + this.txtRecordSets = null; + } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java new file mode 100644 index 0000000000000..170ca666ee353 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java @@ -0,0 +1,94 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.RestClient; +import com.microsoft.azure.credentials.AzureTokenCredentials; +import com.microsoft.azure.management.dns.DnsZones; +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; + +/** + * Entry point to Azure Dns zone manager management. + */ +public class DnsZoneManager extends Manager { + // Collections + private DnsZones zones; + + /** + * Get a Configurable instance that can be used to create {@link DnsZoneManager} + * with optional configuration. + * + * @return the instance allowing configurations + */ + public static Configurable configure() { + return new DnsZoneManager.ConfigurableImpl(); + } + + /** + * Creates an instance of DnsZoneManager that exposes Dns zone manager management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the DnsZoneManager + */ + public static DnsZoneManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return new DnsZoneManager(credentials.getEnvironment().newRestClientBuilder() + .withCredentials(credentials) + .build(), subscriptionId); + } + + /** + * Creates an instance of DnsZoneManager that exposes Dns zone manager management API entry points. + * + * @param restClient the RestClient to be used for API calls. + * @param subscriptionId the subscription UUID + * @return the DnsZoneManager + */ + public static DnsZoneManager authenticate(RestClient restClient, String subscriptionId) { + return new DnsZoneManager(restClient, subscriptionId); + } + + /** + * The interface allowing configurations to be set. + */ + public interface Configurable extends AzureConfigurable { + /** + * Creates an instance of DnsZoneManager that exposes traffic manager management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the interface exposing Dns zone manager management API entry points that work across subscriptions + */ + DnsZoneManager authenticate(AzureTokenCredentials credentials, String subscriptionId); + } + + /** + * The implementation for Configurable interface. + */ + private static class ConfigurableImpl + extends AzureConfigurableImpl + implements Configurable { + + public DnsZoneManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return DnsZoneManager.authenticate(buildRestClient(credentials), subscriptionId); + } + } + + private DnsZoneManager(RestClient restClient, String subscriptionId) { + super(restClient, + subscriptionId, + new DnsManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); + } + + /** + * @return entry point to Dns zone manager profile management + */ + public DnsZones zones() { + if (this.zones == null) { + this.zones = new DnsZonesImpl( + super.innerManagementClient, + this); + } + return this.zones; + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZonesImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZonesImpl.java new file mode 100644 index 0000000000000..4612d57f3232f --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZonesImpl.java @@ -0,0 +1,71 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.DnsZone; +import com.microsoft.azure.management.dns.DnsZones; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import rx.Observable; + +/** + * Implementation of {@link DnsZones}. + */ +class DnsZonesImpl extends GroupableResourcesImpl< + DnsZone, + DnsZoneImpl, + ZoneInner, + ZonesInner, + DnsZoneManager> + implements DnsZones { + private final RecordSetsInner recordSetsClient; + + DnsZonesImpl( + final DnsManagementClientImpl dnsManagementClient, + final DnsZoneManager dnsZoneManager) { + super(dnsManagementClient.zones(), dnsZoneManager); + this.recordSetsClient = dnsManagementClient.recordSets(); + } + + @Override + public PagedList list() { + return wrapList(this.innerCollection.listInSubscription()); + } + + @Override + public PagedList listByGroup(String groupName) { + return wrapList(this.innerCollection.listInResourceGroup(groupName)); + } + + @Override + public DnsZone getByGroup(String groupName, String name) { + return wrapModel(this.innerCollection.get(groupName, name)); + } + + @Override + public Observable deleteByGroupAsync(String groupName, String name) { + this.innerCollection.deleteAsync(groupName, name); + return Observable.just(null); + } + + @Override + public DnsZoneImpl define(String name) { + return wrapModel(name); + } + + @Override + protected DnsZoneImpl wrapModel(String name) { + return new DnsZoneImpl(name, + new ZoneInner(), + this.innerCollection, + this.recordSetsClient, + this.myManager); + } + + @Override + protected DnsZoneImpl wrapModel(ZoneInner inner) { + return new DnsZoneImpl(inner.name(), + inner, + this.innerCollection, + this.recordSetsClient, + this.myManager); + } +} From 8e643a02024d5c1dbdfbaad784a656ef9212db57 Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 2 Nov 2016 12:01:27 -0700 Subject: [PATCH 05/27] Implementing recordset Impls --- .../azure/management/dns/CnameRecordSet.java | 27 +----------- .../azure/management/dns/DnsRecordSet.java | 2 +- .../dns/implementation/ARecordSetImpl.java | 42 ++++++++++++++++++ .../dns/implementation/AaaaRecordSetImpl.java | 43 +++++++++++++++++++ .../implementation/CnameRecordSetImpl.java | 35 +++++++++++++++ .../dns/implementation/DnsRecordSetImpl.java | 40 +++++++++++++++-- .../dns/implementation/MxRecordSetImpl.java | 40 +++++++++++++++++ .../dns/implementation/NsRecordSetImpl.java | 43 +++++++++++++++++++ .../dns/implementation/PtrRecordSetImpl.java | 43 +++++++++++++++++++ .../dns/implementation/TxtRecordSetImpl.java | 41 ++++++++++++++++++ 10 files changed, 327 insertions(+), 29 deletions(-) create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java index 9b0fbc426556e..7c0ace5c8f86f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java @@ -11,9 +11,9 @@ */ public interface CnameRecordSet extends DnsRecordSet { /** - * @return the canonical names (without a terminating dot) of CName records in this record set + * @return the canonical name (without a terminating dot) of CName record in this record set */ - List canonicalNames(); + String canonicalName(); /** * The entirety of the CName record set definition. @@ -68,7 +68,6 @@ interface WithTtl { interface WithCreate extends Creatable, HasTags.DefinitionWithTags, - DefinitionStages.WithCanonicalName, DefinitionStages.WithTtl { } } @@ -77,27 +76,6 @@ interface WithCreate extends * Grouping of CName record set update stages. */ interface UpdateStages { - /** - * The stage of the CName record set update allowing to add or remove a record. - */ - interface WithCanonicalName { - /** - * Creates a CName record with the provided canonical name in this record set. - * - * @param canonicalName the canonical name - * @return the next stage of the record set update - */ - Update withCanonicalName(String canonicalName); - - /** - * Removes a CName record with the provided canonical name from this record set. - * - * @param canonicalName the canonical name - * @return the next stage of the record set update - */ - Update withoutCanonicalName(String canonicalName); - } - /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ @@ -121,7 +99,6 @@ interface WithTtl { interface Update extends Appliable, HasTags.UpdateWithTags, - UpdateStages.WithCanonicalName, UpdateStages.WithTtl { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index 727480069bd72..a202f828324ea 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -16,7 +16,7 @@ public interface DnsRecordSet extends /** * @return the type of records in this record set */ - String recordType(); + RecordType recordType(); /** * @return TTL of the records in this record set diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java new file mode 100644 index 0000000000000..a981bd0119295 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java @@ -0,0 +1,42 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.ARecord; +import com.microsoft.azure.management.dns.ARecordSet; +import rx.functions.Func1; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Implementation of {@link ARecordSet} + */ +class ARecordSetImpl + extends DnsRecordSetImpl + implements ARecordSet { + ARecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parentDnsZone, innerModel, client); + } + + @Override + public List ipv4Addresses() { + List ipv6Addresses = new ArrayList<>(); + if (this.inner().aaaaRecords() != null) { + for (ARecord aRecord : this.inner().aRecords()) { + ipv6Addresses.add(aRecord.ipv4Address()); + } + } + return Collections.unmodifiableList(ipv6Addresses); + } + + @Override + public ARecordSetImpl refresh() { + this.resetInner(); + return this; + } + + @Override + protected Func1 innerToFluentMap() { + return super.innerToFluentMap(this); + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java new file mode 100644 index 0000000000000..4342a036f3109 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java @@ -0,0 +1,43 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.AaaaRecord; +import com.microsoft.azure.management.dns.AaaaRecordSet; +import rx.functions.Func1; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Implementation of {@link AaaaRecordSet} + */ +class AaaaRecordSetImpl + extends DnsRecordSetImpl + implements AaaaRecordSet { + + AaaaRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parentDnsZone, innerModel, client); + } + + @Override + public List ipv6Addresses() { + List ipv6Addresses = new ArrayList<>(); + if (this.inner().aaaaRecords() != null) { + for (AaaaRecord aaaaRecord : this.inner().aaaaRecords()) { + ipv6Addresses.add(aaaaRecord.ipv6Address()); + } + } + return Collections.unmodifiableList(ipv6Addresses); + } + + @Override + public AaaaRecordSetImpl refresh() { + this.resetInner(); + return this; + } + + @Override + protected Func1 innerToFluentMap() { + return super.innerToFluentMap(this); + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java new file mode 100644 index 0000000000000..e30e6bc1159ae --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java @@ -0,0 +1,35 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.ARecordSet; +import com.microsoft.azure.management.dns.CnameRecordSet; +import rx.functions.Func1; + +/** + * Implementation of {@link ARecordSet} + */ +class CnameRecordSetImpl + extends DnsRecordSetImpl + implements CnameRecordSet { + CnameRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parentDnsZone, innerModel, client); + } + + @Override + public String canonicalName() { + if ( this.inner().cnameRecord() != null) { + return this.inner().cnameRecord().cname(); + } + return null; + } + + @Override + public CnameRecordSetImpl refresh() { + this.resetInner(); + return this; + } + + @Override + protected Func1 innerToFluentMap() { + return super.innerToFluentMap(this); + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index 5e67fd74ee2f2..20c1fcdd05d35 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -1,7 +1,12 @@ package com.microsoft.azure.management.dns.implementation; import com.microsoft.azure.management.dns.DnsRecordSet; +import com.microsoft.azure.management.dns.DnsZone; +import com.microsoft.azure.management.dns.RecordType; import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl; +import rx.Observable; +import rx.functions.Func1; + import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; @@ -16,7 +21,7 @@ abstract class DnsRecordSetImpl> extends CreatableUpdatableImpl - implements DnsRecordSet { + implements DnsRecordSet { protected final DnsZoneImpl dnsZone; protected final RecordSetsInner client; @@ -32,8 +37,8 @@ public String id() { } @Override - public String recordType() { - return this.inner().type(); + public RecordType recordType() { + return RecordType.fromString(this.inner().type()); } @Override @@ -41,6 +46,11 @@ public long timeToLive() { return this.inner().tTL(); } + @Override + public DnsZoneImpl parent() { + return this.dnsZone; + } + @Override public Map tags() { if (this.inner().metadata() == null) { @@ -68,4 +78,28 @@ public FluentModelImplT withTimeToLive(long ttlInSeconds) { this.inner().withTTL(ttlInSeconds); return (FluentModelImplT) this; } + + @Override + public boolean isInCreateMode() { + return this.inner().id() == null; + } + + @Override + public Observable createResourceAsync() { + return client.createOrUpdateAsync(this.parent().resourceGroupName(), + this.parent().name(), + this.name(), + this.recordType(), + this.inner()) + .map(innerToFluentMap()); + } + + protected void resetInner() { + this.setInner(this.client.get(this.parent().resourceGroupName(), + this.parent().name(), + this.name(), + this.recordType())); + } + + protected abstract Func1 innerToFluentMap(); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java new file mode 100644 index 0000000000000..97523e7b04b0b --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -0,0 +1,40 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.MxRecord; +import com.microsoft.azure.management.dns.MxRecordSet; +import rx.functions.Func1; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Implementation of {@link MxRecordSet} + */ +class MxRecordSetImpl + extends DnsRecordSetImpl + implements MxRecordSet { + MxRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parentDnsZone, innerModel, client); + } + + @Override + public List records() { + if (this.inner().mxRecords() != null) { + return Collections.unmodifiableList(this.inner().mxRecords()); + } + return Collections.unmodifiableList(new ArrayList()); + } + + @Override + public MxRecordSetImpl refresh() { + this.resetInner(); + return this; + } + + @Override + protected Func1 innerToFluentMap() { + return super.innerToFluentMap(this); + } +} + diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java new file mode 100644 index 0000000000000..724e27ec21123 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java @@ -0,0 +1,43 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.NsRecord; +import com.microsoft.azure.management.dns.NsRecordSet; +import rx.functions.Func1; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Implementation of {@link NsRecordSet} + */ +class NsRecordSetImpl + extends DnsRecordSetImpl + implements NsRecordSet { + NsRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parentDnsZone, innerModel, client); + } + + @Override + public List nameServers() { + List nameServers = new ArrayList<>(); + if (this.inner().aaaaRecords() != null) { + for (NsRecord nsRecord : this.inner().nsRecords()) { + nameServers.add(nsRecord.nsdname()); + } + } + return Collections.unmodifiableList(nameServers); + } + + @Override + public NsRecordSetImpl refresh() { + this.resetInner(); + return this; + } + + @Override + protected Func1 innerToFluentMap() { + return super.innerToFluentMap(this); + } +} + diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java new file mode 100644 index 0000000000000..f3f703093240f --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java @@ -0,0 +1,43 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.PtrRecord; +import com.microsoft.azure.management.dns.PtrRecordSet; +import rx.functions.Func1; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Implementation of {@link PtrRecordSet} + */ +class PtrRecordSetImpl + extends DnsRecordSetImpl + implements PtrRecordSet { + PtrRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parentDnsZone, innerModel, client); + } + + @Override + public List targetDomainNames() { + List targetDomainNames = new ArrayList<>(); + if (this.inner().aaaaRecords() != null) { + for (PtrRecord ptrRecord : this.inner().ptrRecords()) { + targetDomainNames.add(ptrRecord.ptrdname()); + } + } + return Collections.unmodifiableList(targetDomainNames); + } + + @Override + public PtrRecordSetImpl refresh() { + this.resetInner(); + return this; + } + + @Override + protected Func1 innerToFluentMap() { + return super.innerToFluentMap(this); + } +} + diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java new file mode 100644 index 0000000000000..165abb2729492 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java @@ -0,0 +1,41 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.TxtRecord; +import com.microsoft.azure.management.dns.TxtRecordSet; +import rx.functions.Func1; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Implementation of {@link TxtRecordSet} + */ +class TxtRecordSetImpl + extends DnsRecordSetImpl + implements TxtRecordSet { + TxtRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parentDnsZone, innerModel, client); + } + + @Override + public List records() { + if (this.inner().txtRecords() != null) { + return Collections.unmodifiableList(this.inner().txtRecords()); + } + return Collections.unmodifiableList(new ArrayList()); + } + + @Override + public TxtRecordSetImpl refresh() { + this.resetInner(); + return this; + } + + @Override + protected Func1 innerToFluentMap() { + return super.innerToFluentMap(this); + } +} + + From c4d4e9035f5cb89cf859285b3e8ac2628786b258 Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 2 Nov 2016 14:38:15 -0700 Subject: [PATCH 06/27] Implementing definition-stages for all recordsets types --- .../azure/management/dns/AaaaRecordSet.java | 2 +- .../azure/management/dns/CnameRecordSet.java | 4 +- .../azure/management/dns/MxRecordSet.java | 12 ++-- .../azure/management/dns/SoaRecordSet.java | 10 +-- .../azure/management/dns/SrvRecordSet.java | 55 ++++++++++++-- .../azure/management/dns/TxtRecordSet.java | 4 +- .../dns/implementation/ARecordSetImpl.java | 29 +++++++- .../dns/implementation/AaaaRecordSetImpl.java | 29 +++++++- .../implementation/CnameRecordSetImpl.java | 14 +++- .../dns/implementation/DnsRecordSetImpl.java | 2 +- .../dns/implementation/DnsZoneImpl.java | 13 ++-- .../dns/implementation/MxRecordSetImpl.java | 29 +++++++- .../dns/implementation/NsRecordSetImpl.java | 29 +++++++- .../dns/implementation/PtrRecordSetImpl.java | 29 +++++++- .../dns/implementation/SoaRecordSetImpl.java | 70 ++++++++++++++++++ .../dns/implementation/SrvRecordSetImpl.java | 71 +++++++++++++++++++ .../dns/implementation/TxtRecordSetImpl.java | 33 ++++++++- 17 files changed, 394 insertions(+), 41 deletions(-) create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java index 483b12b8294b6..bc9b12ea84977 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java @@ -44,7 +44,7 @@ interface WithIpv6Address { * @param ipv6Address the Ipv6 address * @return the next stage of the record set definition */ - WithCreate withIp6Address(String ipv6Address); + WithCreate withIpv6Address(String ipv6Address); } /** diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java index 7c0ace5c8f86f..39c7286007ddb 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java @@ -66,7 +66,7 @@ interface WithTtl { * for any other optional settings to be specified. */ interface WithCreate extends - Creatable, + Creatable, HasTags.DefinitionWithTags, DefinitionStages.WithTtl { } @@ -97,7 +97,7 @@ interface WithTtl { * Call {@link Update#apply()} to apply the changes to the resource in Azure. */ interface Update extends - Appliable, + Appliable, HasTags.UpdateWithTags, UpdateStages.WithTtl { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java index 86741c7bc591d..5546741d736f9 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java @@ -41,11 +41,11 @@ interface WithMailExchange { /** * Creates and assigns priority to a Mx record with the provided mail exchange server in this record set. * - * @param priority the priority for the mail exchange host, lower the value higher the priority * @param mailExchangeHostName the host name of the mail exchange server + * @param priority the priority for the mail exchange host, lower the value higher the priority * @return the next stage of the record set definition */ - WithCreate withMailExchange(int priority, String mailExchangeHostName); + WithCreate withMailExchange(String mailExchangeHostName, int priority); } /** @@ -85,20 +85,20 @@ interface WithMailExchange { /** * Creates and assigns priority to a Mx record with the provided mail exchange server in this record set. * - * @param priority the priority for the mail exchange host, lower the value higher the priority * @param mailExchangeHostName the host name of the mail exchange server + * @param priority the priority for the mail exchange host, lower the value higher the priority * @return the next stage of the record set update */ - Update withMailExchange(int priority, String mailExchangeHostName); + Update withMailExchange(String mailExchangeHostName, int priority); /** * Removes a Mx record with the provided priority and mail exchange server from this record set. * - * @param priority the priority for the mail exchange host * @param mailExchangeHostName the host name of the mail exchange server + * @param priority the priority for the mail exchange host * @return the next stage of the record set update */ - Update withoutMailExchange(int priority, String mailExchangeHostName); + Update withoutMailExchange(String mailExchangeHostName, int priority); } /** diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java index f9e917aa03d96..59fbdfd50e4da 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java @@ -40,7 +40,7 @@ interface WithRefreshTime { * @param refreshTimeInSeconds the refresh time in seconds * @return the next stage of the record set update */ - Update withRefreshTimeInSeconds(int refreshTimeInSeconds); + Update withRefreshTimeInSeconds(long refreshTimeInSeconds); } /** @@ -54,7 +54,7 @@ interface WithRetryTime { * @param refreshTimeInSeconds the retry time in seconds * @return the next stage of the record set update */ - Update withRetryTimeInSeconds(int refreshTimeInSeconds); + Update withRetryTimeInSeconds(long refreshTimeInSeconds); } /** @@ -68,7 +68,7 @@ interface WithExpireTime { * @param expireTimeInSeconds the expire time in seconds * @return the next stage of the record set update */ - Update withExpireTimeInSeconds(int expireTimeInSeconds); + Update withExpireTimeInSeconds(long expireTimeInSeconds); } /** @@ -81,7 +81,7 @@ interface WithNegativeCachingTtl { * @param negativeCachingTimeToLive the Ttl for cached negative response * @return the next stage of the record set update */ - Update withNegativeCachingTimeToLiveInSeconds(int negativeCachingTimeToLive); + Update withNegativeResponseCachingTimeToLiveInSeconds(long negativeCachingTimeToLive); } /** @@ -94,7 +94,7 @@ interface WithSerialNumber { * @param serialNumber the serial number * @return the next stage of the record set update */ - Update withSerialNumber(int serialNumber); + Update withSerialNumber(long serialNumber); } /** diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java index 128bcbcc3b0ae..a8a4c15ec641f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java @@ -7,7 +7,7 @@ import java.util.List; /** - * An immutable client-side representation of a Srv record set in Azure Dns Zone. + * An immutable client-side representation of a Srv (service) record set in Azure Dns Zone. */ public interface SrvRecordSet extends DnsRecordSet { /** @@ -20,6 +20,7 @@ public interface SrvRecordSet extends DnsRecordSet { */ interface Definition extends DefinitionStages.Blank, + DefinitionStages.WithRecord, DefinitionStages.WithCreate { } @@ -30,8 +31,23 @@ interface DefinitionStages { /** * The first stage of a Srv record set definition. */ - interface Blank { - // TODO + interface Blank extends WithRecord { + } + + /** + * The stage of the srv record set definition allowing to add a Srv record. + */ + interface WithRecord { + /** + * Specifies a service record for a service. + * + * @param target the canonical name of the target host running the service + * @param port the port on which the service is bounded + * @param priority the priority of the target host, lower the value higher the priority + * @param weight the relative weight (preference) of the records with the same priority, higher the value more the preference + * @return the next stage of the record set definition + */ + WithCreate withRecord(String target, int port, int priority, int weight); } /** @@ -53,8 +69,9 @@ interface WithTtl { * for any other optional settings to be specified. */ interface WithCreate extends - Creatable, + Creatable, HasTags.DefinitionWithTags, + DefinitionStages.WithRecord, DefinitionStages.WithTtl { } } @@ -63,6 +80,33 @@ interface WithCreate extends * Grouping of Srv record set update stages. */ interface UpdateStages { + /** + * The stage of the srv record set update allowing to add or remove a Srv record. + */ + interface WithRecord { + /** + * Specifies a service record for a service. + * + * @param target the canonical name of the target host running the service + * @param port the port on which the service is bounded + * @param priority the priority of the target host, lower the value higher the priority + * @param weight the relative weight (preference) of the records with the same priority, higher the value more the preference + * @return the next stage of the record set update + */ + Update withRecord(String target, int port, int priority, int weight); + + /** + * Removes a service record. + * + * @param target the canonical name of the target host running the service + * @param port the port on which the service is bounded + * @param priority the priority of the record + * @param weight the weight of the record + * @return the next stage of the record set update + */ + Update withoutRecord(String target, int port, int priority, int weight); + } + /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ @@ -84,8 +128,9 @@ interface WithTtl { * Call {@link Update#apply()} to apply the changes to the resource in Azure. */ interface Update extends - Appliable, + Appliable, HasTags.UpdateWithTags, + UpdateStages.WithRecord, UpdateStages.WithTtl { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java index e23b167e67681..34e34296d7959 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java @@ -66,7 +66,7 @@ interface WithTtl { * for any other optional settings to be specified. */ interface WithCreate extends - Creatable, + Creatable, HasTags.DefinitionWithTags, DefinitionStages.WithText, DefinitionStages.WithTtl { @@ -119,7 +119,7 @@ interface WithTtl { * Call {@link Update#apply()} to apply the changes to the resource in Azure. */ interface Update extends - Appliable, + Appliable, HasTags.UpdateWithTags, UpdateStages.WithText, UpdateStages.WithTtl { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java index a981bd0119295..d4ef7c184c62c 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java @@ -13,7 +13,10 @@ */ class ARecordSetImpl extends DnsRecordSetImpl - implements ARecordSet { + implements + ARecordSet, + ARecordSet.Definition, + ARecordSet.Update { ARecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -31,7 +34,29 @@ public List ipv4Addresses() { @Override public ARecordSetImpl refresh() { - this.resetInner(); + this.refreshInner(); + return this; + } + + @Override + public ARecordSetImpl withIpv4Address(String ipv4Address) { + if (this.inner().aRecords() == null) { + this.inner().withARecords(new ArrayList()); + } + this.inner().aRecords().add(new ARecord().withIpv4Address(ipv4Address)); + return this; + } + + @Override + public ARecordSetImpl withoutIpv4Address(String ipv4Address) { + if (this.inner().aRecords() != null) { + for (ARecord record : this.inner().aRecords()) { + if (record.ipv4Address().equalsIgnoreCase(ipv4Address)) { + this.inner().aRecords().remove(record); + break; + } + } + } return this; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java index 4342a036f3109..b6110188018bb 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java @@ -13,7 +13,10 @@ */ class AaaaRecordSetImpl extends DnsRecordSetImpl - implements AaaaRecordSet { + implements + AaaaRecordSet, + AaaaRecordSet.Definition, + AaaaRecordSet.Update { AaaaRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); @@ -32,7 +35,29 @@ public List ipv6Addresses() { @Override public AaaaRecordSetImpl refresh() { - this.resetInner(); + this.refreshInner(); + return this; + } + + @Override + public AaaaRecordSetImpl withIpv6Address(String ipv6Address) { + if (this.inner().aaaaRecords() == null) { + this.inner().withAaaaRecords(new ArrayList()); + } + this.inner().aaaaRecords().add(new AaaaRecord().withIpv6Address(ipv6Address)); + return this; + } + + @Override + public AaaaRecordSetImpl withoutIpv6Address(String ipv6Address) { + if (this.inner().aaaaRecords() != null) { + for (AaaaRecord record : this.inner().aaaaRecords()) { + if (record.ipv6Address().equalsIgnoreCase(ipv6Address)) { + this.inner().aaaaRecords().remove(record); + break; + } + } + } return this; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java index e30e6bc1159ae..584ba41a18c5e 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java @@ -1,6 +1,7 @@ package com.microsoft.azure.management.dns.implementation; import com.microsoft.azure.management.dns.ARecordSet; +import com.microsoft.azure.management.dns.CnameRecord; import com.microsoft.azure.management.dns.CnameRecordSet; import rx.functions.Func1; @@ -9,7 +10,10 @@ */ class CnameRecordSetImpl extends DnsRecordSetImpl - implements CnameRecordSet { + implements + CnameRecordSet, + CnameRecordSet.Definition, + CnameRecordSet.Update { CnameRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -24,7 +28,13 @@ public String canonicalName() { @Override public CnameRecordSetImpl refresh() { - this.resetInner(); + this.refreshInner(); + return this; + } + + @Override + public CnameRecordSetImpl withCanonicalName(String canonicalName) { + this.inner().withCnameRecord(new CnameRecord().withCname(canonicalName)); return this; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index 20c1fcdd05d35..e524eb8c2505f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -94,7 +94,7 @@ public Observable createResourceAsync() { .map(innerToFluentMap()); } - protected void resetInner() { + protected void refreshInner() { this.setInner(this.client.get(this.parent().resourceGroupName(), this.parent().name(), this.name(), diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java index 4c91089a404fa..23df5095a7b16 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java @@ -1,13 +1,13 @@ package com.microsoft.azure.management.dns.implementation; import com.microsoft.azure.management.dns.ARecordSets; -import com.microsoft.azure.management.dns.AaaaRecord; import com.microsoft.azure.management.dns.AaaaRecordSets; import com.microsoft.azure.management.dns.CnameRecordSets; import com.microsoft.azure.management.dns.DnsZone; import com.microsoft.azure.management.dns.MxRecordSets; import com.microsoft.azure.management.dns.NsRecordSets; import com.microsoft.azure.management.dns.PtrRecordSets; +import com.microsoft.azure.management.dns.RecordType; import com.microsoft.azure.management.dns.SoaRecordSet; import com.microsoft.azure.management.dns.SrvRecordSets; import com.microsoft.azure.management.dns.TxtRecordSets; @@ -109,18 +109,21 @@ public TxtRecordSets txtRecordSets() { @Override public SoaRecordSet getSoaRecordSet() { - // TODO: Do HTTP GET - return null; + RecordSetInner inner = this.recordSetsClient.get(this.resourceGroupName(), this.name(), "@", RecordType.SOA); + return new SoaRecordSetImpl(this, inner, this.recordSetsClient); } @Override public Observable createResourceAsync() { - return null; + return this.innerCollection.createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner()) + .map(innerToFluentMap(this)); } @Override public DnsZone refresh() { - return null; + ZoneInner inner = this.innerCollection.get(this.resourceGroupName(), this.name()); + this.setInner(inner); + return this; } private void initRecordSets() { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java index 97523e7b04b0b..dbd827f130491 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -13,7 +13,10 @@ */ class MxRecordSetImpl extends DnsRecordSetImpl - implements MxRecordSet { + implements + MxRecordSet, + MxRecordSet.Definition, + MxRecordSet.Update { MxRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -28,7 +31,29 @@ public List records() { @Override public MxRecordSetImpl refresh() { - this.resetInner(); + this.refreshInner(); + return this; + } + + @Override + public MxRecordSetImpl withMailExchange(String mailExchangeHostName, int priority) { + if (this.inner().mxRecords() == null) { + this.inner().withMxRecords(new ArrayList()); + } + this.inner().mxRecords().add(new MxRecord().withExchange(mailExchangeHostName).withPreference(priority)); + return this; + } + + @Override + public MxRecordSetImpl withoutMailExchange(String mailExchangeHostName, int priority) { + if (this.inner().mxRecords() != null) { + for (MxRecord record : this.inner().mxRecords()) { + if (record.exchange().equalsIgnoreCase(mailExchangeHostName) && record.preference() == priority) { + this.inner().mxRecords().remove(record); + break; + } + } + } return this; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java index 724e27ec21123..61b3795f0882d 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java @@ -13,7 +13,10 @@ */ class NsRecordSetImpl extends DnsRecordSetImpl - implements NsRecordSet { + implements + NsRecordSet, + NsRecordSet.Definition, + NsRecordSet.Update { NsRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -31,7 +34,29 @@ public List nameServers() { @Override public NsRecordSetImpl refresh() { - this.resetInner(); + this.refreshInner(); + return this; + } + + @Override + public NsRecordSetImpl withNameServer(String nameServerHostName) { + if (this.inner().nsRecords() == null) { + this.inner().withNsRecords(new ArrayList()); + } + this.inner().nsRecords().add(new NsRecord().withNsdname(nameServerHostName)); + return this; + } + + @Override + public NsRecordSetImpl withoutNameServer(String nameServerHostName) { + if (this.inner().nsRecords() != null) { + for (NsRecord record : this.inner().nsRecords()) { + if (record.nsdname().equalsIgnoreCase(nameServerHostName)) { + this.inner().nsRecords().remove(record); + break; + } + } + } return this; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java index f3f703093240f..c5e4519825d06 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java @@ -13,7 +13,10 @@ */ class PtrRecordSetImpl extends DnsRecordSetImpl - implements PtrRecordSet { + implements + PtrRecordSet, + PtrRecordSet.Definition, + PtrRecordSet.Update { PtrRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -31,7 +34,29 @@ public List targetDomainNames() { @Override public PtrRecordSetImpl refresh() { - this.resetInner(); + this.refreshInner(); + return this; + } + + @Override + public PtrRecordSetImpl withTargetDomain(String targetDomainName) { + if (this.inner().ptrRecords() == null) { + this.inner().withPtrRecords(new ArrayList()); + } + this.inner().ptrRecords().add(new PtrRecord().withPtrdname(targetDomainName)); + return this; + } + + @Override + public PtrRecordSetImpl withoutTargetDomain(String targetDomainName) { + if (this.inner().nsRecords() != null) { + for (PtrRecord record : this.inner().ptrRecords()) { + if (record.ptrdname().equalsIgnoreCase(targetDomainName)) { + this.inner().ptrRecords().remove(record); + break; + } + } + } return this; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java new file mode 100644 index 0000000000000..40610231eb12b --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java @@ -0,0 +1,70 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.SoaRecord; +import com.microsoft.azure.management.dns.SoaRecordSet; +import rx.functions.Func1; + +/** + * Implementation of {@link SoaRecordSet} + */ +class SoaRecordSetImpl + extends DnsRecordSetImpl + implements + SoaRecordSet, + SoaRecordSet.Update { + SoaRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parentDnsZone, innerModel, client); + } + + @Override + public SoaRecord record() { + return this.inner().soaRecord(); + } + + @Override + public SoaRecordSetImpl refresh() { + this.refreshInner(); + return this; + } + + @Override + public SoaRecordSetImpl withEmailServer(String emailServerHostName) { + this.inner().soaRecord().withEmail(emailServerHostName); + return this; + } + + @Override + public SoaRecordSetImpl withExpireTimeInSeconds(long expireTimeInSeconds) { + this.inner().soaRecord().withExpireTime(expireTimeInSeconds); + return this; + } + + @Override + public SoaRecordSetImpl withNegativeResponseCachingTimeToLiveInSeconds(long negativeCachingTimeToLive) { + this.inner().soaRecord().withMinimumTtl(negativeCachingTimeToLive); + return this; + } + + @Override + public SoaRecordSetImpl withRefreshTimeInSeconds(long refreshTimeInSeconds) { + this.inner().soaRecord().withRefreshTime(refreshTimeInSeconds); + return this; + } + + @Override + public SoaRecordSetImpl withRetryTimeInSeconds(long refreshTimeInSeconds) { + this.inner().soaRecord().withRetryTime(refreshTimeInSeconds); + return this; + } + + @Override + public SoaRecordSetImpl withSerialNumber(long serialNumber) { + this.inner().soaRecord().withSerialNumber(serialNumber); + return this; + } + + @Override + protected Func1 innerToFluentMap() { + return super.innerToFluentMap(this); + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java new file mode 100644 index 0000000000000..1da34ec61b9cc --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java @@ -0,0 +1,71 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.SrvRecord; +import com.microsoft.azure.management.dns.SrvRecordSet; +import rx.functions.Func1; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Implementation of {@link SrvRecordSet} + */ +class SrvRecordSetImpl + extends DnsRecordSetImpl + implements + SrvRecordSet, + SrvRecordSet.Definition, + SrvRecordSet.Update { + SrvRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parentDnsZone, innerModel, client); + } + + @Override + public List records() { + if (this.inner().srvRecords() != null) { + return Collections.unmodifiableList(this.inner().srvRecords()); + } + return Collections.unmodifiableList(new ArrayList()); + } + + @Override + public SrvRecordSetImpl refresh() { + this.refreshInner(); + return this; + } + + @Override + public SrvRecordSetImpl withRecord(String target, int port, int priority, int weight) { + if (this.inner().srvRecords() == null) { + this.inner().withSrvRecords(new ArrayList()); + } + this.inner().srvRecords().add(new SrvRecord() + .withTarget(target) + .withPort(port) + .withPriority(priority) + .withWeight(weight)); + return this; + } + + @Override + public SrvRecordSetImpl withoutRecord(String target, int port, int priority, int weight) { + if (this.inner().srvRecords() != null) { + for (SrvRecord record : this.inner().srvRecords()) { + if (record.target().equalsIgnoreCase(target) && + record.port() == port && + record.priority() == priority && + record.weight() == weight) { + this.inner().srvRecords().remove(record); + break; + } + } + } + return this; + } + + @Override + protected Func1 innerToFluentMap() { + return super.innerToFluentMap(this); + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java index 165abb2729492..0aa7d3f325234 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java @@ -13,7 +13,10 @@ */ class TxtRecordSetImpl extends DnsRecordSetImpl - implements TxtRecordSet { + implements + TxtRecordSet, + TxtRecordSet.Definition, + TxtRecordSet.Update { TxtRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -28,7 +31,33 @@ public List records() { @Override public TxtRecordSetImpl refresh() { - this.resetInner(); + this.refreshInner(); + return this; + } + + @Override + public TxtRecordSetImpl withText(String text) { + if (this.inner().txtRecords() == null) { + this.inner().withTxtRecords(new ArrayList()); + } + List value = new ArrayList<>(); + value.add(text); + this.inner().txtRecords().add(new TxtRecord().withValue(value)); + return this; + } + + @Override + public TxtRecordSetImpl withoutText(String text) { + if (this.inner().txtRecords() != null) { + for (TxtRecord record : this.inner().txtRecords()) { + if (record.value() != null && record.value().size() != 0) { + if (record.value().get(0).equalsIgnoreCase(text)) { + this.inner().txtRecords().remove(record); + break; + } + } + } + } return this; } From 93b4140b32d87974e563e7481bbd158135fc39f2 Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 2 Nov 2016 15:52:21 -0700 Subject: [PATCH 07/27] adding recordsets impl types --- .../azure/management/dns/ARecordSets.java | 2 + .../azure/management/dns/AaaaRecordSets.java | 2 + .../azure/management/dns/CnameRecordSets.java | 2 + .../azure/management/dns/DnsRecordSets.java | 7 -- .../azure/management/dns/MxRecordSets.java | 2 + .../azure/management/dns/NsRecordSets.java | 2 + .../azure/management/dns/PtrRecordSets.java | 2 + .../azure/management/dns/SrvRecordSets.java | 2 + .../azure/management/dns/TxtRecordSets.java | 3 + .../dns/implementation/ARecordSetsImpl.java | 65 +++++++++++++++++++ .../implementation/AaaaRecordSetsImpl.java | 65 +++++++++++++++++++ .../implementation/CnameRecordSetsImpl.java | 65 +++++++++++++++++++ .../dns/implementation/DnsZoneImpl.java | 17 ++--- .../dns/implementation/MxRecordSetsImpl.java | 65 +++++++++++++++++++ .../dns/implementation/NsRecordSetsImpl.java | 65 +++++++++++++++++++ .../dns/implementation/PtrRecordSetsImpl.java | 65 +++++++++++++++++++ .../dns/implementation/SrvRecordSetsImpl.java | 65 +++++++++++++++++++ .../dns/implementation/TxtRecordSetsImpl.java | 65 +++++++++++++++++++ 18 files changed, 546 insertions(+), 15 deletions(-) create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetsImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetsImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetsImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetsImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetsImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetsImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetsImpl.java diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java index dbae95b48a512..6649613aab6c8 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; @@ -13,6 +14,7 @@ public interface ARecordSets extends DnsRecordSets, SupportsListing, + SupportsGettingByName, SupportsGettingById, SupportsCreating, SupportsDeletingById { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java index e7d3236745b8f..65e9935b625c5 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; @@ -13,6 +14,7 @@ public interface AaaaRecordSets extends DnsRecordSets, SupportsListing, + SupportsGettingByName, SupportsGettingById, SupportsCreating, SupportsDeletingById { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java index b5f1d7720830a..faa3c910eb7a7 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; @@ -13,6 +14,7 @@ public interface CnameRecordSets extends DnsRecordSets, SupportsListing, + SupportsGettingByName, SupportsGettingById, SupportsCreating, SupportsDeletingById { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java index 3fe3a5900ec25..3967a91c4f808 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java @@ -9,11 +9,4 @@ */ @Fluent public interface DnsRecordSets { - /** - * Gets the information about a Dns record set from Azure based on name. - * - * @param name the name of the record set - * @return the record set - */ - FluentRecordSetModelT getByName(String name); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java index 6a7aa036e2303..922267bdadcdf 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; @@ -13,6 +14,7 @@ public interface MxRecordSets extends DnsRecordSets, SupportsListing, + SupportsGettingByName, SupportsGettingById, SupportsCreating, SupportsDeletingById { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java index 66541056cb632..ddd96ca818f95 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; @@ -13,6 +14,7 @@ public interface NsRecordSets extends DnsRecordSets, SupportsListing, + SupportsGettingByName, SupportsGettingById, SupportsCreating, SupportsDeletingById { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java index 7e8fb2c1cfea2..a46cb2afae533 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; @@ -13,6 +14,7 @@ public interface PtrRecordSets extends DnsRecordSets, SupportsListing, + SupportsGettingByName, SupportsGettingById, SupportsCreating, SupportsDeletingById { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java index d3a3b7576da4d..f6de9cb271e86 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; @@ -13,6 +14,7 @@ public interface SrvRecordSets extends DnsRecordSets, SupportsListing, + SupportsGettingByName, SupportsGettingById, SupportsCreating, SupportsDeletingById { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java index d6b39a41be6a9..bd6a8ec97ef48 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java @@ -2,8 +2,10 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** @@ -13,6 +15,7 @@ public interface TxtRecordSets extends DnsRecordSets, SupportsListing, + SupportsGettingByName, SupportsGettingById, SupportsCreating, SupportsDeletingById { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetsImpl.java new file mode 100644 index 0000000000000..0f45021d730bd --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetsImpl.java @@ -0,0 +1,65 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.ARecordSet; +import com.microsoft.azure.management.dns.ARecordSets; +import com.microsoft.azure.management.dns.RecordType; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; +import rx.Observable; + +/** + * Implementation of {@link ARecordSets}. + */ +class ARecordSetsImpl + extends CreatableWrappersImpl + implements ARecordSets { + + private final DnsZoneImpl dnsZone; + private final RecordSetsInner client; + + ARecordSetsImpl(DnsZoneImpl dnsZone, RecordSetsInner client) { + this.dnsZone = dnsZone; + this.client = client; + } + + @Override + public ARecordSetImpl getByName(String name) { + RecordSetInner inner = this.client.get(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + name, + RecordType.A); + return new ARecordSetImpl(this.dnsZone, inner, this.client); + } + + @Override + public ARecordSetImpl getById(String id) { + return null; + } + + @Override + public ARecordSetImpl define(String name) { + return wrapModel(name); + } + + @Override + public Observable deleteByIdAsync(String id) { + return null; + } + + @Override + public PagedList list() { + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.A)); + } + + @Override + protected ARecordSetImpl wrapModel(String name) { + RecordSetInner inner = new RecordSetInner(); + inner.withName(name).withType(RecordType.A.toString()); + return wrapModel(inner); + } + + @Override + protected ARecordSetImpl wrapModel(RecordSetInner inner) { + return new ARecordSetImpl(this.dnsZone, inner, this.client); + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetsImpl.java new file mode 100644 index 0000000000000..7ad682a1a7083 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetsImpl.java @@ -0,0 +1,65 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.AaaaRecordSet; +import com.microsoft.azure.management.dns.AaaaRecordSets; +import com.microsoft.azure.management.dns.RecordType; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; +import rx.Observable; + +/** + * Implementation of {@link AaaaRecordSets}. + */ +class AaaaRecordSetsImpl + extends CreatableWrappersImpl + implements AaaaRecordSets { + + private final DnsZoneImpl dnsZone; + private final RecordSetsInner client; + + AaaaRecordSetsImpl(DnsZoneImpl dnsZone, RecordSetsInner client) { + this.dnsZone = dnsZone; + this.client = client; + } + + @Override + public AaaaRecordSetImpl getByName(String name) { + RecordSetInner inner = this.client.get(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + name, + RecordType.AAAA); + return new AaaaRecordSetImpl(this.dnsZone, inner, this.client); + } + + @Override + public AaaaRecordSetImpl getById(String id) { + return null; + } + + @Override + public AaaaRecordSetImpl define(String name) { + return wrapModel(name); + } + + @Override + public Observable deleteByIdAsync(String id) { + return null; + } + + @Override + public PagedList list() { + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.AAAA)); + } + + @Override + protected AaaaRecordSetImpl wrapModel(String name) { + RecordSetInner inner = new RecordSetInner(); + inner.withName(name).withType(RecordType.AAAA.toString()); + return wrapModel(inner); + } + + @Override + protected AaaaRecordSetImpl wrapModel(RecordSetInner inner) { + return new AaaaRecordSetImpl(this.dnsZone, inner, this.client); + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetsImpl.java new file mode 100644 index 0000000000000..2e33a5741eee0 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetsImpl.java @@ -0,0 +1,65 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.CnameRecordSet; +import com.microsoft.azure.management.dns.CnameRecordSets; +import com.microsoft.azure.management.dns.RecordType; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; +import rx.Observable; + +/** + * Implementation of {@link CnameRecordSets}. + */ +class CnameRecordSetsImpl + extends CreatableWrappersImpl + implements CnameRecordSets { + + private final DnsZoneImpl dnsZone; + private final RecordSetsInner client; + + CnameRecordSetsImpl(DnsZoneImpl dnsZone, RecordSetsInner client) { + this.dnsZone = dnsZone; + this.client = client; + } + + @Override + public CnameRecordSet getByName(String name) { + RecordSetInner inner = this.client.get(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + name, + RecordType.CNAME); + return new CnameRecordSetImpl(this.dnsZone, inner, this.client); + } + + @Override + public CnameRecordSet getById(String id) { + return null; + } + + @Override + public CnameRecordSetImpl define(String name) { + return wrapModel(name); + } + + @Override + public Observable deleteByIdAsync(String id) { + return null; + } + + @Override + public PagedList list() { + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.CNAME)); + } + + @Override + protected CnameRecordSetImpl wrapModel(String name) { + RecordSetInner inner = new RecordSetInner(); + inner.withName(name).withType(RecordType.CNAME.toString()); + return wrapModel(inner); + } + + @Override + protected CnameRecordSetImpl wrapModel(RecordSetInner inner) { + return new CnameRecordSetImpl(this.dnsZone, inner, this.client); + } +} \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java index 23df5095a7b16..bc064a2fdc725 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java @@ -123,17 +123,18 @@ public Observable createResourceAsync() { public DnsZone refresh() { ZoneInner inner = this.innerCollection.get(this.resourceGroupName(), this.name()); this.setInner(inner); + this.initRecordSets(); return this; } private void initRecordSets() { - this.aRecordSets = null; - this.aaaaRecordSets = null; - this.cnameRecordSets = null; - this.mxRecordSets = null; - this.nsRecordSets = null; - this.ptrRecordSets = null; - this.srvRecordSets = null; - this.txtRecordSets = null; + this.aRecordSets = new ARecordSetsImpl(this, this.recordSetsClient); + this.aaaaRecordSets = new AaaaRecordSetsImpl(this, this.recordSetsClient); + this.cnameRecordSets = new CnameRecordSetsImpl(this, this.recordSetsClient); + this.mxRecordSets = new MxRecordSetsImpl(this, this.recordSetsClient); + this.nsRecordSets = new NsRecordSetsImpl(this, this.recordSetsClient); + this.ptrRecordSets = new PtrRecordSetsImpl(this, this.recordSetsClient); + this.srvRecordSets = new SrvRecordSetsImpl(this, this.recordSetsClient); + this.txtRecordSets = new TxtRecordSetsImpl(this, this.recordSetsClient); } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetsImpl.java new file mode 100644 index 0000000000000..651d686b316dd --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetsImpl.java @@ -0,0 +1,65 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.MxRecordSet; +import com.microsoft.azure.management.dns.MxRecordSets; +import com.microsoft.azure.management.dns.RecordType; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; +import rx.Observable; + +/** + * Implementation of {@link MxRecordSets}. + */ +class MxRecordSetsImpl + extends CreatableWrappersImpl + implements MxRecordSets { + + private final DnsZoneImpl dnsZone; + private final RecordSetsInner client; + + MxRecordSetsImpl(DnsZoneImpl dnsZone, RecordSetsInner client) { + this.dnsZone = dnsZone; + this.client = client; + } + + @Override + public MxRecordSetImpl getByName(String name) { + RecordSetInner inner = this.client.get(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + name, + RecordType.MX); + return new MxRecordSetImpl(this.dnsZone, inner, this.client); + } + + @Override + public MxRecordSetImpl getById(String id) { + return null; + } + + @Override + public MxRecordSetImpl define(String name) { + return wrapModel(name); + } + + @Override + public Observable deleteByIdAsync(String id) { + return null; + } + + @Override + public PagedList list() { + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.MX)); + } + + @Override + protected MxRecordSetImpl wrapModel(String name) { + RecordSetInner inner = new RecordSetInner(); + inner.withName(name).withType(RecordType.MX.toString()); + return wrapModel(inner); + } + + @Override + protected MxRecordSetImpl wrapModel(RecordSetInner inner) { + return new MxRecordSetImpl(this.dnsZone, inner, this.client); + } +} \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetsImpl.java new file mode 100644 index 0000000000000..97816df24fedc --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetsImpl.java @@ -0,0 +1,65 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.NsRecordSet; +import com.microsoft.azure.management.dns.NsRecordSets; +import com.microsoft.azure.management.dns.RecordType; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; +import rx.Observable; + +/** + * Implementation of {@link NsRecordSets}. + */ +class NsRecordSetsImpl + extends CreatableWrappersImpl + implements NsRecordSets { + + private final DnsZoneImpl dnsZone; + private final RecordSetsInner client; + + NsRecordSetsImpl(DnsZoneImpl dnsZone, RecordSetsInner client) { + this.dnsZone = dnsZone; + this.client = client; + } + + @Override + public NsRecordSetImpl getByName(String name) { + RecordSetInner inner = this.client.get(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + name, + RecordType.NS); + return new NsRecordSetImpl(this.dnsZone, inner, this.client); + } + + @Override + public NsRecordSetImpl getById(String id) { + return null; + } + + @Override + public NsRecordSetImpl define(String name) { + return wrapModel(name); + } + + @Override + public Observable deleteByIdAsync(String id) { + return null; + } + + @Override + public PagedList list() { + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.NS)); + } + + @Override + protected NsRecordSetImpl wrapModel(String name) { + RecordSetInner inner = new RecordSetInner(); + inner.withName(name).withType(RecordType.NS.toString()); + return wrapModel(inner); + } + + @Override + protected NsRecordSetImpl wrapModel(RecordSetInner inner) { + return new NsRecordSetImpl(this.dnsZone, inner, this.client); + } +} \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetsImpl.java new file mode 100644 index 0000000000000..f6f9762478f2d --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetsImpl.java @@ -0,0 +1,65 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.PtrRecordSet; +import com.microsoft.azure.management.dns.PtrRecordSets; +import com.microsoft.azure.management.dns.RecordType; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; +import rx.Observable; + +/** + * Implementation of {@link PtrRecordSets}. + */ +class PtrRecordSetsImpl + extends CreatableWrappersImpl + implements PtrRecordSets { + + private final DnsZoneImpl dnsZone; + private final RecordSetsInner client; + + PtrRecordSetsImpl(DnsZoneImpl dnsZone, RecordSetsInner client) { + this.dnsZone = dnsZone; + this.client = client; + } + + @Override + public PtrRecordSetImpl getByName(String name) { + RecordSetInner inner = this.client.get(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + name, + RecordType.PTR); + return new PtrRecordSetImpl(this.dnsZone, inner, this.client); + } + + @Override + public PtrRecordSetImpl getById(String id) { + return null; + } + + @Override + public PtrRecordSetImpl define(String name) { + return wrapModel(name); + } + + @Override + public Observable deleteByIdAsync(String id) { + return null; + } + + @Override + public PagedList list() { + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.PTR)); + } + + @Override + protected PtrRecordSetImpl wrapModel(String name) { + RecordSetInner inner = new RecordSetInner(); + inner.withName(name).withType(RecordType.PTR.toString()); + return wrapModel(inner); + } + + @Override + protected PtrRecordSetImpl wrapModel(RecordSetInner inner) { + return new PtrRecordSetImpl(this.dnsZone, inner, this.client); + } +} \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java new file mode 100644 index 0000000000000..4f14daff0c27f --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java @@ -0,0 +1,65 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.RecordType; +import com.microsoft.azure.management.dns.SrvRecordSet; +import com.microsoft.azure.management.dns.SrvRecordSets; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; +import rx.Observable; + +/** + * Implementation of {@link SrvRecordSets } + */ +class SrvRecordSetsImpl + extends CreatableWrappersImpl + implements SrvRecordSets { + + private final DnsZoneImpl dnsZone; + private final RecordSetsInner client; + + SrvRecordSetsImpl(DnsZoneImpl dnsZone, RecordSetsInner client) { + this.dnsZone = dnsZone; + this.client = client; + } + + @Override + public SrvRecordSetImpl getByName(String name) { + RecordSetInner inner = this.client.get(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + name, + RecordType.SRV); + return new SrvRecordSetImpl(this.dnsZone, inner, this.client); + } + + @Override + public SrvRecordSetImpl getById(String id) { + return null; + } + + @Override + public SrvRecordSetImpl define(String name) { + return wrapModel(name); + } + + @Override + public Observable deleteByIdAsync(String id) { + return null; + } + + @Override + public PagedList list() { + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.SRV)); + } + + @Override + protected SrvRecordSetImpl wrapModel(String name) { + RecordSetInner inner = new RecordSetInner(); + inner.withName(name).withType(RecordType.SRV.toString()); + return wrapModel(inner); + } + + @Override + protected SrvRecordSetImpl wrapModel(RecordSetInner inner) { + return new SrvRecordSetImpl(this.dnsZone, inner, this.client); + } +} \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetsImpl.java new file mode 100644 index 0000000000000..505e5c46d3879 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetsImpl.java @@ -0,0 +1,65 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.RecordType; +import com.microsoft.azure.management.dns.TxtRecordSet; +import com.microsoft.azure.management.dns.TxtRecordSets; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; +import rx.Observable; + +/** + * Implementation of {@link TxtRecordSets}. + */ +class TxtRecordSetsImpl + extends CreatableWrappersImpl + implements TxtRecordSets { + + private final DnsZoneImpl dnsZone; + private final RecordSetsInner client; + + TxtRecordSetsImpl(DnsZoneImpl dnsZone, RecordSetsInner client) { + this.dnsZone = dnsZone; + this.client = client; + } + + @Override + public TxtRecordSetImpl getByName(String name) { + RecordSetInner inner = this.client.get(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + name, + RecordType.TXT); + return new TxtRecordSetImpl(this.dnsZone, inner, this.client); + } + + @Override + public TxtRecordSetImpl getById(String id) { + return null; + } + + @Override + public TxtRecordSetImpl define(String name) { + return wrapModel(name); + } + + @Override + public Observable deleteByIdAsync(String id) { + return null; + } + + @Override + public PagedList list() { + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.TXT)); + } + + @Override + protected TxtRecordSetImpl wrapModel(String name) { + RecordSetInner inner = new RecordSetInner(); + inner.withName(name).withType(RecordType.TXT.toString()); + return wrapModel(inner); + } + + @Override + protected TxtRecordSetImpl wrapModel(RecordSetInner inner) { + return new TxtRecordSetImpl(this.dnsZone, inner, this.client); + } +} \ No newline at end of file From 9d9610ce4e3acd40b20f91dbeb8b257e8b0da014 Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 2 Nov 2016 16:47:37 -0700 Subject: [PATCH 08/27] Some checkstyle fixes --- .../azure/management/dns/implementation/ARecordSetImpl.java | 2 +- .../azure/management/dns/implementation/AaaaRecordSetImpl.java | 2 +- .../management/dns/implementation/CnameRecordSetImpl.java | 3 +-- .../azure/management/dns/implementation/MxRecordSetImpl.java | 2 +- .../azure/management/dns/implementation/NsRecordSetImpl.java | 2 +- .../azure/management/dns/implementation/PtrRecordSetImpl.java | 2 +- .../azure/management/dns/implementation/SoaRecordSetImpl.java | 2 +- .../azure/management/dns/implementation/SrvRecordSetImpl.java | 2 +- .../azure/management/dns/implementation/SrvRecordSetsImpl.java | 2 +- .../azure/management/dns/implementation/TxtRecordSetImpl.java | 2 +- 10 files changed, 10 insertions(+), 11 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java index d4ef7c184c62c..8c9f720d1a240 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java @@ -9,7 +9,7 @@ import java.util.List; /** - * Implementation of {@link ARecordSet} + * Implementation of {@link ARecordSet}. */ class ARecordSetImpl extends DnsRecordSetImpl diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java index b6110188018bb..9dbe214daeeb8 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java @@ -9,7 +9,7 @@ import java.util.List; /** - * Implementation of {@link AaaaRecordSet} + * Implementation of {@link AaaaRecordSet}. */ class AaaaRecordSetImpl extends DnsRecordSetImpl diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java index 584ba41a18c5e..6e541711536ee 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java @@ -1,12 +1,11 @@ package com.microsoft.azure.management.dns.implementation; -import com.microsoft.azure.management.dns.ARecordSet; import com.microsoft.azure.management.dns.CnameRecord; import com.microsoft.azure.management.dns.CnameRecordSet; import rx.functions.Func1; /** - * Implementation of {@link ARecordSet} + * Implementation of {@link CnameRecordSet}. */ class CnameRecordSetImpl extends DnsRecordSetImpl diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java index dbd827f130491..57f812ace71e7 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -9,7 +9,7 @@ import java.util.List; /** - * Implementation of {@link MxRecordSet} + * Implementation of {@link MxRecordSet}. */ class MxRecordSetImpl extends DnsRecordSetImpl diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java index 61b3795f0882d..913b9845c8c86 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java @@ -9,7 +9,7 @@ import java.util.List; /** - * Implementation of {@link NsRecordSet} + * Implementation of {@link NsRecordSet}. */ class NsRecordSetImpl extends DnsRecordSetImpl diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java index c5e4519825d06..a9f991bbc63f7 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java @@ -9,7 +9,7 @@ import java.util.List; /** - * Implementation of {@link PtrRecordSet} + * Implementation of {@link PtrRecordSet}. */ class PtrRecordSetImpl extends DnsRecordSetImpl diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java index 40610231eb12b..ab199a42af155 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java @@ -5,7 +5,7 @@ import rx.functions.Func1; /** - * Implementation of {@link SoaRecordSet} + * Implementation of {@link SoaRecordSet}. */ class SoaRecordSetImpl extends DnsRecordSetImpl diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java index 1da34ec61b9cc..f4bf6bc0f7eb6 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java @@ -9,7 +9,7 @@ import java.util.List; /** - * Implementation of {@link SrvRecordSet} + * Implementation of {@link SrvRecordSet}. */ class SrvRecordSetImpl extends DnsRecordSetImpl diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java index 4f14daff0c27f..7f741d9ab36f7 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java @@ -8,7 +8,7 @@ import rx.Observable; /** - * Implementation of {@link SrvRecordSets } + * Implementation of {@link SrvRecordSets}. */ class SrvRecordSetsImpl extends CreatableWrappersImpl diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java index 0aa7d3f325234..f12d54ab4291b 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java @@ -9,7 +9,7 @@ import java.util.List; /** - * Implementation of {@link TxtRecordSet} + * Implementation of {@link TxtRecordSet}. */ class TxtRecordSetImpl extends DnsRecordSetImpl From 9a607f6de8de35522e670b1b752f67016eac7289 Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 2 Nov 2016 18:13:19 -0700 Subject: [PATCH 09/27] Adding definition stages in DnsRecordSet interface --- .../azure/management/dns/DnsRecordSet.java | 292 ++++++++++++++++++ 1 file changed, 292 insertions(+) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index a202f828324ea..91c5b4c1d2bfe 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -3,6 +3,7 @@ import com.microsoft.azure.management.dns.implementation.RecordSetInner; import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.model.Attachable; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; /** @@ -22,4 +23,295 @@ public interface DnsRecordSet extends * @return TTL of the records in this record set */ long timeToLive(); + + /** + * The entirety of a Dns zone record set definition as a part of parent definition. + * + * @param the return type of the final {@link Attachable#attach()} + */ + interface Definition extends + DefinitionStages.ARecordSetBlank, + DefinitionStages.WithARecordIpv4Address, + DefinitionStages.WithARecordIpv4AddressOrAttachable, + DefinitionStages.AaaaRecordSetBlank, + DefinitionStages.WithAaaaRecordIpv6Address, + DefinitionStages.WithAaaaRecordIpv6AddressOrAttachable, + DefinitionStages.CnameRecordSetBlank, + DefinitionStages.WithCnameRecordCanonicalName, + DefinitionStages.WithCnameRecordCanonicalNameOrAttachable, + DefinitionStages.MxRecordSetBlank, + DefinitionStages.WithMxRecordMailExchange, + DefinitionStages.WithMxRecordMailExchangeOrAttachable, + DefinitionStages.NsRecordSetBlank, + DefinitionStages.WithNsRecordNameServer, + DefinitionStages.SrvRecordSetBlank, + DefinitionStages.WithSrvRecordEntry, + DefinitionStages.WithSrvRecordEntryOrAttachable, + DefinitionStages.TxtRecordSetBlank, + DefinitionStages.WithTxtRecordTextValue, + DefinitionStages.WithTxtRecordTextValueOrAttachable, + DefinitionStages.WithAttach { + } + + /** + * Grouping of Dns zone record set definition stages as a part of parent Dns zone definition. + */ + interface DefinitionStages { + /** + * The first stage of a A record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface ARecordSetBlank extends WithARecordIpv4Address { + } + + /** + * The stage of the A record set definition allowing to add first A record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithARecordIpv4Address { + /** + * Creates an A record with the provided Ipv4 address in this record set. + * + * @param ipv4Address the Ipv4 address + * @return the next stage of the record set definition + */ + WithARecordIpv4AddressOrAttachable withIpv4Address(String ipv4Address); + } + + /** + * The stage of the A record set definition allowing to add additional A records or + * attach the record set to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithARecordIpv4AddressOrAttachable + extends WithARecordIpv4Address, Attachable { + } + + /** + * The first stage of a Aaaa record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface AaaaRecordSetBlank extends WithAaaaRecordIpv6Address { + } + + /** + * The stage of the Aaaa record set definition allowing to add first Aaaa record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithAaaaRecordIpv6Address { + /** + * Creates an Aaaa record with the provided Ipv6 address in this record set. + * + * @param ipv6Address the Ipv6 address + * @return the next stage of the record set definition + */ + WithAaaaRecordIpv6AddressOrAttachable withIpv6Address(String ipv6Address); + } + + /** + * The stage of the Aaaa record set definition allowing to add additional A records or + * attach the record set to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithAaaaRecordIpv6AddressOrAttachable + extends WithAaaaRecordIpv6Address, Attachable { + } + + /** + * The first stage of a Cname record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface CnameRecordSetBlank extends WithCnameRecordCanonicalName { + } + + /** + * The stage of the CName record set definition allowing to add first Cname record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithCnameRecordCanonicalName { + /** + * Creates a CName record with the provided canonical name in this record set. + * + * @param canonicalName the canonical name + * @return the next stage of the record set definition + */ + WithCnameRecordCanonicalNameOrAttachable withCanonicalName(String canonicalName); + } + + /** + * The stage of the Cname record set definition allowing to add additional Cname records or + * attach the record set to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithCnameRecordCanonicalNameOrAttachable + extends WithCnameRecordCanonicalName, Attachable { + } + + /** + * The first stage of a Mx record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface MxRecordSetBlank extends WithMxRecordMailExchange { + } + + /** + * The stage of the Mx record set definition allowing to add first Mx record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithMxRecordMailExchange { + /** + * Creates and assigns priority to a Mx record with the provided mail exchange server in this record set. + * + * @param mailExchangeHostName the host name of the mail exchange server + * @param priority the priority for the mail exchange host, lower the value higher the priority + * @return the next stage of the record set definition + */ + WithMxRecordMailExchangeOrAttachable withMailExchange(String mailExchangeHostName, int priority); + } + + /** + * The stage of the Mx record set definition allowing to add additional Mx records or attach the record set + * to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithMxRecordMailExchangeOrAttachable + extends WithMxRecordMailExchange, Attachable { + } + + /** + * The first stage of a Ns record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface NsRecordSetBlank extends WithNsRecordNameServer { + } + + /** + * The stage of the Ns record set definition allowing to add a Ns record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithNsRecordNameServer { + /** + * Creates a Ns record with the provided name server in this record set. + * + * @param nameServerHostName the name server host name + * @return the next stage of the record set definition + */ + Attachable withNameServer(String nameServerHostName); + } + + /** + * The first stage of a Srv record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface SrvRecordSetBlank extends WithSrvRecordEntry { + } + + /** + * The stage of the Srv record definition allowing to add first service record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSrvRecordEntry { + /** + * Specifies a service record for a service. + * + * @param target the canonical name of the target host running the service + * @param port the port on which the service is bounded + * @param priority the priority of the target host, lower the value higher the priority + * @param weight the relative weight (preference) of the records with the same priority, higher the value more the preference + * @return the next stage of the record set definition + */ + WithSrvRecordEntryOrAttachable withRecord(String target, int port, int priority, int weight); + } + + /** + * The stage of the Srv record set definition allowing to add additional Srv records or attach the record set + * to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSrvRecordEntryOrAttachable + extends WithSrvRecordEntry, Attachable { + } + + /** + * The first stage of a Txt record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface TxtRecordSetBlank extends WithTxtRecordTextValue { + } + + /** + * The stage of the Srv record definition allowing to add first Txt record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTxtRecordTextValue { + /** + * Creates a Txt record with the given text in this record set. + * + * @param text the text value + * @return the next stage of the record set definition + */ + WithTxtRecordTextValueOrAttachable withText(String text); + } + + /** + * The stage of the Txt record set definition allowing to add additional Txt records or attach the record set + * to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTxtRecordTextValueOrAttachable + extends WithTxtRecordTextValue, Attachable { + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithAttach withTimeToLive(long ttlInSeconds); + } + + /** The final stage of the Dns zone record set definition. + *

+ * At this stage, any remaining optional settings can be specified, or the Dns zone record set + * definition can be attached to the parent traffic manager profile definition using {@link DnsRecordSet.DefinitionStages.WithAttach#attach()}. + * @param the return type of {@link DnsRecordSet.DefinitionStages.WithAttach#attach()} + */ + interface WithAttach extends + Attachable.InDefinition, + DefinitionStages.WithTtl { + } + } + + /** + * Grouping of Dns zone record set definition stages as a part of parent Dns zone definition. + */ + interface UpdateDefinitionStages { + } } From 6b203e432222811db7a6a803849765b64b61d508 Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 3 Nov 2016 11:58:45 -0700 Subject: [PATCH 10/27] Adding record sets collection readable entry points to Dns zone --- .../azure/management/dns/ARecordSets.java | 11 +- .../azure/management/dns/AaaaRecordSets.java | 11 +- .../azure/management/dns/CnameRecordSets.java | 11 +- .../azure/management/dns/DnsRecordSet.java | 573 +++++++++++++++++- .../azure/management/dns/DnsRecordSets.java | 2 +- .../azure/management/dns/DnsZone.java | 261 ++++++++ .../azure/management/dns/MxRecordSets.java | 11 +- .../azure/management/dns/NsRecordSets.java | 11 +- .../azure/management/dns/PtrRecordSets.java | 11 +- .../azure/management/dns/SoaRecordSets.java | 3 +- .../azure/management/dns/SrvRecordSets.java | 11 +- .../azure/management/dns/TxtRecordSets.java | 12 +- .../dns/implementation/ARecordSetsImpl.java | 31 +- .../implementation/AaaaRecordSetsImpl.java | 31 +- .../implementation/CnameRecordSetsImpl.java | 31 +- .../dns/implementation/MxRecordSetsImpl.java | 27 +- .../dns/implementation/NsRecordSetsImpl.java | 27 +- .../dns/implementation/PtrRecordSetsImpl.java | 27 +- .../dns/implementation/SrvRecordSetsImpl.java | 27 +- .../dns/implementation/TxtRecordSetsImpl.java | 27 +- 20 files changed, 856 insertions(+), 300 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java index 6649613aab6c8..8a17035ee8b1e 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSets.java @@ -1,21 +1,14 @@ package com.microsoft.azure.management.dns; import com.microsoft.azure.management.apigeneration.Fluent; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** - * Entry point to Dns zone A record set management API. + * Entry point to A record sets in a Dns zone. */ @Fluent public interface ARecordSets extends - DnsRecordSets, SupportsListing, - SupportsGettingByName, - SupportsGettingById, - SupportsCreating, - SupportsDeletingById { + SupportsGettingByName { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java index 65e9935b625c5..cf025c9fcac45 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSets.java @@ -1,21 +1,14 @@ package com.microsoft.azure.management.dns; import com.microsoft.azure.management.apigeneration.Fluent; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** - * Entry point to Dns zone Aaaa record set management API. + * Entry point to Aaaa record sets in a Dns zone. */ @Fluent public interface AaaaRecordSets extends - DnsRecordSets, SupportsListing, - SupportsGettingByName, - SupportsGettingById, - SupportsCreating, - SupportsDeletingById { + SupportsGettingByName { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java index faa3c910eb7a7..7105aefb793b9 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSets.java @@ -1,21 +1,14 @@ package com.microsoft.azure.management.dns; import com.microsoft.azure.management.apigeneration.Fluent; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** - * Entry point to Dns zone CName record set management API. + * Entry point to Cname record sets in a Dns zone. */ @Fluent public interface CnameRecordSets extends - DnsRecordSets, SupportsListing, - SupportsGettingByName, - SupportsGettingById, - SupportsCreating, - SupportsDeletingById { + SupportsGettingByName { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index 91c5b4c1d2bfe..0b17954d61047 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -4,6 +4,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; import com.microsoft.azure.management.resources.fluentcore.model.Attachable; +import com.microsoft.azure.management.resources.fluentcore.model.Settable; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; /** @@ -36,14 +37,14 @@ interface Definition extends DefinitionStages.AaaaRecordSetBlank, DefinitionStages.WithAaaaRecordIpv6Address, DefinitionStages.WithAaaaRecordIpv6AddressOrAttachable, - DefinitionStages.CnameRecordSetBlank, - DefinitionStages.WithCnameRecordCanonicalName, - DefinitionStages.WithCnameRecordCanonicalNameOrAttachable, DefinitionStages.MxRecordSetBlank, DefinitionStages.WithMxRecordMailExchange, DefinitionStages.WithMxRecordMailExchangeOrAttachable, DefinitionStages.NsRecordSetBlank, DefinitionStages.WithNsRecordNameServer, + DefinitionStages.PtrRecordSetBlank, + DefinitionStages.WithPtrRecordTargetDomainName, + DefinitionStages.WithPtrRecordTargetDomainNameOrAttachable, DefinitionStages.SrvRecordSetBlank, DefinitionStages.WithSrvRecordEntry, DefinitionStages.WithSrvRecordEntryOrAttachable, @@ -124,36 +125,288 @@ interface WithAaaaRecordIpv6AddressOrAttachable } /** - * The first stage of a Cname record definition. + * The first stage of a Mx record definition. * * @param the return type of {@link WithAttach#attach()} */ - interface CnameRecordSetBlank extends WithCnameRecordCanonicalName { + interface MxRecordSetBlank extends WithMxRecordMailExchange { } /** - * The stage of the CName record set definition allowing to add first Cname record. + * The stage of the Mx record set definition allowing to add first Mx record. * * @param the return type of {@link WithAttach#attach()} */ - interface WithCnameRecordCanonicalName { + interface WithMxRecordMailExchange { /** - * Creates a CName record with the provided canonical name in this record set. + * Creates and assigns priority to a Mx record with the provided mail exchange server in this record set. + * + * @param mailExchangeHostName the host name of the mail exchange server + * @param priority the priority for the mail exchange host, lower the value higher the priority + * @return the next stage of the record set definition + */ + WithMxRecordMailExchangeOrAttachable withMailExchange(String mailExchangeHostName, int priority); + } + + /** + * The stage of the Mx record set definition allowing to add additional Mx records or attach the record set + * to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithMxRecordMailExchangeOrAttachable + extends WithMxRecordMailExchange, Attachable { + } + + /** + * The first stage of a Ns record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface NsRecordSetBlank extends WithNsRecordNameServer { + } + + /** + * The stage of the Ns record set definition allowing to add a Ns record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithNsRecordNameServer { + /** + * Creates a Ns record with the provided name server in this record set. + * + * @param nameServerHostName the name server host name + * @return the next stage of the record set definition + */ + Attachable withNameServer(String nameServerHostName); + } + + /** + * The first stage of a Ptr record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface PtrRecordSetBlank extends WithPtrRecordTargetDomainName { + } + + /** + * The stage of the Ptr record set definition allowing to add first Cname record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithPtrRecordTargetDomainName { + /** + * Creates a Ptr record with the provided target domain name in this record set. * - * @param canonicalName the canonical name + * @param targetDomainName the target domain name * @return the next stage of the record set definition */ - WithCnameRecordCanonicalNameOrAttachable withCanonicalName(String canonicalName); + WithPtrRecordTargetDomainNameOrAttachable withTargetDomainName(String targetDomainName); } /** - * The stage of the Cname record set definition allowing to add additional Cname records or + * The stage of the Ptr record set definition allowing to add additional Ptr records or * attach the record set to the parent. * * @param the return type of {@link WithAttach#attach()} */ - interface WithCnameRecordCanonicalNameOrAttachable - extends WithCnameRecordCanonicalName, Attachable { + interface WithPtrRecordTargetDomainNameOrAttachable + extends WithPtrRecordTargetDomainName, Attachable { + } + + /** + * The first stage of a Srv record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface SrvRecordSetBlank extends WithSrvRecordEntry { + } + + /** + * The stage of the Srv record definition allowing to add first service record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSrvRecordEntry { + /** + * Specifies a service record for a service. + * + * @param target the canonical name of the target host running the service + * @param port the port on which the service is bounded + * @param priority the priority of the target host, lower the value higher the priority + * @param weight the relative weight (preference) of the records with the same priority, higher the value more the preference + * @return the next stage of the record set definition + */ + WithSrvRecordEntryOrAttachable withRecord(String target, int port, int priority, int weight); + } + + /** + * The stage of the Srv record set definition allowing to add additional Srv records or attach the record set + * to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSrvRecordEntryOrAttachable + extends WithSrvRecordEntry, Attachable { + } + + /** + * The first stage of a Txt record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface TxtRecordSetBlank extends WithTxtRecordTextValue { + } + + /** + * The stage of the Srv record definition allowing to add first Txt record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTxtRecordTextValue { + /** + * Creates a Txt record with the given text in this record set. + * + * @param text the text value + * @return the next stage of the record set definition + */ + WithTxtRecordTextValueOrAttachable withText(String text); + } + + /** + * The stage of the Txt record set definition allowing to add additional Txt records or attach the record set + * to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTxtRecordTextValueOrAttachable + extends WithTxtRecordTextValue, Attachable { + } + + /** + * The stage of the record set definition allowing to specify Ttl for the records in this record set. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set definition + */ + WithAttach withTimeToLive(long ttlInSeconds); + } + + /** The final stage of the Dns zone record set definition. + *

+ * At this stage, any remaining optional settings can be specified, or the Dns zone record set + * definition can be attached to the parent traffic manager profile definition using {@link DnsRecordSet.DefinitionStages.WithAttach#attach()}. + * @param the return type of {@link DnsRecordSet.DefinitionStages.WithAttach#attach()} + */ + interface WithAttach extends + Attachable.InDefinition, + DefinitionStages.WithTtl { + } + } + + /** + * The entirety of a Dns zone record set definition as a part of parent update. + * + * @param the return type of the final {@link Attachable#attach()} + */ + interface UpdateDefinition extends + UpdateDefinitionStages.ARecordSetBlank, + UpdateDefinitionStages.WithARecordIpv4Address, + UpdateDefinitionStages.WithARecordIpv4AddressOrAttachable, + UpdateDefinitionStages.AaaaRecordSetBlank, + UpdateDefinitionStages.WithAaaaRecordIpv6Address, + UpdateDefinitionStages.WithAaaaRecordIpv6AddressOrAttachable, + UpdateDefinitionStages.MxRecordSetBlank, + UpdateDefinitionStages.WithMxRecordMailExchange, + UpdateDefinitionStages.WithMxRecordMailExchangeOrAttachable, + UpdateDefinitionStages.NsRecordSetBlank, + UpdateDefinitionStages.WithNsRecordNameServer, + UpdateDefinitionStages.PtrRecordSetBlank, + UpdateDefinitionStages.WithPtrRecordTargetDomainName, + UpdateDefinitionStages.WithPtrRecordTargetDomainNameOrAttachable, + UpdateDefinitionStages.SrvRecordSetBlank, + UpdateDefinitionStages.WithSrvRecordEntry, + UpdateDefinitionStages.WithSrvRecordEntryOrAttachable, + UpdateDefinitionStages.TxtRecordSetBlank, + UpdateDefinitionStages.WithTxtRecordTextValue, + UpdateDefinitionStages.WithTxtRecordTextValueOrAttachable, + UpdateDefinitionStages.WithAttach { + } + + /** + * Grouping of Dns zone record set definition stages as a part of parent Dns zone update. + */ + interface UpdateDefinitionStages { + /** + * The first stage of a A record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface ARecordSetBlank extends WithARecordIpv4Address { + } + + /** + * The stage of the A record set definition allowing to add first A record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithARecordIpv4Address { + /** + * Creates an A record with the provided Ipv4 address in this record set. + * + * @param ipv4Address the Ipv4 address + * @return the next stage of the record set definition + */ + WithARecordIpv4AddressOrAttachable withIpv4Address(String ipv4Address); + } + + /** + * The stage of the A record set definition allowing to add additional A records or + * attach the record set to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithARecordIpv4AddressOrAttachable + extends WithARecordIpv4Address, Attachable { + } + + /** + * The first stage of a Aaaa record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface AaaaRecordSetBlank extends WithAaaaRecordIpv6Address { + } + + /** + * The stage of the Aaaa record set definition allowing to add first Aaaa record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithAaaaRecordIpv6Address { + /** + * Creates an Aaaa record with the provided Ipv6 address in this record set. + * + * @param ipv6Address the Ipv6 address + * @return the next stage of the record set definition + */ + WithAaaaRecordIpv6AddressOrAttachable withIpv6Address(String ipv6Address); + } + + /** + * The stage of the Aaaa record set definition allowing to add additional A records or + * attach the record set to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithAaaaRecordIpv6AddressOrAttachable + extends WithAaaaRecordIpv6Address, Attachable { } /** @@ -213,6 +466,39 @@ interface WithNsRecordNameServer { Attachable withNameServer(String nameServerHostName); } + /** + * The first stage of a Ptr record definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface PtrRecordSetBlank extends WithPtrRecordTargetDomainName { + } + + /** + * The stage of the Ptr record set definition allowing to add first Cname record. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithPtrRecordTargetDomainName { + /** + * Creates a Ptr record with the provided target domain name in this record set. + * + * @param targetDomainName the target domain name + * @return the next stage of the record set definition + */ + WithPtrRecordTargetDomainNameOrAttachable withTargetDomainName(String targetDomainName); + } + + /** + * The stage of the Ptr record set definition allowing to add additional Ptr records or + * attach the record set to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithPtrRecordTargetDomainNameOrAttachable + extends WithPtrRecordTargetDomainName, Attachable { + } + /** * The first stage of a Srv record definition. * @@ -246,7 +532,7 @@ interface WithSrvRecordEntry { * @param the return type of {@link WithAttach#attach()} */ interface WithSrvRecordEntryOrAttachable - extends WithSrvRecordEntry, Attachable { + extends WithSrvRecordEntry, Attachable { } /** @@ -279,7 +565,7 @@ interface WithTxtRecordTextValue { * @param the return type of {@link WithAttach#attach()} */ interface WithTxtRecordTextValueOrAttachable - extends WithTxtRecordTextValue, Attachable { + extends WithTxtRecordTextValue, Attachable { } /** @@ -300,18 +586,263 @@ interface WithTtl { /** The final stage of the Dns zone record set definition. *

* At this stage, any remaining optional settings can be specified, or the Dns zone record set - * definition can be attached to the parent traffic manager profile definition using {@link DnsRecordSet.DefinitionStages.WithAttach#attach()}. - * @param the return type of {@link DnsRecordSet.DefinitionStages.WithAttach#attach()} + * definition can be attached to the parent traffic manager profile definition + * using {@link DnsRecordSet.UpdateDefinitionStages.WithAttach#attach()}. + * @param the return type of {@link DnsRecordSet.UpdateDefinitionStages.WithAttach#attach()} */ interface WithAttach extends - Attachable.InDefinition, - DefinitionStages.WithTtl { + Attachable.InUpdate, + UpdateDefinitionStages.WithTtl { } } /** - * Grouping of Dns zone record set definition stages as a part of parent Dns zone definition. + * The entirety of a record sets update as a part of parent Dns zone update. */ - interface UpdateDefinitionStages { + interface UpdateCombined extends + UpdateARecordSet, + UpdateAaaaRecordSet, + UpdatePtrRecordSet, + UpdateMxRecordSet, + UpdateSrvRecordSet, + UpdateTxtRecordSet, + Update { + } + + /** + * The entirety of an A record set update as a part of parent Dns zone update. + */ + interface UpdateARecordSet extends + UpdateStages.WithARecordIpv4Address, + Update { + } + + /** + * The entirety of an Aaaa record set update as a part of parent Dns zone update. + */ + interface UpdateAaaaRecordSet extends + UpdateStages.WithAaaaRecordIpv6Address, + Update { + } + + /** + * The entirety of a Mx record set update as a part of parent Dns zone update. + */ + interface UpdateMxRecordSet extends + UpdateStages.WithMxRecordMailExchange, + Update { + } + + /** + * The entirety of a Ns record set update as a part of parent Dns zone update. + */ + interface UpdateNsRecordSet extends + UpdateStages.WithNsRecordNameServer, + Update { + } + + /** + * The entirety of a Ptr record set update as a part of parent Dns zone update. + */ + interface UpdatePtrRecordSet extends + UpdateStages.WithPtrRecordTargetDomainName, + Update { + } + + /** + * The entirety of a Srv record set update as a part of parent Dns zone update. + */ + interface UpdateSrvRecordSet extends + UpdateStages.WithSrvRecordEntry, + Update { + } + + /** + * The entirety of a txt record set update as a part of parent Dns zone update. + */ + interface UpdateTxtRecordSet extends + UpdateStages.WithTxtRecordTextValue, + Update { + } + + /** + * the set of configurations that can be updated for Dns record set irrespective of their type {@link RecordType}. + */ + interface Update extends + Settable, + UpdateStages.WithTtl { + } + + /** + * Grouping of Dns zone record set update stages. + */ + interface UpdateStages { + /** + * The stage of the A record set update allowing to add or remove A record. + */ + interface WithARecordIpv4Address { + /** + * Creates an A record with the provided Ipv4 address in the record set. + * + * @param ipv4Address the Ipv4 address + * @return the next stage of the record set update + */ + UpdateARecordSet withIpv4Address(String ipv4Address); + + /** + * Removes the A record with the provided Ipv4 address from the record set. + * + * @param ipv4Address the Ipv4 address + * @return the next stage of the record set update + */ + UpdateARecordSet withoutIpv4Address(String ipv4Address); + } + + /** + * The stage of the Aaaa record set update allowing to add or remove Aaaa record. + */ + interface WithAaaaRecordIpv6Address { + /** + * Creates an Aaaa record with the provided Ipv6 address in this record set. + * + * @param ipv6Address the Ipv6 address + * @return the next stage of the record set update + */ + UpdateAaaaRecordSet withIpv6Address(String ipv6Address); + + /** + * Removes an Aaaa record with the provided Ipv6 address from this record set. + * + * @param ipv6Address the Ipv6 address + * @return the next stage of the record set update + */ + UpdateAaaaRecordSet withoutIpv6Address(String ipv6Address); + } + + /** + * The stage of the Mx record set definition allowing to add or remove Mx record. + */ + interface WithMxRecordMailExchange { + /** + * Creates and assigns priority to a Mx record with the provided mail exchange server in this record set. + * + * @param mailExchangeHostName the host name of the mail exchange server + * @param priority the priority for the mail exchange host, lower the value higher the priority + * @return the next stage of the record set update + */ + UpdateMxRecordSet withMailExchange(String mailExchangeHostName, int priority); + + /** + * Removes Mx record with the provided mail exchange server and priority from this record set. + * + * @param mailExchangeHostName the host name of the mail exchange server + * @param priority the priority for the mail exchange host, lower the value higher the priority + * @return the next stage of the record set update + */ + UpdateMxRecordSet withoutMailExchange(String mailExchangeHostName, int priority); + } + + /** + * The stage of the Ns record set definition allowing to add or remove a Ns record. + */ + interface WithNsRecordNameServer { + /** + * Creates a Ns record with the provided name server in this record set. + * + * @param nameServerHostName the name server host name + * @return the next stage of the record set update + */ + UpdateNsRecordSet withNameServer(String nameServerHostName); + + /** + * Rmoves a Ns record with the provided name server from this record set. + * + * @param nameServerHostName the name server host name + * @return the next stage of the record set update + */ + UpdateNsRecordSet withoutNameServer(String nameServerHostName); + } + + /** + * The stage of the CName record set definition allowing to add or remove Cname record. + */ + interface WithPtrRecordTargetDomainName { + /** + * Creates a CName record with the provided canonical name in this record set. + * + * @param targetDomainName the target domain name + * @return the next stage of the record set update + */ + UpdatePtrRecordSet withTargetDomainName(String targetDomainName); + + /** + * Removes the CName record with the provided canonical name from this record set. + * + * @param targetDomainName the target domain name + * @return the next stage of the record set update + */ + UpdatePtrRecordSet withoutTargetDomainName(String targetDomainName); + } + + /** + * The stage of the Srv record definition allowing to add or remove service record. + */ + interface WithSrvRecordEntry { + /** + * Specifies a service record for a service. + * + * @param target the canonical name of the target host running the service + * @param port the port on which the service is bounded + * @param priority the priority of the target host, lower the value higher the priority + * @param weight the relative weight (preference) of the records with the same priority, higher the value more the preference + * @return the next stage of the record set update + */ + UpdateSrvRecordSet withRecord(String target, int port, int priority, int weight); + + /** + * Removes a service record for a service. + * + * @param target the canonical name of the target host running the service + * @param port the port on which the service is bounded + * @param priority the priority of the target host + * @param weight the relative weight (preference) of the records + * @return the next stage of the record set update + */ + UpdateSrvRecordSet withoutRecord(String target, int port, int priority, int weight); + } + + /** + * The stage of the Srv record definition allowing to add or remove Txt record. + */ + interface WithTxtRecordTextValue { + /** + * Creates a Txt record with the given text in this record set. + * + * @param text the text value + * @return the next stage of the record set update + */ + UpdateTxtRecordSet withText(String text); + + /** + * Removes a Txt record with the given text from this record set. + * + * @param text the text value + * @return the next stage of the record set update + */ + UpdateTxtRecordSet withoutText(String text); + } + + /** + * The stage of the record set update allowing to specify Ttl for the records in this record set. + */ + interface WithTtl { + /** + * Specifies the Ttl for the records in the record set. + * + * @param ttlInSeconds ttl in seconds + * @return the next stage of the record set update + */ + Update withTimeToLive(long ttlInSeconds); + } } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java index 3967a91c4f808..4a7f3ab06afc8 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java @@ -8,5 +8,5 @@ * @param the type of the record set */ @Fluent -public interface DnsRecordSets { +public interface DnsRecordSets { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java index a8ffb08d92887..0fe240855586e 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java @@ -99,12 +99,83 @@ interface DefinitionStages { interface Blank extends GroupableResource.DefinitionStages.WithGroupAndRegion { } + /** + * The stage of the Dns zone definition allowing to specify record set. + */ + interface WithRecordSet { + /** + * Specifies definition of an A record set. + * + * @param name name of the A record set + * @return the stage representing configuration for the A record set + */ + DnsRecordSet.DefinitionStages.ARecordSetBlank defineARecordSet(String name); + + /** + * Specifies definition of an Aaaa record set. + * + * @param name name of the Aaaa record set + * @return the stage representing configuration for the Aaaa record set + */ + DnsRecordSet.DefinitionStages.AaaaRecordSetBlank defineAaaaRecordSet(String name); + + /** + * Specifies definition of a Cname record set. + * + * @param name name of the Cname record set + * @param alias the Cname record alias + * @return the next stage of Dns zone definition + */ + WithCreate withCnameRecordSet(String name, String alias); + + /** + * Specifies definition of a Mx record set. + * + * @param name name of the Mx record set + * @return the stage representing configuration for the Mx record set + */ + DnsRecordSet.DefinitionStages.MxRecordSetBlank defineMxRecordSet(String name); + + /** + * Specifies definition of an Ns record set. + * + * @param name name of the Ns record set + * @return the stage representing configuration for the Ns record set + */ + DnsRecordSet.DefinitionStages.NsRecordSetBlank defineNsRecordSet(String name); + + /** + * Specifies definition of a Ptr record set. + * + * @param name name of the Ptr record set + * @return the stage representing configuration for the Ptr record set + */ + DnsRecordSet.DefinitionStages.PtrRecordSetBlank definePtrRecordSet(String name); + + /** + * Specifies definition of a Srv record set. + * + * @param name the name of the Srv record set + * @return the stage representing configuration for the Srv record set + */ + DnsRecordSet.DefinitionStages.SrvRecordSetBlank defineSrvRecordSet(String name); + + /** + * Specifies definition of a Txt record set. + * + * @param name the name of the Txt record set + * @return the stage representing configuration for the Txt record set + */ + DnsRecordSet.DefinitionStages.TxtRecordSetBlank defineTxtRecordSet(String name); + } + /** * The stage of the definition which contains all the minimum required inputs for the resource to be created * (via {@link WithCreate#create()}), but also allows for any other optional settings to be specified. */ interface WithCreate extends Creatable, + DefinitionStages.WithRecordSet, Resource.DefinitionWithTags { } } @@ -113,6 +184,195 @@ interface WithCreate extends * Grouping of Dns zone update stages. */ interface UpdateStages { + /** + * The stage of the Dns zone update allowing to specify record set. + */ + interface WithRecordSet { + /** + * Specifies definition of an A record set to be attached to the Dns zone. + * + * @param name name of the A record set + * @return the stage representing configuration for the A record set + */ + DnsRecordSet.UpdateDefinitionStages.ARecordSetBlank defineARecordSet(String name); + + /** + * Specifies definition of an Aaaa record set to be attached to the Dns zone. + * + * @param name name of the Aaaa record set + * @return the stage representing configuration for the Aaaa record set + */ + DnsRecordSet.UpdateDefinitionStages.AaaaRecordSetBlank defineAaaaRecordSet(String name); + + /** + * Specifies definition of a Cname record set to be attached to the Dns zone. + * + * @param name name of the Cname record set + * @param alias the Cname record alias + * @return the next stage of Dns zone definition + */ + Update withCnameRecordSet(String name, String alias); + + /** + * Specifies definition of a Mx record set to be attached to the Dns zone. + * + * @param name name of the Mx record set + * @return the stage representing configuration for the Mx record set + */ + DnsRecordSet.UpdateDefinitionStages.MxRecordSetBlank defineMxRecordSet(String name); + + /** + * Specifies definition of an Ns record set to be attached to the Dns zone. + * + * @param name name of the Ns record set + * @return the stage representing configuration for the Ns record set + */ + DnsRecordSet.UpdateDefinitionStages.NsRecordSetBlank defineNsRecordSet(String name); + + /** + * Specifies definition of a Ptr record set to be attached to the Dns zone. + * + * @param name name of the Ptr record set + * @return the stage representing configuration for the Ptr record set + */ + DnsRecordSet.UpdateDefinitionStages.PtrRecordSetBlank definePtrRecordSet(String name); + + /** + * Specifies definition of a Srv record set to be attached to the Dns zone. + * + * @param name the name of the Srv record set + * @return the stage representing configuration for the Srv record set + */ + DnsRecordSet.UpdateDefinitionStages.SrvRecordSetBlank defineSrvRecordSet(String name); + + /** + * Specifies definition of a Txt record set to be attached to the Dns zone. + * + * @param name the name of the Txt record set + * @return the stage representing configuration for the Txt record set + */ + DnsRecordSet.UpdateDefinitionStages.TxtRecordSetBlank defineTxtRecordSet(String name); + + /** + * Begins the description of an update of an existing A record set in this Dns zone. + * + * @param name name of the A record set + * @return the stage representing configuration for the A record set + */ + DnsRecordSet.UpdateARecordSet updateARecordSet(String name); + + /** + * Begins the description of an update of an existing Aaaa record set in this Dns zone. + * + * @param name name of the Aaaa record set + * @return the stage representing configuration for the Aaaa record set + */ + DnsRecordSet.UpdateAaaaRecordSet updateAaaaRecordSet(String name); + + /** + * Begins the description of an update of an existing Mx record set in this Dns zone. + * + * @param name name of the Mx record set + * @return the stage representing configuration for the Mx record set + */ + DnsRecordSet.UpdateMxRecordSet updateMxRecordSet(String name); + + /** + * Begins the description of an update of an existing Ns record set in this Dns zone. + * + * @param name name of the Ns record set + * @return the stage representing configuration for the Ns record set + */ + DnsRecordSet.UpdateNsRecordSet updateNsRecordSet(String name); + + /** + * Begins the description of an update of an existing Ptr record set in this Dns zone. + * + * @param name name of the Ptr record set + * @return the stage representing configuration for the Ptr record set + */ + DnsRecordSet.UpdatePtrRecordSet updatePtrRecordSet(String name); + + /** + * Begins the description of an update of an existing Srv record set in this Dns zone. + * + * @param name the name of the Srv record set + * @return the stage representing configuration for the Srv record set + */ + DnsRecordSet.UpdateSrvRecordSet updateSrvRecordSet(String name); + + /** + * Begins the description of an update of an existing Txt record set in this Dns zone. + * + * @param name the name of the Txt record set + * @return the stage representing configuration for the Txt record set + */ + DnsRecordSet.UpdateTxtRecordSet updateTxtRecordSet(String name); + + /** + * Removes a A record set in the Dns zone. + * + * @param name name of the A record set + * @return the next stage of Dns zone update + */ + Update withoutARecordSet(String name); + + /** + * Removes a Aaaa record set in the Dns zone. + * + * @param name name of the Aaaa record set + * @return the next stage of Dns zone update + */ + Update withoutAaaaRecordSet(String name); + + /** + * Removes a Cname record set in the Dns zone. + * + * @param name name of the Cname record set + * @return the next stage of Dns zone update + */ + Update withoutCnameRecordSet(String name); + + /** + * Removes a Mx record set in the Dns zone. + * + * @param name name of the Mx record set + * @return the next stage of Dns zone update + */ + Update withoutMxRecordSet(String name); + + /** + * Removes a Ns record set in the Dns zone. + * + * @param name name of the Ns record set + * @return the next stage of Dns zone update + */ + Update withoutNsRecordSet(String name); + + /** + * Removes a Ptr record set in the Dns zone. + * + * @param name name of the Ptr record set + * @return the next stage of Dns zone update + */ + Update withoutPtrRecordSet(String name); + + /** + * Removes a Srv record set in the Dns zone. + * + * @param name name of the Srv record set + * @return the next stage of Dns zone update + */ + Update withoutSrvRecordSet(String name); + + /** + * Removes a Txt record set in the Dns zone. + * + * @param name name of the Txt record set + * @return the next stage of Dns zone update + */ + Update withoutTxtRecordSet(String name); + } } /** @@ -122,6 +382,7 @@ interface UpdateStages { */ interface Update extends Appliable, + UpdateStages.WithRecordSet, Resource.UpdateWithTags { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java index 922267bdadcdf..e6aeb3442b7e9 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSets.java @@ -1,21 +1,14 @@ package com.microsoft.azure.management.dns; import com.microsoft.azure.management.apigeneration.Fluent; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** - * Entry point to Dns zone Mx record set management API. + * Entry point to Mx record sets in a Dns zone. */ @Fluent public interface MxRecordSets extends - DnsRecordSets, SupportsListing, - SupportsGettingByName, - SupportsGettingById, - SupportsCreating, - SupportsDeletingById { + SupportsGettingByName { } \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java index ddd96ca818f95..f2e8242c0dfe5 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSets.java @@ -1,21 +1,14 @@ package com.microsoft.azure.management.dns; import com.microsoft.azure.management.apigeneration.Fluent; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** - * Entry point to Dns zone Ns record set management API. + * Entry point to Ns record sets in a Dns zone. */ @Fluent public interface NsRecordSets extends - DnsRecordSets, SupportsListing, - SupportsGettingByName, - SupportsGettingById, - SupportsCreating, - SupportsDeletingById { + SupportsGettingByName { } \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java index a46cb2afae533..8c1a4b92c9863 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSets.java @@ -1,21 +1,14 @@ package com.microsoft.azure.management.dns; import com.microsoft.azure.management.apigeneration.Fluent; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** - * Entry point to Dns zone Ptr record set management API. + * Entry point to Ptr record sets in a Dns zone. */ @Fluent public interface PtrRecordSets extends - DnsRecordSets, SupportsListing, - SupportsGettingByName, - SupportsGettingById, - SupportsCreating, - SupportsDeletingById { + SupportsGettingByName { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java index b7ef30ed1bba2..313c4b8e130d6 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSets.java @@ -5,11 +5,10 @@ import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** - * Entry point to Dns zone Soa record set management API. + * Entry point to Soa record sets in a Dns zone. */ @Fluent public interface SoaRecordSets extends - DnsRecordSets, SupportsListing, SupportsGettingById { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java index f6de9cb271e86..e3051edd40fb6 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSets.java @@ -1,21 +1,14 @@ package com.microsoft.azure.management.dns; import com.microsoft.azure.management.apigeneration.Fluent; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** - * Entry point to Dns zone Srv record set management API. + * Entry point to Srv record sets in a Dns zone. */ @Fluent public interface SrvRecordSets extends - DnsRecordSets, SupportsListing, - SupportsGettingByName, - SupportsGettingById, - SupportsCreating, - SupportsDeletingById { + SupportsGettingByName { } \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java index bd6a8ec97ef48..1b91a7465878d 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSets.java @@ -1,22 +1,14 @@ package com.microsoft.azure.management.dns; import com.microsoft.azure.management.apigeneration.Fluent; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingByName; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** - * Entry point to Dns zone Txt record set management API. + * Entry point to Txt record sets in a Dns zone. */ @Fluent public interface TxtRecordSets extends - DnsRecordSets, SupportsListing, - SupportsGettingByName, - SupportsGettingById, - SupportsCreating, - SupportsDeletingById { + SupportsGettingByName { } \ No newline at end of file diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetsImpl.java index 0f45021d730bd..d763f85041642 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetsImpl.java @@ -4,14 +4,13 @@ import com.microsoft.azure.management.dns.ARecordSet; import com.microsoft.azure.management.dns.ARecordSets; import com.microsoft.azure.management.dns.RecordType; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; -import rx.Observable; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; /** * Implementation of {@link ARecordSets}. */ class ARecordSetsImpl - extends CreatableWrappersImpl + extends ReadableWrappersImpl implements ARecordSets { private final DnsZoneImpl dnsZone; @@ -31,31 +30,11 @@ public ARecordSetImpl getByName(String name) { return new ARecordSetImpl(this.dnsZone, inner, this.client); } - @Override - public ARecordSetImpl getById(String id) { - return null; - } - - @Override - public ARecordSetImpl define(String name) { - return wrapModel(name); - } - - @Override - public Observable deleteByIdAsync(String id) { - return null; - } - @Override public PagedList list() { - return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.A)); - } - - @Override - protected ARecordSetImpl wrapModel(String name) { - RecordSetInner inner = new RecordSetInner(); - inner.withName(name).withType(RecordType.A.toString()); - return wrapModel(inner); + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + RecordType.A)); } @Override diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetsImpl.java index 7ad682a1a7083..da13001bfd0bd 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetsImpl.java @@ -4,14 +4,13 @@ import com.microsoft.azure.management.dns.AaaaRecordSet; import com.microsoft.azure.management.dns.AaaaRecordSets; import com.microsoft.azure.management.dns.RecordType; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; -import rx.Observable; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; /** * Implementation of {@link AaaaRecordSets}. */ class AaaaRecordSetsImpl - extends CreatableWrappersImpl + extends ReadableWrappersImpl implements AaaaRecordSets { private final DnsZoneImpl dnsZone; @@ -31,31 +30,11 @@ public AaaaRecordSetImpl getByName(String name) { return new AaaaRecordSetImpl(this.dnsZone, inner, this.client); } - @Override - public AaaaRecordSetImpl getById(String id) { - return null; - } - - @Override - public AaaaRecordSetImpl define(String name) { - return wrapModel(name); - } - - @Override - public Observable deleteByIdAsync(String id) { - return null; - } - @Override public PagedList list() { - return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.AAAA)); - } - - @Override - protected AaaaRecordSetImpl wrapModel(String name) { - RecordSetInner inner = new RecordSetInner(); - inner.withName(name).withType(RecordType.AAAA.toString()); - return wrapModel(inner); + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + RecordType.AAAA)); } @Override diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetsImpl.java index 2e33a5741eee0..90c1eeaec1d89 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetsImpl.java @@ -4,14 +4,13 @@ import com.microsoft.azure.management.dns.CnameRecordSet; import com.microsoft.azure.management.dns.CnameRecordSets; import com.microsoft.azure.management.dns.RecordType; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; -import rx.Observable; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; /** * Implementation of {@link CnameRecordSets}. */ class CnameRecordSetsImpl - extends CreatableWrappersImpl + extends ReadableWrappersImpl implements CnameRecordSets { private final DnsZoneImpl dnsZone; @@ -31,31 +30,11 @@ public CnameRecordSet getByName(String name) { return new CnameRecordSetImpl(this.dnsZone, inner, this.client); } - @Override - public CnameRecordSet getById(String id) { - return null; - } - - @Override - public CnameRecordSetImpl define(String name) { - return wrapModel(name); - } - - @Override - public Observable deleteByIdAsync(String id) { - return null; - } - @Override public PagedList list() { - return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.CNAME)); - } - - @Override - protected CnameRecordSetImpl wrapModel(String name) { - RecordSetInner inner = new RecordSetInner(); - inner.withName(name).withType(RecordType.CNAME.toString()); - return wrapModel(inner); + return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), + this.dnsZone.name(), + RecordType.CNAME)); } @Override diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetsImpl.java index 651d686b316dd..0e6d7bb20c152 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetsImpl.java @@ -4,14 +4,13 @@ import com.microsoft.azure.management.dns.MxRecordSet; import com.microsoft.azure.management.dns.MxRecordSets; import com.microsoft.azure.management.dns.RecordType; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; -import rx.Observable; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; /** * Implementation of {@link MxRecordSets}. */ class MxRecordSetsImpl - extends CreatableWrappersImpl + extends ReadableWrappersImpl implements MxRecordSets { private final DnsZoneImpl dnsZone; @@ -31,33 +30,11 @@ public MxRecordSetImpl getByName(String name) { return new MxRecordSetImpl(this.dnsZone, inner, this.client); } - @Override - public MxRecordSetImpl getById(String id) { - return null; - } - - @Override - public MxRecordSetImpl define(String name) { - return wrapModel(name); - } - - @Override - public Observable deleteByIdAsync(String id) { - return null; - } - @Override public PagedList list() { return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.MX)); } - @Override - protected MxRecordSetImpl wrapModel(String name) { - RecordSetInner inner = new RecordSetInner(); - inner.withName(name).withType(RecordType.MX.toString()); - return wrapModel(inner); - } - @Override protected MxRecordSetImpl wrapModel(RecordSetInner inner) { return new MxRecordSetImpl(this.dnsZone, inner, this.client); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetsImpl.java index 97816df24fedc..4b4b75da46bd0 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetsImpl.java @@ -4,14 +4,13 @@ import com.microsoft.azure.management.dns.NsRecordSet; import com.microsoft.azure.management.dns.NsRecordSets; import com.microsoft.azure.management.dns.RecordType; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; -import rx.Observable; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; /** * Implementation of {@link NsRecordSets}. */ class NsRecordSetsImpl - extends CreatableWrappersImpl + extends ReadableWrappersImpl implements NsRecordSets { private final DnsZoneImpl dnsZone; @@ -31,33 +30,11 @@ public NsRecordSetImpl getByName(String name) { return new NsRecordSetImpl(this.dnsZone, inner, this.client); } - @Override - public NsRecordSetImpl getById(String id) { - return null; - } - - @Override - public NsRecordSetImpl define(String name) { - return wrapModel(name); - } - - @Override - public Observable deleteByIdAsync(String id) { - return null; - } - @Override public PagedList list() { return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.NS)); } - @Override - protected NsRecordSetImpl wrapModel(String name) { - RecordSetInner inner = new RecordSetInner(); - inner.withName(name).withType(RecordType.NS.toString()); - return wrapModel(inner); - } - @Override protected NsRecordSetImpl wrapModel(RecordSetInner inner) { return new NsRecordSetImpl(this.dnsZone, inner, this.client); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetsImpl.java index f6f9762478f2d..2ec079d0383e1 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetsImpl.java @@ -4,14 +4,13 @@ import com.microsoft.azure.management.dns.PtrRecordSet; import com.microsoft.azure.management.dns.PtrRecordSets; import com.microsoft.azure.management.dns.RecordType; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; -import rx.Observable; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; /** * Implementation of {@link PtrRecordSets}. */ class PtrRecordSetsImpl - extends CreatableWrappersImpl + extends ReadableWrappersImpl implements PtrRecordSets { private final DnsZoneImpl dnsZone; @@ -31,33 +30,11 @@ public PtrRecordSetImpl getByName(String name) { return new PtrRecordSetImpl(this.dnsZone, inner, this.client); } - @Override - public PtrRecordSetImpl getById(String id) { - return null; - } - - @Override - public PtrRecordSetImpl define(String name) { - return wrapModel(name); - } - - @Override - public Observable deleteByIdAsync(String id) { - return null; - } - @Override public PagedList list() { return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.PTR)); } - @Override - protected PtrRecordSetImpl wrapModel(String name) { - RecordSetInner inner = new RecordSetInner(); - inner.withName(name).withType(RecordType.PTR.toString()); - return wrapModel(inner); - } - @Override protected PtrRecordSetImpl wrapModel(RecordSetInner inner) { return new PtrRecordSetImpl(this.dnsZone, inner, this.client); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java index 7f741d9ab36f7..16c744f6a91af 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetsImpl.java @@ -4,14 +4,13 @@ import com.microsoft.azure.management.dns.RecordType; import com.microsoft.azure.management.dns.SrvRecordSet; import com.microsoft.azure.management.dns.SrvRecordSets; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; -import rx.Observable; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; /** * Implementation of {@link SrvRecordSets}. */ class SrvRecordSetsImpl - extends CreatableWrappersImpl + extends ReadableWrappersImpl implements SrvRecordSets { private final DnsZoneImpl dnsZone; @@ -31,33 +30,11 @@ public SrvRecordSetImpl getByName(String name) { return new SrvRecordSetImpl(this.dnsZone, inner, this.client); } - @Override - public SrvRecordSetImpl getById(String id) { - return null; - } - - @Override - public SrvRecordSetImpl define(String name) { - return wrapModel(name); - } - - @Override - public Observable deleteByIdAsync(String id) { - return null; - } - @Override public PagedList list() { return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.SRV)); } - @Override - protected SrvRecordSetImpl wrapModel(String name) { - RecordSetInner inner = new RecordSetInner(); - inner.withName(name).withType(RecordType.SRV.toString()); - return wrapModel(inner); - } - @Override protected SrvRecordSetImpl wrapModel(RecordSetInner inner) { return new SrvRecordSetImpl(this.dnsZone, inner, this.client); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetsImpl.java index 505e5c46d3879..da01adc9454c5 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetsImpl.java @@ -4,14 +4,13 @@ import com.microsoft.azure.management.dns.RecordType; import com.microsoft.azure.management.dns.TxtRecordSet; import com.microsoft.azure.management.dns.TxtRecordSets; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; -import rx.Observable; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl; /** * Implementation of {@link TxtRecordSets}. */ class TxtRecordSetsImpl - extends CreatableWrappersImpl + extends ReadableWrappersImpl implements TxtRecordSets { private final DnsZoneImpl dnsZone; @@ -31,33 +30,11 @@ public TxtRecordSetImpl getByName(String name) { return new TxtRecordSetImpl(this.dnsZone, inner, this.client); } - @Override - public TxtRecordSetImpl getById(String id) { - return null; - } - - @Override - public TxtRecordSetImpl define(String name) { - return wrapModel(name); - } - - @Override - public Observable deleteByIdAsync(String id) { - return null; - } - @Override public PagedList list() { return super.wrapList(this.client.listByType(this.dnsZone.resourceGroupName(), this.dnsZone.name(), RecordType.TXT)); } - @Override - protected TxtRecordSetImpl wrapModel(String name) { - RecordSetInner inner = new RecordSetInner(); - inner.withName(name).withType(RecordType.TXT.toString()); - return wrapModel(inner); - } - @Override protected TxtRecordSetImpl wrapModel(RecordSetInner inner) { return new TxtRecordSetImpl(this.dnsZone, inner, this.client); From 1b663bafbeb0b9ba3d34f8b34585aa01fa3b87b7 Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 3 Nov 2016 17:16:22 -0700 Subject: [PATCH 11/27] implementing def and update stages in DnsRecordSetImpl --- .../azure/management/dns/ARecordSet.java | 6 +- .../azure/management/dns/AaaaRecordSet.java | 8 +- .../azure/management/dns/CnameRecordSet.java | 8 +- .../azure/management/dns/DnsRecordSet.java | 133 +++++++-- .../azure/management/dns/MxRecordSet.java | 6 +- .../azure/management/dns/NsRecordSet.java | 6 +- .../azure/management/dns/PtrRecordSet.java | 6 +- .../azure/management/dns/SoaRecordSet.java | 4 +- .../azure/management/dns/SrvRecordSet.java | 6 +- .../azure/management/dns/TxtRecordSet.java | 6 +- .../dns/implementation/ARecordSetImpl.java | 50 ++-- .../dns/implementation/AaaaRecordSetImpl.java | 50 ++-- .../implementation/CnameRecordSetImpl.java | 25 +- .../dns/implementation/DnsRecordSetImpl.java | 272 +++++++++++++++--- .../dns/implementation/DnsZoneImpl.java | 117 ++++++++ .../dns/implementation/MxRecordSetImpl.java | 50 ++-- .../dns/implementation/NsRecordSetImpl.java | 50 ++-- .../dns/implementation/PtrRecordSetImpl.java | 50 ++-- .../dns/implementation/SrvRecordSetImpl.java | 60 ++-- .../dns/implementation/TxtRecordSetImpl.java | 52 ++-- .../fluentcore/arm/models/Resource.java | 8 +- .../models/{HasTags.java => Taggable.java} | 2 +- 22 files changed, 641 insertions(+), 334 deletions(-) rename azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/{HasTags.java => Taggable.java} (98%) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java index 181582aa69ec6..717bb695f4cd0 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java @@ -1,6 +1,6 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; @@ -66,7 +66,7 @@ interface WithTtl { */ interface WithCreate extends Creatable, - HasTags.DefinitionWithTags, + Taggable.DefinitionWithTags, DefinitionStages.WithTtl { } } @@ -118,7 +118,7 @@ interface WithTtl { */ interface Update extends Appliable, - HasTags.UpdateWithTags, + Taggable.UpdateWithTags, UpdateStages.WithIpv4Address, UpdateStages.WithTtl { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java index bc9b12ea84977..744c461141c57 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java @@ -1,6 +1,6 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; @@ -9,7 +9,7 @@ /** * An immutable client-side representation of a Aaaa (Ipv6) record set in Azure Dns Zone. */ -public interface AaaaRecordSet extends DnsRecordSet { +public interface AaaaRecordSet extends DnsRecordSet { /** * @return the IPv6 addresses of Aaaa records in this record set */ @@ -67,7 +67,7 @@ interface WithTtl { */ interface WithCreate extends Creatable, - HasTags.DefinitionWithTags, + Taggable.DefinitionWithTags, DefinitionStages.WithIpv6Address, DefinitionStages.WithTtl { } @@ -120,7 +120,7 @@ interface WithTtl { */ interface Update extends Appliable, - HasTags.UpdateWithTags, + Taggable.UpdateWithTags, UpdateStages.WithIpv6Address, UpdateStages.WithTtl { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java index 39c7286007ddb..e06f00d8c9d55 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java @@ -1,11 +1,9 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; -import java.util.List; - /** * An immutable client-side representation of a CName (canonical name) record set in Azure Dns Zone. */ @@ -67,7 +65,7 @@ interface WithTtl { */ interface WithCreate extends Creatable, - HasTags.DefinitionWithTags, + Taggable.DefinitionWithTags, DefinitionStages.WithTtl { } } @@ -98,7 +96,7 @@ interface WithTtl { */ interface Update extends Appliable, - HasTags.UpdateWithTags, + Taggable.UpdateWithTags, UpdateStages.WithTtl { } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index 0b17954d61047..d47209d2e2c46 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -2,17 +2,17 @@ import com.microsoft.azure.management.dns.implementation.RecordSetInner; import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; import com.microsoft.azure.management.resources.fluentcore.model.Attachable; import com.microsoft.azure.management.resources.fluentcore.model.Settable; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; +import java.util.Map; + /** * An immutable client-side representation of a record set in Azure Dns Zone. */ -public interface DnsRecordSet extends - ExternalChildResource, - HasTags, +public interface DnsRecordSet extends + ExternalChildResource, Wrapper { /** @@ -42,6 +42,7 @@ interface Definition extends DefinitionStages.WithMxRecordMailExchangeOrAttachable, DefinitionStages.NsRecordSetBlank, DefinitionStages.WithNsRecordNameServer, + DefinitionStages.WithNsRecordNameServerOrAttachable, DefinitionStages.PtrRecordSetBlank, DefinitionStages.WithPtrRecordTargetDomainName, DefinitionStages.WithPtrRecordTargetDomainNameOrAttachable, @@ -88,7 +89,7 @@ interface WithARecordIpv4Address { * @param the return type of {@link WithAttach#attach()} */ interface WithARecordIpv4AddressOrAttachable - extends WithARecordIpv4Address, Attachable { + extends WithARecordIpv4Address, WithAttach { } /** @@ -121,7 +122,7 @@ interface WithAaaaRecordIpv6Address { * @param the return type of {@link WithAttach#attach()} */ interface WithAaaaRecordIpv6AddressOrAttachable - extends WithAaaaRecordIpv6Address, Attachable { + extends WithAaaaRecordIpv6Address, WithAttach { } /** @@ -155,7 +156,7 @@ interface WithMxRecordMailExchange { * @param the return type of {@link WithAttach#attach()} */ interface WithMxRecordMailExchangeOrAttachable - extends WithMxRecordMailExchange, Attachable { + extends WithMxRecordMailExchange, WithAttach { } /** @@ -178,7 +179,17 @@ interface WithNsRecordNameServer { * @param nameServerHostName the name server host name * @return the next stage of the record set definition */ - Attachable withNameServer(String nameServerHostName); + WithNsRecordNameServerOrAttachable withNameServer(String nameServerHostName); + } + + /** + * The stage of the Ns record set definition allowing to add additional Ns records or + * attach the record set to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithNsRecordNameServerOrAttachable + extends WithNsRecordNameServer, WithAttach { } /** @@ -211,7 +222,7 @@ interface WithPtrRecordTargetDomainName { * @param the return type of {@link WithAttach#attach()} */ interface WithPtrRecordTargetDomainNameOrAttachable - extends WithPtrRecordTargetDomainName, Attachable { + extends WithPtrRecordTargetDomainName, WithAttach { } /** @@ -247,7 +258,7 @@ interface WithSrvRecordEntry { * @param the return type of {@link WithAttach#attach()} */ interface WithSrvRecordEntryOrAttachable - extends WithSrvRecordEntry, Attachable { + extends WithSrvRecordEntry, WithAttach { } /** @@ -280,7 +291,7 @@ interface WithTxtRecordTextValue { * @param the return type of {@link WithAttach#attach()} */ interface WithTxtRecordTextValueOrAttachable - extends WithTxtRecordTextValue, Attachable { + extends WithTxtRecordTextValue, WithAttach { } /** @@ -298,6 +309,28 @@ interface WithTtl { WithAttach withTimeToLive(long ttlInSeconds); } + /** + * The stage of the record set definition allowing to specify tags. + * + * @param the return type of {@link UpdateDefinitionStages.WithAttach#attach()} + */ + interface WithTags { + /** + * Specifies tags for the resource as a {@link Map}. + * @param tags a {@link Map} of tags + * @return the next stage of the record set definition + */ + WithAttach withTags(Map tags); + + /** + * Adds a tag to the resource. + * @param key the key for the tag + * @param value the value for the tag + * @return the next stage of the record set definition + */ + WithAttach withTag(String key, String value); + } + /** The final stage of the Dns zone record set definition. *

* At this stage, any remaining optional settings can be specified, or the Dns zone record set @@ -306,6 +339,7 @@ interface WithTtl { */ interface WithAttach extends Attachable.InDefinition, + DefinitionStages.WithTags, DefinitionStages.WithTtl { } } @@ -327,6 +361,7 @@ interface UpdateDefinition extends UpdateDefinitionStages.WithMxRecordMailExchangeOrAttachable, UpdateDefinitionStages.NsRecordSetBlank, UpdateDefinitionStages.WithNsRecordNameServer, + UpdateDefinitionStages.WithNsRecordNameServerOrAttachable, UpdateDefinitionStages.PtrRecordSetBlank, UpdateDefinitionStages.WithPtrRecordTargetDomainName, UpdateDefinitionStages.WithPtrRecordTargetDomainNameOrAttachable, @@ -373,7 +408,7 @@ interface WithARecordIpv4Address { * @param the return type of {@link WithAttach#attach()} */ interface WithARecordIpv4AddressOrAttachable - extends WithARecordIpv4Address, Attachable { + extends WithARecordIpv4Address, WithAttach { } /** @@ -406,7 +441,7 @@ interface WithAaaaRecordIpv6Address { * @param the return type of {@link WithAttach#attach()} */ interface WithAaaaRecordIpv6AddressOrAttachable - extends WithAaaaRecordIpv6Address, Attachable { + extends WithAaaaRecordIpv6Address, WithAttach { } /** @@ -440,7 +475,7 @@ interface WithMxRecordMailExchange { * @param the return type of {@link WithAttach#attach()} */ interface WithMxRecordMailExchangeOrAttachable - extends WithMxRecordMailExchange, Attachable { + extends WithMxRecordMailExchange, WithAttach { } /** @@ -463,7 +498,17 @@ interface WithNsRecordNameServer { * @param nameServerHostName the name server host name * @return the next stage of the record set definition */ - Attachable withNameServer(String nameServerHostName); + WithNsRecordNameServerOrAttachable withNameServer(String nameServerHostName); + } + + /** + * The stage of the Ns record set definition allowing to add additional Ns records or + * attach the record set to the parent. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithNsRecordNameServerOrAttachable + extends WithNsRecordNameServer, WithAttach { } /** @@ -496,7 +541,7 @@ interface WithPtrRecordTargetDomainName { * @param the return type of {@link WithAttach#attach()} */ interface WithPtrRecordTargetDomainNameOrAttachable - extends WithPtrRecordTargetDomainName, Attachable { + extends WithPtrRecordTargetDomainName, WithAttach { } /** @@ -532,7 +577,7 @@ interface WithSrvRecordEntry { * @param the return type of {@link WithAttach#attach()} */ interface WithSrvRecordEntryOrAttachable - extends WithSrvRecordEntry, Attachable { + extends WithSrvRecordEntry, WithAttach { } /** @@ -565,7 +610,7 @@ interface WithTxtRecordTextValue { * @param the return type of {@link WithAttach#attach()} */ interface WithTxtRecordTextValueOrAttachable - extends WithTxtRecordTextValue, Attachable { + extends WithTxtRecordTextValue, WithAttach { } /** @@ -583,6 +628,28 @@ interface WithTtl { WithAttach withTimeToLive(long ttlInSeconds); } + /** + * The stage of the record set definition allowing to specify tags. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTags { + /** + * Specifies tags for the resource as a {@link Map}. + * @param tags a {@link Map} of tags + * @return the next stage of the record set update + */ + WithAttach withTags(Map tags); + + /** + * Adds a tag to the resource. + * @param key the key for the tag + * @param value the value for the tag + * @return the next stage of the record set definition + */ + WithAttach withTag(String key, String value); + } + /** The final stage of the Dns zone record set definition. *

* At this stage, any remaining optional settings can be specified, or the Dns zone record set @@ -592,6 +659,7 @@ interface WithTtl { */ interface WithAttach extends Attachable.InUpdate, + UpdateDefinitionStages.WithTags, UpdateDefinitionStages.WithTtl { } } @@ -604,6 +672,7 @@ interface UpdateCombined extends UpdateAaaaRecordSet, UpdatePtrRecordSet, UpdateMxRecordSet, + UpdateNsRecordSet, UpdateSrvRecordSet, UpdateTxtRecordSet, Update { @@ -670,6 +739,7 @@ interface UpdateTxtRecordSet extends */ interface Update extends Settable, + UpdateStages.UpdateWithTags, UpdateStages.WithTtl { } @@ -844,5 +914,32 @@ interface WithTtl { */ Update withTimeToLive(long ttlInSeconds); } + + /** + * An update allowing tags to be modified for the resource. + */ + interface UpdateWithTags { + /** + * Specifies tags for the record set as a {@link Map}. + * @param tags a {@link Map} of tags + * @return the next stage of the record set update + */ + Update withTags(Map tags); + + /** + * Adds a tag to the record set. + * @param key the key for the tag + * @param value the value for the tag + * @return the next stage of the record set update + */ + Update withTag(String key, String value); + + /** + * Removes a tag from the record set. + * @param key the key of the tag to remove + * @return the next stage of the record set update + */ + Update withoutTag(String key); + } } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java index 5546741d736f9..bc5c7554b2d12 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java @@ -1,6 +1,6 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; @@ -68,7 +68,7 @@ interface WithTtl { */ interface WithCreate extends Creatable, - HasTags.DefinitionWithTags, + Taggable.DefinitionWithTags, DefinitionStages.WithMailExchange, DefinitionStages.WithTtl { } @@ -123,7 +123,7 @@ interface WithTtl { */ interface Update extends Appliable, - HasTags.UpdateWithTags, + Taggable.UpdateWithTags, UpdateStages.WithMailExchange, UpdateStages.WithTtl { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java index 527537db4ad29..6e56cbdfaf11a 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java @@ -1,6 +1,6 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; @@ -64,7 +64,7 @@ interface WithTtl { */ interface WithCreate extends Creatable, - HasTags.DefinitionWithTags, + Taggable.DefinitionWithTags, DefinitionStages.WithNameServer, DefinitionStages.WithTtl { } @@ -117,7 +117,7 @@ interface WithTtl { */ interface Update extends Appliable, - HasTags.UpdateWithTags, + Taggable.UpdateWithTags, UpdateStages.WithNameServer, UpdateStages.WithTtl { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java index 8049b1601dd8f..0b5990dbbbc22 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java @@ -1,6 +1,6 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; @@ -67,7 +67,7 @@ interface WithTtl { */ interface WithCreate extends Creatable, - HasTags.DefinitionWithTags, + Taggable.DefinitionWithTags, DefinitionStages.WithTargetDomain, DefinitionStages.WithTtl { } @@ -120,7 +120,7 @@ interface WithTtl { */ interface Update extends Appliable, - HasTags.UpdateWithTags, + Taggable.UpdateWithTags, UpdateStages.WithTargetDomain, UpdateStages.WithTtl { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java index 59fbdfd50e4da..da192e8569903 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java @@ -1,6 +1,6 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; /** @@ -119,7 +119,7 @@ interface WithTtl { */ interface Update extends Appliable, - HasTags.UpdateWithTags, + Taggable.UpdateWithTags, UpdateStages.WithEmailServer, UpdateStages.WithRefreshTime, UpdateStages.WithRetryTime, diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java index a8a4c15ec641f..c95b8c47f4767 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java @@ -1,6 +1,6 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; @@ -70,7 +70,7 @@ interface WithTtl { */ interface WithCreate extends Creatable, - HasTags.DefinitionWithTags, + Taggable.DefinitionWithTags, DefinitionStages.WithRecord, DefinitionStages.WithTtl { } @@ -129,7 +129,7 @@ interface WithTtl { */ interface Update extends Appliable, - HasTags.UpdateWithTags, + Taggable.UpdateWithTags, UpdateStages.WithRecord, UpdateStages.WithTtl { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java index 34e34296d7959..8edf6e046222b 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java @@ -1,6 +1,6 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.HasTags; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; import com.microsoft.azure.management.resources.fluentcore.model.Appliable; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; @@ -67,7 +67,7 @@ interface WithTtl { */ interface WithCreate extends Creatable, - HasTags.DefinitionWithTags, + Taggable.DefinitionWithTags, DefinitionStages.WithText, DefinitionStages.WithTtl { } @@ -120,7 +120,7 @@ interface WithTtl { */ interface Update extends Appliable, - HasTags.UpdateWithTags, + Taggable.UpdateWithTags, UpdateStages.WithText, UpdateStages.WithTtl { } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java index 8c9f720d1a240..fc54e27030768 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java @@ -2,7 +2,6 @@ import com.microsoft.azure.management.dns.ARecord; import com.microsoft.azure.management.dns.ARecordSet; -import rx.functions.Func1; import java.util.ArrayList; import java.util.Collections; @@ -12,11 +11,8 @@ * Implementation of {@link ARecordSet}. */ class ARecordSetImpl - extends DnsRecordSetImpl - implements - ARecordSet, - ARecordSet.Definition, - ARecordSet.Update { + extends DnsRecordSetImpl + implements ARecordSet { ARecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -33,35 +29,29 @@ public List ipv4Addresses() { } @Override - public ARecordSetImpl refresh() { - this.refreshInner(); - return this; - } + protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + if (this.inner().aRecords() != null && this.inner().aRecords().size() > 0) { + if (resource.aRecords() == null) { + resource.withARecords(new ArrayList()); + } - @Override - public ARecordSetImpl withIpv4Address(String ipv4Address) { - if (this.inner().aRecords() == null) { - this.inner().withARecords(new ArrayList()); + for (ARecord recordToAdd : this.inner().aRecords()) { + resource.aRecords().add(recordToAdd); + } } - this.inner().aRecords().add(new ARecord().withIpv4Address(ipv4Address)); - return this; - } - @Override - public ARecordSetImpl withoutIpv4Address(String ipv4Address) { - if (this.inner().aRecords() != null) { - for (ARecord record : this.inner().aRecords()) { - if (record.ipv4Address().equalsIgnoreCase(ipv4Address)) { - this.inner().aRecords().remove(record); - break; + if (recordSetRemoveInfo.aRecords().size() > 0) { + if (resource.aRecords() != null) { + for (ARecord recordToRemove : recordSetRemoveInfo.aRecords()) { + for (ARecord record : resource.aRecords()) { + if (record.ipv4Address().equalsIgnoreCase(recordToRemove.ipv4Address())) { + resource.aRecords().remove(record); + break; + } + } } } } - return this; - } - - @Override - protected Func1 innerToFluentMap() { - return super.innerToFluentMap(this); + return resource; } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java index 9dbe214daeeb8..92ccd10a0d218 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java @@ -2,7 +2,6 @@ import com.microsoft.azure.management.dns.AaaaRecord; import com.microsoft.azure.management.dns.AaaaRecordSet; -import rx.functions.Func1; import java.util.ArrayList; import java.util.Collections; @@ -12,11 +11,8 @@ * Implementation of {@link AaaaRecordSet}. */ class AaaaRecordSetImpl - extends DnsRecordSetImpl - implements - AaaaRecordSet, - AaaaRecordSet.Definition, - AaaaRecordSet.Update { + extends DnsRecordSetImpl + implements AaaaRecordSet { AaaaRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); @@ -34,35 +30,29 @@ public List ipv6Addresses() { } @Override - public AaaaRecordSetImpl refresh() { - this.refreshInner(); - return this; - } + protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + if (this.inner().aaaaRecords() != null && this.inner().aaaaRecords().size() > 0) { + if (resource.aaaaRecords() == null) { + resource.withAaaaRecords(new ArrayList()); + } - @Override - public AaaaRecordSetImpl withIpv6Address(String ipv6Address) { - if (this.inner().aaaaRecords() == null) { - this.inner().withAaaaRecords(new ArrayList()); + for (AaaaRecord recordToAdd : this.inner().aaaaRecords()) { + resource.aaaaRecords().add(recordToAdd); + } } - this.inner().aaaaRecords().add(new AaaaRecord().withIpv6Address(ipv6Address)); - return this; - } - @Override - public AaaaRecordSetImpl withoutIpv6Address(String ipv6Address) { - if (this.inner().aaaaRecords() != null) { - for (AaaaRecord record : this.inner().aaaaRecords()) { - if (record.ipv6Address().equalsIgnoreCase(ipv6Address)) { - this.inner().aaaaRecords().remove(record); - break; + if (recordSetRemoveInfo.aaaaRecords().size() > 0) { + if (resource.aaaaRecords() != null) { + for (AaaaRecord recordToRemove : recordSetRemoveInfo.aaaaRecords()) { + for (AaaaRecord record : resource.aaaaRecords()) { + if (record.ipv6Address().equalsIgnoreCase(recordToRemove.ipv6Address())) { + resource.aaaaRecords().remove(record); + break; + } + } } } } - return this; - } - - @Override - protected Func1 innerToFluentMap() { - return super.innerToFluentMap(this); + return resource; } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java index 6e541711536ee..36c93e295848a 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java @@ -1,18 +1,13 @@ package com.microsoft.azure.management.dns.implementation; -import com.microsoft.azure.management.dns.CnameRecord; import com.microsoft.azure.management.dns.CnameRecordSet; -import rx.functions.Func1; /** * Implementation of {@link CnameRecordSet}. */ class CnameRecordSetImpl - extends DnsRecordSetImpl - implements - CnameRecordSet, - CnameRecordSet.Definition, - CnameRecordSet.Update { + extends DnsRecordSetImpl + implements CnameRecordSet { CnameRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -26,19 +21,7 @@ public String canonicalName() { } @Override - public CnameRecordSetImpl refresh() { - this.refreshInner(); - return this; - } - - @Override - public CnameRecordSetImpl withCanonicalName(String canonicalName) { - this.inner().withCnameRecord(new CnameRecord().withCname(canonicalName)); - return this; - } - - @Override - protected Func1 innerToFluentMap() { - return super.innerToFluentMap(this); + protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + return resource; } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index e524eb8c2505f..a0f6732682ae0 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -1,34 +1,55 @@ package com.microsoft.azure.management.dns.implementation; +import com.microsoft.azure.management.dns.ARecord; +import com.microsoft.azure.management.dns.AaaaRecord; +import com.microsoft.azure.management.dns.CnameRecord; import com.microsoft.azure.management.dns.DnsRecordSet; import com.microsoft.azure.management.dns.DnsZone; +import com.microsoft.azure.management.dns.MxRecord; +import com.microsoft.azure.management.dns.NsRecord; +import com.microsoft.azure.management.dns.PtrRecord; import com.microsoft.azure.management.dns.RecordType; -import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl; +import com.microsoft.azure.management.dns.SrvRecord; +import com.microsoft.azure.management.dns.TxtRecord; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; import rx.Observable; import rx.functions.Func1; -import java.util.Collections; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; /** * Implementation of {@link DnsRecordSet}. - * - * @param The record set fluent model type - * @param the implementation type of the fluent model type */ -abstract class DnsRecordSetImpl> - extends CreatableUpdatableImpl - implements DnsRecordSet { - protected final DnsZoneImpl dnsZone; +abstract class DnsRecordSetImpl extends ExternalChildResourceImpl + implements DnsRecordSet, + DnsRecordSet.Definition, + DnsRecordSet.UpdateDefinition, + DnsRecordSet.UpdateCombined { protected final RecordSetsInner client; + private RecordSetInner recordSetRemoveInfo; - protected DnsRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(innerModel.name(), innerModel); - this.dnsZone = parentDnsZone; + protected DnsRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(innerModel.name(), parent, innerModel); this.client = client; + this.recordSetRemoveInfo = new RecordSetInner() + .withName(innerModel.name()) + .withType(innerModel.type()) + .withARecords(new ArrayList()) + .withAaaaRecords(new ArrayList()) + .withCnameRecord(new CnameRecord()) + .withMxRecords(new ArrayList()) + .withNsRecords(new ArrayList()) + .withPtrRecords(new ArrayList()) + .withSrvRecords(new ArrayList()) + .withTxtRecords(new ArrayList()) + .withMetadata(new LinkedHashMap()); } @Override @@ -46,60 +67,231 @@ public long timeToLive() { return this.inner().tTL(); } + // Setters + + @Override + public DnsRecordSetImpl withIpv4Address(String ipv4Address) { + if (this.inner().aRecords() == null) { + this.inner().withARecords(new ArrayList()); + } + this.inner() + .aRecords() + .add(new ARecord().withIpv4Address(ipv4Address)); + return this; + } + + @Override + public DnsRecordSetImpl withoutIpv4Address(String ipv4Address) { + this.recordSetRemoveInfo + .aRecords() + .add(new ARecord().withIpv4Address(ipv4Address)); + return this; + } + + @Override + public DnsRecordSetImpl withIpv6Address(String ipv6Address) { + if (this.inner().aaaaRecords() == null) { + this.inner().withAaaaRecords(new ArrayList()); + } + this.inner() + .aaaaRecords() + .add(new AaaaRecord().withIpv6Address(ipv6Address)); + return this; + } + + @Override + public DnsRecordSetImpl withoutIpv6Address(String ipv6Address) { + this.recordSetRemoveInfo + .aaaaRecords() + .add(new AaaaRecord().withIpv6Address(ipv6Address)); + return this; + } + + @Override + public DnsRecordSetImpl withMailExchange(String mailExchangeHostName, int priority) { + if (this.inner().mxRecords() == null) { + this.inner().withMxRecords(new ArrayList()); + } + this.inner() + .mxRecords() + .add(new MxRecord().withExchange(mailExchangeHostName).withPreference(priority)); + return this; + } + + @Override + public DnsRecordSetImpl withoutMailExchange(String mailExchangeHostName, int priority) { + this.recordSetRemoveInfo + .mxRecords() + .add(new MxRecord().withExchange(mailExchangeHostName).withPreference(priority)); + return this; + } + + @Override + public DnsRecordSetImpl withNameServer(String nameServerHostName) { + if (this.inner().nsRecords() == null) { + this.inner().withNsRecords(new ArrayList()); + } + this.inner() + .nsRecords() + .add(new NsRecord().withNsdname(nameServerHostName)); + return this; + } + + @Override + public DnsRecordSetImpl withoutNameServer(String nameServerHostName) { + this.recordSetRemoveInfo + .nsRecords() + .add(new NsRecord().withNsdname(nameServerHostName)); + return this; + } + + @Override + public DnsRecordSetImpl withTargetDomainName(String targetDomainName) { + if (this.inner().ptrRecords() == null) { + this.inner().withPtrRecords(new ArrayList()); + } + this.inner() + .ptrRecords() + .add(new PtrRecord().withPtrdname(targetDomainName)); + return this; + } + @Override - public DnsZoneImpl parent() { - return this.dnsZone; + public DnsRecordSetImpl withoutTargetDomainName(String targetDomainName) { + this.recordSetRemoveInfo + .ptrRecords() + .add(new PtrRecord().withPtrdname(targetDomainName)); + return this; } @Override - public Map tags() { - if (this.inner().metadata() == null) { - return Collections.unmodifiableMap(new LinkedHashMap()); + public DnsRecordSetImpl withRecord(String target, int port, int priority, int weight) { + if (this.inner().srvRecords() == null) { + this.inner().withSrvRecords(new ArrayList()); } - return Collections.unmodifiableMap(this.inner().metadata()); + this.inner().srvRecords().add(new SrvRecord() + .withTarget(target) + .withPort(port) + .withPriority(priority) + .withWeight(weight)); + return this; } - public final FluentModelImplT withTags(Map tags) { + @Override + public DnsRecordSetImpl withoutRecord(String target, int port, int priority, int weight) { + this.recordSetRemoveInfo. + srvRecords().add(new SrvRecord() + .withTarget(target) + .withPort(port) + .withPriority(priority) + .withWeight(weight)); + return this; + } + + @Override + public DnsRecordSetImpl withText(String text) { + if (this.inner().txtRecords() == null) { + this.inner().withTxtRecords(new ArrayList()); + } + List value = new ArrayList<>(); + value.add(text); + this.inner().txtRecords().add(new TxtRecord().withValue(value)); + return this; + } + + @Override + public DnsRecordSetImpl withoutText(String text) { + List value = new ArrayList<>(); + value.add(text); + this.recordSetRemoveInfo + .txtRecords().add(new TxtRecord().withValue(value)); + return this; + } + + @Override + public DnsRecordSetImpl withTimeToLive(long ttlInSeconds) { + this.inner().withTTL(ttlInSeconds); + return this; + } + + @Override + public DnsRecordSetImpl withTags(Map tags) { this.inner().withMetadata(new HashMap<>(tags)); - return (FluentModelImplT) this; + return this; } - public final FluentModelImplT withTag(String key, String value) { + @Override + public DnsRecordSetImpl withTag(String key, String value) { this.inner().metadata().put(key, value); - return (FluentModelImplT) this; + return this; } - public final FluentModelImplT withoutTag(String key) { - this.inner().metadata().remove(key); - return (FluentModelImplT) this; + @Override + public DnsRecordSetImpl withoutTag(String key) { + this.recordSetRemoveInfo + .metadata().put(key, null); + return this; } - public FluentModelImplT withTimeToLive(long ttlInSeconds) { - this.inner().withTTL(ttlInSeconds); - return (FluentModelImplT) this; + // + + @Override + public Observable createAsync() { + return createOrUpdateAsync(this.inner()); } @Override - public boolean isInCreateMode() { - return this.inner().id() == null; + public Observable updateAsync() { + return this.client.getAsync(this.parent().resourceGroupName(), + this.parent().name(), this.name(), this.recordType()) + .map(new Func1() { + public RecordSetInner call(RecordSetInner resource) { + return merge(resource, recordSetRemoveInfo); + } + }).flatMap(new Func1>() { + @Override + public Observable call(RecordSetInner resource) { + return createOrUpdateAsync(resource); + } + }); } @Override - public Observable createResourceAsync() { - return client.createOrUpdateAsync(this.parent().resourceGroupName(), - this.parent().name(), - this.name(), - this.recordType(), - this.inner()) - .map(innerToFluentMap()); + public Observable deleteAsync() { + return this.client.deleteAsync(this.parent().resourceGroupName(), + this.parent().name(), this.name(), this.recordType()); + } + + @Override + public DnsZoneImpl attach() { + // TODO add record + return this.parent(); } - protected void refreshInner() { + @Override + public DnsRecordSetImpl refresh() { this.setInner(this.client.get(this.parent().resourceGroupName(), this.parent().name(), this.name(), this.recordType())); + return this; + } + + private Observable createOrUpdateAsync(RecordSetInner resource) { + final DnsRecordSetImpl self = this; + return this.client.createOrUpdateAsync(this.parent().resourceGroupName(), + this.parent().name(), + this.name(), + this.recordType(), + resource) + .map(new Func1() { + @Override + public DnsRecordSet call(RecordSetInner inner) { + self.setInner(inner); + return self; + } + }); } - protected abstract Func1 innerToFluentMap(); + protected abstract RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java index bc064a2fdc725..9a793a38a78ec 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java @@ -113,6 +113,123 @@ public SoaRecordSet getSoaRecordSet() { return new SoaRecordSetImpl(this, inner, this.recordSetsClient); } + // Setters + + @Override + public ARecordSetImpl defineARecordSet(String name) { + return null; + } + + @Override + public AaaaRecordSetImpl defineAaaaRecordSet(String name) { + return null; + } + + @Override + public DnsZoneImpl withCnameRecordSet(String name, String alias) { + return null; + } + + @Override + public MxRecordSetImpl defineMxRecordSet(String name) { + return null; + } + + @Override + public NsRecordSetImpl defineNsRecordSet(String name) { + return null; + } + + @Override + public PtrRecordSetImpl definePtrRecordSet(String name) { + return null; + } + + @Override + public SrvRecordSetImpl defineSrvRecordSet(String name) { + return null; + } + + @Override + public TxtRecordSetImpl defineTxtRecordSet(String name) { + return null; + } + + @Override + public ARecordSetImpl updateARecordSet(String name) { + return null; + } + + @Override + public AaaaRecordSetImpl updateAaaaRecordSet(String name) { + return null; + } + + @Override + public MxRecordSetImpl updateMxRecordSet(String name) { + return null; + } + + @Override + public NsRecordSetImpl updateNsRecordSet(String name) { + return null; + } + + @Override + public PtrRecordSetImpl updatePtrRecordSet(String name) { + return null; + } + + @Override + public SrvRecordSetImpl updateSrvRecordSet(String name) { + return null; + } + + @Override + public TxtRecordSetImpl updateTxtRecordSet(String name) { + return null; + } + + @Override + public DnsZoneImpl withoutARecordSet(String name) { + return null; + } + + @Override + public DnsZoneImpl withoutAaaaRecordSet(String name) { + return null; + } + + @Override + public DnsZoneImpl withoutCnameRecordSet(String name) { + return null; + } + + @Override + public DnsZoneImpl withoutMxRecordSet(String name) { + return null; + } + + @Override + public DnsZoneImpl withoutNsRecordSet(String name) { + return null; + } + + @Override + public DnsZoneImpl withoutPtrRecordSet(String name) { + return null; + } + + @Override + public DnsZoneImpl withoutSrvRecordSet(String name) { + return null; + } + + @Override + public DnsZoneImpl withoutTxtRecordSet(String name) { + return null; + } + @Override public Observable createResourceAsync() { return this.innerCollection.createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner()) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java index 57f812ace71e7..c2114e7290b14 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -2,7 +2,6 @@ import com.microsoft.azure.management.dns.MxRecord; import com.microsoft.azure.management.dns.MxRecordSet; -import rx.functions.Func1; import java.util.ArrayList; import java.util.Collections; @@ -12,11 +11,8 @@ * Implementation of {@link MxRecordSet}. */ class MxRecordSetImpl - extends DnsRecordSetImpl - implements - MxRecordSet, - MxRecordSet.Definition, - MxRecordSet.Update { + extends DnsRecordSetImpl + implements MxRecordSet { MxRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -30,36 +26,30 @@ public List records() { } @Override - public MxRecordSetImpl refresh() { - this.refreshInner(); - return this; - } + protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + if (this.inner().mxRecords() != null && this.inner().mxRecords().size() > 0) { + if (resource.mxRecords() == null) { + resource.withMxRecords(new ArrayList()); + } - @Override - public MxRecordSetImpl withMailExchange(String mailExchangeHostName, int priority) { - if (this.inner().mxRecords() == null) { - this.inner().withMxRecords(new ArrayList()); + for (MxRecord recordToAdd : this.inner().mxRecords()) { + resource.mxRecords().add(recordToAdd); + } } - this.inner().mxRecords().add(new MxRecord().withExchange(mailExchangeHostName).withPreference(priority)); - return this; - } - @Override - public MxRecordSetImpl withoutMailExchange(String mailExchangeHostName, int priority) { - if (this.inner().mxRecords() != null) { - for (MxRecord record : this.inner().mxRecords()) { - if (record.exchange().equalsIgnoreCase(mailExchangeHostName) && record.preference() == priority) { - this.inner().mxRecords().remove(record); - break; + if (recordSetRemoveInfo.mxRecords().size() > 0) { + if (resource.mxRecords() != null) { + for (MxRecord recordToRemove : recordSetRemoveInfo.mxRecords()) { + for (MxRecord record : resource.mxRecords()) { + if (record.exchange().equalsIgnoreCase(recordToRemove.exchange()) && record.preference() == recordToRemove.preference()) { + resource.mxRecords().remove(record); + break; + } + } } } } - return this; - } - - @Override - protected Func1 innerToFluentMap() { - return super.innerToFluentMap(this); + return resource; } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java index 913b9845c8c86..1693d5623ae70 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java @@ -2,7 +2,6 @@ import com.microsoft.azure.management.dns.NsRecord; import com.microsoft.azure.management.dns.NsRecordSet; -import rx.functions.Func1; import java.util.ArrayList; import java.util.Collections; @@ -12,11 +11,8 @@ * Implementation of {@link NsRecordSet}. */ class NsRecordSetImpl - extends DnsRecordSetImpl - implements - NsRecordSet, - NsRecordSet.Definition, - NsRecordSet.Update { + extends DnsRecordSetImpl + implements NsRecordSet { NsRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -33,36 +29,30 @@ public List nameServers() { } @Override - public NsRecordSetImpl refresh() { - this.refreshInner(); - return this; - } + protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + if (this.inner().nsRecords() != null && this.inner().nsRecords().size() > 0) { + if (resource.nsRecords() == null) { + resource.withNsRecords(new ArrayList()); + } - @Override - public NsRecordSetImpl withNameServer(String nameServerHostName) { - if (this.inner().nsRecords() == null) { - this.inner().withNsRecords(new ArrayList()); + for (NsRecord recordToAdd : this.inner().nsRecords()) { + resource.nsRecords().add(recordToAdd); + } } - this.inner().nsRecords().add(new NsRecord().withNsdname(nameServerHostName)); - return this; - } - @Override - public NsRecordSetImpl withoutNameServer(String nameServerHostName) { - if (this.inner().nsRecords() != null) { - for (NsRecord record : this.inner().nsRecords()) { - if (record.nsdname().equalsIgnoreCase(nameServerHostName)) { - this.inner().nsRecords().remove(record); - break; + if (recordSetRemoveInfo.nsRecords().size() > 0) { + if (resource.nsRecords() != null) { + for (NsRecord recordToRemove : recordSetRemoveInfo.nsRecords()) { + for (NsRecord record : resource.nsRecords()) { + if (record.nsdname().equalsIgnoreCase(recordToRemove.nsdname())) { + resource.nsRecords().remove(record); + break; + } + } } } } - return this; - } - - @Override - protected Func1 innerToFluentMap() { - return super.innerToFluentMap(this); + return resource; } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java index a9f991bbc63f7..e4dc3efdf453b 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java @@ -2,7 +2,6 @@ import com.microsoft.azure.management.dns.PtrRecord; import com.microsoft.azure.management.dns.PtrRecordSet; -import rx.functions.Func1; import java.util.ArrayList; import java.util.Collections; @@ -12,11 +11,8 @@ * Implementation of {@link PtrRecordSet}. */ class PtrRecordSetImpl - extends DnsRecordSetImpl - implements - PtrRecordSet, - PtrRecordSet.Definition, - PtrRecordSet.Update { + extends DnsRecordSetImpl + implements PtrRecordSet { PtrRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -33,36 +29,30 @@ public List targetDomainNames() { } @Override - public PtrRecordSetImpl refresh() { - this.refreshInner(); - return this; - } + protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + if (this.inner().ptrRecords() != null && this.inner().ptrRecords().size() > 0) { + if (resource.ptrRecords() == null) { + resource.withPtrRecords(new ArrayList()); + } - @Override - public PtrRecordSetImpl withTargetDomain(String targetDomainName) { - if (this.inner().ptrRecords() == null) { - this.inner().withPtrRecords(new ArrayList()); + for (PtrRecord recordToAdd : this.inner().ptrRecords()) { + resource.ptrRecords().add(recordToAdd); + } } - this.inner().ptrRecords().add(new PtrRecord().withPtrdname(targetDomainName)); - return this; - } - @Override - public PtrRecordSetImpl withoutTargetDomain(String targetDomainName) { - if (this.inner().nsRecords() != null) { - for (PtrRecord record : this.inner().ptrRecords()) { - if (record.ptrdname().equalsIgnoreCase(targetDomainName)) { - this.inner().ptrRecords().remove(record); - break; + if (recordSetRemoveInfo.ptrRecords().size() > 0) { + if (resource.ptrRecords() != null) { + for (PtrRecord recordToRemove : recordSetRemoveInfo.ptrRecords()) { + for (PtrRecord record : resource.ptrRecords()) { + if (record.ptrdname().equalsIgnoreCase(recordToRemove.ptrdname())) { + resource.ptrRecords().remove(record); + break; + } + } } } } - return this; - } - - @Override - protected Func1 innerToFluentMap() { - return super.innerToFluentMap(this); + return resource; } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java index f4bf6bc0f7eb6..b08fe630071b1 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java @@ -2,7 +2,6 @@ import com.microsoft.azure.management.dns.SrvRecord; import com.microsoft.azure.management.dns.SrvRecordSet; -import rx.functions.Func1; import java.util.ArrayList; import java.util.Collections; @@ -12,11 +11,8 @@ * Implementation of {@link SrvRecordSet}. */ class SrvRecordSetImpl - extends DnsRecordSetImpl - implements - SrvRecordSet, - SrvRecordSet.Definition, - SrvRecordSet.Update { + extends DnsRecordSetImpl + implements SrvRecordSet { SrvRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -30,42 +26,32 @@ public List records() { } @Override - public SrvRecordSetImpl refresh() { - this.refreshInner(); - return this; - } + protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + if (this.inner().srvRecords() != null && this.inner().srvRecords().size() > 0) { + if (resource.srvRecords() == null) { + resource.withSrvRecords(new ArrayList()); + } - @Override - public SrvRecordSetImpl withRecord(String target, int port, int priority, int weight) { - if (this.inner().srvRecords() == null) { - this.inner().withSrvRecords(new ArrayList()); + for (SrvRecord recordToAdd : this.inner().srvRecords()) { + resource.srvRecords().add(recordToAdd); + } } - this.inner().srvRecords().add(new SrvRecord() - .withTarget(target) - .withPort(port) - .withPriority(priority) - .withWeight(weight)); - return this; - } - @Override - public SrvRecordSetImpl withoutRecord(String target, int port, int priority, int weight) { - if (this.inner().srvRecords() != null) { - for (SrvRecord record : this.inner().srvRecords()) { - if (record.target().equalsIgnoreCase(target) && - record.port() == port && - record.priority() == priority && - record.weight() == weight) { - this.inner().srvRecords().remove(record); - break; + if (recordSetRemoveInfo.srvRecords().size() > 0) { + if (resource.srvRecords() != null) { + for (SrvRecord recordToRemove : recordSetRemoveInfo.srvRecords()) { + for (SrvRecord record : resource.srvRecords()) { + if (record.target().equalsIgnoreCase(recordToRemove.target()) + && record.port() == recordToRemove.port() + && record.weight() == recordToRemove.weight() + && record.priority() == recordToRemove.priority()) { + resource.srvRecords().remove(record); + break; + } + } } } } - return this; - } - - @Override - protected Func1 innerToFluentMap() { - return super.innerToFluentMap(this); + return resource; } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java index f12d54ab4291b..65a06051526d7 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java @@ -2,7 +2,6 @@ import com.microsoft.azure.management.dns.TxtRecord; import com.microsoft.azure.management.dns.TxtRecordSet; -import rx.functions.Func1; import java.util.ArrayList; import java.util.Collections; @@ -12,11 +11,8 @@ * Implementation of {@link TxtRecordSet}. */ class TxtRecordSetImpl - extends DnsRecordSetImpl - implements - TxtRecordSet, - TxtRecordSet.Definition, - TxtRecordSet.Update { + extends DnsRecordSetImpl + implements TxtRecordSet { TxtRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -30,40 +26,30 @@ public List records() { } @Override - public TxtRecordSetImpl refresh() { - this.refreshInner(); - return this; - } + protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + if (this.inner().txtRecords() != null && this.inner().txtRecords().size() > 0) { + if (resource.txtRecords() == null) { + resource.withTxtRecords(new ArrayList()); + } - @Override - public TxtRecordSetImpl withText(String text) { - if (this.inner().txtRecords() == null) { - this.inner().withTxtRecords(new ArrayList()); + for (TxtRecord recordToAdd : this.inner().txtRecords()) { + resource.txtRecords().add(recordToAdd); + } } - List value = new ArrayList<>(); - value.add(text); - this.inner().txtRecords().add(new TxtRecord().withValue(value)); - return this; - } - @Override - public TxtRecordSetImpl withoutText(String text) { - if (this.inner().txtRecords() != null) { - for (TxtRecord record : this.inner().txtRecords()) { - if (record.value() != null && record.value().size() != 0) { - if (record.value().get(0).equalsIgnoreCase(text)) { - this.inner().txtRecords().remove(record); - break; + if (recordSetRemoveInfo.txtRecords().size() > 0) { + if (resource.txtRecords() != null) { + for (TxtRecord recordToRemove : recordSetRemoveInfo.txtRecords()) { + for (TxtRecord record : resource.txtRecords()) { + if (record.value().size() != 0 && record.value().get(0).equalsIgnoreCase(recordToRemove.value().get(0))) { + resource.txtRecords().remove(record); + break; + } } } } } - return this; - } - - @Override - protected Func1 innerToFluentMap() { - return super.innerToFluentMap(this); + return resource; } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java index 1c6cf5b10a55c..d158c44f6227c 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java @@ -10,8 +10,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.model.Indexable; -import java.util.Map; - /** * Base interfaces for fluent resources. */ @@ -20,7 +18,7 @@ public interface Resource extends Indexable, HasId, HasName, - HasTags { + Taggable { /** * @return the type of the resource @@ -65,7 +63,7 @@ interface DefinitionWithRegion { * @param the type of the next stage resource definition */ @LangDefinition(ContainerName = "Resource.Definition", ContainerFileName = "IDefinition") - interface DefinitionWithTags extends HasTags.DefinitionWithTags { + interface DefinitionWithTags extends Taggable.DefinitionWithTags { } /** @@ -74,6 +72,6 @@ interface DefinitionWithTags extends HasTags.DefinitionWithTags { * @param the type of the next stage resource update */ @LangDefinition(ContainerName = "Resource.Update", ContainerFileName = "IUpdate") - interface UpdateWithTags extends HasTags.UpdateWithTags { + interface UpdateWithTags extends Taggable.UpdateWithTags { } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/HasTags.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Taggable.java similarity index 98% rename from azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/HasTags.java rename to azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Taggable.java index 52ee19953ed35..0085f4f1688ca 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/HasTags.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Taggable.java @@ -8,7 +8,7 @@ * An interface representing a resource that has tags. */ @Fluent -public interface HasTags { +public interface Taggable { /** * @return the tags associated with the resource */ From bacce7cf5c17ca42a83aaebd10c783e932eb22f8 Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 3 Nov 2016 17:26:32 -0700 Subject: [PATCH 12/27] Clear collections after add or remove during update --- .../azure/management/dns/implementation/ARecordSetImpl.java | 2 ++ .../azure/management/dns/implementation/AaaaRecordSetImpl.java | 2 ++ .../azure/management/dns/implementation/DnsRecordSetImpl.java | 2 +- .../azure/management/dns/implementation/MxRecordSetImpl.java | 2 ++ .../azure/management/dns/implementation/NsRecordSetImpl.java | 2 ++ .../azure/management/dns/implementation/PtrRecordSetImpl.java | 2 ++ .../azure/management/dns/implementation/SrvRecordSetImpl.java | 2 ++ .../azure/management/dns/implementation/TxtRecordSetImpl.java | 2 ++ 8 files changed, 15 insertions(+), 1 deletion(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java index fc54e27030768..6f277f85f4b3a 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java @@ -38,6 +38,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet for (ARecord recordToAdd : this.inner().aRecords()) { resource.aRecords().add(recordToAdd); } + this.inner().aRecords().clear(); } if (recordSetRemoveInfo.aRecords().size() > 0) { @@ -51,6 +52,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } + recordSetRemoveInfo.aRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java index 92ccd10a0d218..068e120cd1f1d 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java @@ -39,6 +39,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet for (AaaaRecord recordToAdd : this.inner().aaaaRecords()) { resource.aaaaRecords().add(recordToAdd); } + this.inner().aaaaRecords().clear(); } if (recordSetRemoveInfo.aaaaRecords().size() > 0) { @@ -52,6 +53,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } + recordSetRemoveInfo.aaaaRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index a0f6732682ae0..9418527501c22 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -287,7 +287,7 @@ private Observable createOrUpdateAsync(RecordSetInner resource) { .map(new Func1() { @Override public DnsRecordSet call(RecordSetInner inner) { - self.setInner(inner); + setInner(inner); return self; } }); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java index c2114e7290b14..2dc5e9d1b474a 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -35,6 +35,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet for (MxRecord recordToAdd : this.inner().mxRecords()) { resource.mxRecords().add(recordToAdd); } + this.inner().mxRecords().clear(); } if (recordSetRemoveInfo.mxRecords().size() > 0) { @@ -48,6 +49,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } + recordSetRemoveInfo.mxRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java index 1693d5623ae70..836f683eb1c20 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java @@ -38,6 +38,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet for (NsRecord recordToAdd : this.inner().nsRecords()) { resource.nsRecords().add(recordToAdd); } + this.inner().nsRecords().clear(); } if (recordSetRemoveInfo.nsRecords().size() > 0) { @@ -51,6 +52,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } + recordSetRemoveInfo.nsRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java index e4dc3efdf453b..9ac3b27bb0733 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java @@ -38,6 +38,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet for (PtrRecord recordToAdd : this.inner().ptrRecords()) { resource.ptrRecords().add(recordToAdd); } + this.inner().ptrRecords().clear(); } if (recordSetRemoveInfo.ptrRecords().size() > 0) { @@ -51,6 +52,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } + recordSetRemoveInfo.ptrRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java index b08fe630071b1..8f6e6d55cf25b 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java @@ -35,6 +35,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet for (SrvRecord recordToAdd : this.inner().srvRecords()) { resource.srvRecords().add(recordToAdd); } + this.inner().srvRecords().clear(); } if (recordSetRemoveInfo.srvRecords().size() > 0) { @@ -51,6 +52,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } + recordSetRemoveInfo.srvRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java index 65a06051526d7..772914f97a423 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java @@ -35,6 +35,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet for (TxtRecord recordToAdd : this.inner().txtRecords()) { resource.txtRecords().add(recordToAdd); } + this.inner().txtRecords().clear(); } if (recordSetRemoveInfo.txtRecords().size() > 0) { @@ -48,6 +49,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } + recordSetRemoveInfo.txtRecords().clear(); } return resource; } From 321a2c81d6a23d1204e75ece7efd06c7b61e2e58 Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 3 Nov 2016 17:35:21 -0700 Subject: [PATCH 13/27] Removing def and update interfaces from record set interfaces as they are now part of DnsRecordSet interface --- .../azure/management/dns/ARecordSet.java | 114 +--------------- .../azure/management/dns/AaaaRecordSet.java | 114 ---------------- .../azure/management/dns/CnameRecordSet.java | 93 +------------ .../azure/management/dns/MxRecordSet.java | 119 +---------------- .../azure/management/dns/NsRecordSet.java | 116 +--------------- .../azure/management/dns/PtrRecordSet.java | 116 +--------------- .../azure/management/dns/SoaRecordSet.java | 2 +- .../azure/management/dns/SrvRecordSet.java | 125 +----------------- .../azure/management/dns/TxtRecordSet.java | 116 +--------------- .../dns/implementation/SoaRecordSetImpl.java | 25 +++- 10 files changed, 29 insertions(+), 911 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java index 717bb695f4cd0..acbf36f7ce168 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/ARecordSet.java @@ -1,125 +1,13 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; - import java.util.List; /** * An immutable client-side representation of a A (Ipv4) record set in Azure Dns Zone. */ -public interface ARecordSet extends DnsRecordSet { +public interface ARecordSet extends DnsRecordSet { /** * @return the Ipv4 addresses of A records in this record set */ List ipv4Addresses(); - - /** - * The entirety of the A record set definition. - */ - interface Definition extends - DefinitionStages.Blank, - DefinitionStages.WithCreate { - } - - /** - * Grouping of A record set definition stages. - */ - interface DefinitionStages { - /** - * The first stage of an A record set definition. - */ - interface Blank extends WithIpv4Address { - } - - /** - * The stage of the A record set definition allowing to add a record. - */ - interface WithIpv4Address { - /** - * Creates an A record with the provided Ipv4 address in this record set. - * - * @param ipv4Address the Ipv4 address - * @return the next stage of the record set definition - */ - WithCreate withIpv4Address(String ipv4Address); - } - - /** - * The stage of the record set definition allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set definition - */ - WithCreate withTimeToLive(long ttlInSeconds); - } - - /** - * The stage of the definition which contains all the minimum required inputs for - * the resource to be created (via {@link WithCreate#create()}), but also allows - * for any other optional settings to be specified. - */ - interface WithCreate extends - Creatable, - Taggable.DefinitionWithTags, - DefinitionStages.WithTtl { - } - } - - /** - * Grouping of A record set update stages. - */ - interface UpdateStages { - /** - * The stage of the Aaaa record set update allowing to add or remove a record. - */ - interface WithIpv4Address { - /** - * Creates an A record with the provided Ipv4 address in this record set. - * - * @param ipv4Address the Ipv4 address - * @return the next stage of the record set update - */ - Update withIpv4Address(String ipv4Address); - - /** - * Removes an A record with the provided Ipv4 address from this record set. - * - * @param ipv4Address the Ipv4 address - * @return the next stage of the record set update - */ - Update withoutIpv4Address(String ipv4Address); - } - - /** - * The stage of the record set update allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set update - */ - Update withTimeToLive(long ttlInSeconds); - } - } - - /** - * The template for an update operation, containing all the settings that - * can be modified. - *

- * Call {@link Update#apply()} to apply the changes to the resource in Azure. - */ - interface Update extends - Appliable, - Taggable.UpdateWithTags, - UpdateStages.WithIpv4Address, - UpdateStages.WithTtl { - } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java index 744c461141c57..0cc7281166078 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/AaaaRecordSet.java @@ -1,9 +1,5 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; - import java.util.List; /** @@ -14,114 +10,4 @@ public interface AaaaRecordSet extends DnsRecordSet { * @return the IPv6 addresses of Aaaa records in this record set */ List ipv6Addresses(); - - /** - * The entirety of the Aaaa record set definition. - */ - interface Definition extends - DefinitionStages.Blank, - DefinitionStages.WithIpv6Address, - DefinitionStages.WithCreate { - } - - /** - * Grouping of Aaaa record set definition stages. - */ - interface DefinitionStages { - /** - * The first stage of a Aaaa record set definition. - */ - interface Blank extends WithIpv6Address { - } - - /** - * The stage of the Aaaa record set definition allowing to add a record. - */ - interface WithIpv6Address { - /** - * Creates an Aaaa record with the provided Ipv6 address in this record set. - * - * @param ipv6Address the Ipv6 address - * @return the next stage of the record set definition - */ - WithCreate withIpv6Address(String ipv6Address); - } - - /** - * The stage of the record set definition allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set definition - */ - WithCreate withTimeToLive(long ttlInSeconds); - } - - /** - * The stage of the definition which contains all the minimum required inputs for - * the resource to be created (via {@link WithCreate#create()}), but also allows - * for any other optional settings to be specified. - */ - interface WithCreate extends - Creatable, - Taggable.DefinitionWithTags, - DefinitionStages.WithIpv6Address, - DefinitionStages.WithTtl { - } - } - - /** - * Grouping of Aaaa record set update stages. - */ - interface UpdateStages { - /** - * The stage of the Aaaa record set update allowing to add or remove a record. - */ - interface WithIpv6Address { - /** - * Creates an Aaaa record with the provided Ipv6 address in this record set. - * - * @param ipv6Address the Ipv6 address - * @return the next stage of the record set update - */ - Update withIpv6Address(String ipv6Address); - - /** - * Removes an Aaaa record with the provided Ipv6 address from this record set. - * - * @param ipv6Address the Ipv6 address - * @return the next stage of the record set update - */ - Update withoutIpv6Address(String ipv6Address); - } - - /** - * The stage of the record set update allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set update - */ - Update withTimeToLive(long ttlInSeconds); - } - } - - /** - * The template for an update operation, containing all the settings that - * can be modified. - *

- * Call {@link Update#apply()} to apply the changes to the resource in Azure. - */ - interface Update extends - Appliable, - Taggable.UpdateWithTags, - UpdateStages.WithIpv6Address, - UpdateStages.WithTtl { - } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java index e06f00d8c9d55..952b1b9c2b9b3 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/CnameRecordSet.java @@ -1,102 +1,11 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; - /** * An immutable client-side representation of a CName (canonical name) record set in Azure Dns Zone. */ -public interface CnameRecordSet extends DnsRecordSet { +public interface CnameRecordSet extends DnsRecordSet { /** * @return the canonical name (without a terminating dot) of CName record in this record set */ String canonicalName(); - - /** - * The entirety of the CName record set definition. - */ - interface Definition extends - DefinitionStages.Blank, - DefinitionStages.WithCanonicalName, - DefinitionStages.WithCreate { - } - - /** - * Grouping of CName record set definition stages. - */ - interface DefinitionStages { - /** - * The first stage of a CName record set definition. - */ - interface Blank extends WithCanonicalName { - } - - /** - * The stage of the CName record set definition allowing to add a record. - */ - interface WithCanonicalName { - /** - * Creates a CName record with the provided canonical name in this record set. - * - * @param canonicalName the canonical name - * @return the next stage of the record set definition - */ - WithCreate withCanonicalName(String canonicalName); - } - - /** - * The stage of the record set definition allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set definition - */ - WithCreate withTimeToLive(long ttlInSeconds); - } - - /** - * The stage of the definition which contains all the minimum required inputs for - * the resource to be created (via {@link WithCreate#create()}), but also allows - * for any other optional settings to be specified. - */ - interface WithCreate extends - Creatable, - Taggable.DefinitionWithTags, - DefinitionStages.WithTtl { - } - } - - /** - * Grouping of CName record set update stages. - */ - interface UpdateStages { - /** - * The stage of the record set update allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set update - */ - Update withTimeToLive(long ttlInSeconds); - } - } - - /** - * The template for an update operation, containing all the settings that - * can be modified. - *

- * Call {@link Update#apply()} to apply the changes to the resource in Azure. - */ - interface Update extends - Appliable, - Taggable.UpdateWithTags, - UpdateStages.WithTtl { - } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java index bc5c7554b2d12..bf8cc8df96e1b 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/MxRecordSet.java @@ -1,130 +1,13 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; - import java.util.List; /** * An immutable client-side representation of a Mx (mail exchange) record set in Azure Dns Zone. */ -public interface MxRecordSet extends DnsRecordSet { +public interface MxRecordSet extends DnsRecordSet { /** * @return the Mx records in this record set */ List records(); - - /** - * The entirety of the CName record set definition. - */ - interface Definition extends - DefinitionStages.Blank, - DefinitionStages.WithMailExchange, - DefinitionStages.WithCreate { - } - - /** - * Grouping of Mx record set definition stages. - */ - interface DefinitionStages { - /** - * The first stage of a Mx record set definition. - */ - interface Blank extends WithMailExchange { - } - - /** - * The stage of the Mx record set definition allowing to add a record. - */ - interface WithMailExchange { - /** - * Creates and assigns priority to a Mx record with the provided mail exchange server in this record set. - * - * @param mailExchangeHostName the host name of the mail exchange server - * @param priority the priority for the mail exchange host, lower the value higher the priority - * @return the next stage of the record set definition - */ - WithCreate withMailExchange(String mailExchangeHostName, int priority); - } - - /** - * The stage of the record set definition allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set definition - */ - WithCreate withTimeToLive(long ttlInSeconds); - } - - /** - * The stage of the definition which contains all the minimum required inputs for - * the resource to be created (via {@link WithCreate#create()}), but also allows - * for any other optional settings to be specified. - */ - interface WithCreate extends - Creatable, - Taggable.DefinitionWithTags, - DefinitionStages.WithMailExchange, - DefinitionStages.WithTtl { - } - } - - /** - * Grouping of Mx record set update stages. - */ - interface UpdateStages { - /** - * The stage of the Mx record set definition allowing to add or remove a record. - */ - interface WithMailExchange { - /** - * Creates and assigns priority to a Mx record with the provided mail exchange server in this record set. - * - * @param mailExchangeHostName the host name of the mail exchange server - * @param priority the priority for the mail exchange host, lower the value higher the priority - * @return the next stage of the record set update - */ - Update withMailExchange(String mailExchangeHostName, int priority); - - /** - * Removes a Mx record with the provided priority and mail exchange server from this record set. - * - * @param mailExchangeHostName the host name of the mail exchange server - * @param priority the priority for the mail exchange host - * @return the next stage of the record set update - */ - Update withoutMailExchange(String mailExchangeHostName, int priority); - } - - /** - * The stage of the record set update allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set update - */ - Update withTimeToLive(long ttlInSeconds); - } - } - - /** - * The template for an update operation, containing all the settings that - * can be modified. - *

- * Call {@link Update#apply()} to apply the changes to the resource in Azure. - */ - interface Update extends - Appliable, - Taggable.UpdateWithTags, - UpdateStages.WithMailExchange, - UpdateStages.WithTtl { - } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java index 6e56cbdfaf11a..49003cde7742f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java @@ -1,124 +1,10 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; - import java.util.List; -public interface NsRecordSet extends DnsRecordSet { +public interface NsRecordSet extends DnsRecordSet { /** * @return the name server names of Ns (name server) records in this record set */ List nameServers(); - - /** - * The entirety of the Ns record set definition. - */ - interface Definition extends - DefinitionStages.Blank, - DefinitionStages.WithNameServer, - DefinitionStages.WithCreate { - } - - /** - * Grouping of Ns record set definition stages. - */ - interface DefinitionStages { - /** - * The first stage of a Ns record set definition. - */ - interface Blank extends WithNameServer { - } - - /** - * The stage of the Ns record set definition allowing to add a record. - */ - interface WithNameServer { - /** - * Creates a Ns record with the provided name server in this record set. - * - * @param nameServerHostName the name server host name - * @return the next stage of the record set definition - */ - WithCreate withNameServer(String nameServerHostName); - } - - /** - * The stage of the record set definition allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set definition - */ - WithCreate withTimeToLive(long ttlInSeconds); - } - - /** - * The stage of the definition which contains all the minimum required inputs for - * the resource to be created (via {@link WithCreate#create()}), but also allows - * for any other optional settings to be specified. - */ - interface WithCreate extends - Creatable, - Taggable.DefinitionWithTags, - DefinitionStages.WithNameServer, - DefinitionStages.WithTtl { - } - } - - /** - * Grouping of Ns record set update stages. - */ - interface UpdateStages { - /** - * The stage of the Ns record set definition allowing to add or remove a record. - */ - interface WithNameServer { - /** - * Creates a Ns record with the provided name server in this record set. - * - * @param nameServerHostName the name server host name - * @return the next stage of the record set definition - */ - Update withNameServer(String nameServerHostName); - - /** - * Removes a Ns record with the provided name server from this record set. - * - * @param nameServerHostName the name server host name - * @return the next stage of the record set definition - */ - Update withoutNameServer(String nameServerHostName); - } - - /** - * The stage of the record set update allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set update - */ - Update withTimeToLive(long ttlInSeconds); - } - } - - /** - * The template for an update operation, containing all the settings that - * can be modified. - *

- * Call {@link Update#apply()} to apply the changes to the resource in Azure. - */ - interface Update extends - Appliable, - Taggable.UpdateWithTags, - UpdateStages.WithNameServer, - UpdateStages.WithTtl { - } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java index 0b5990dbbbc22..7e3536d9d4bed 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/PtrRecordSet.java @@ -1,127 +1,13 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; - import java.util.List; /** * An immutable client-side representation of a Ptr (pointer) record set in Azure Dns Zone. */ -public interface PtrRecordSet extends DnsRecordSet { +public interface PtrRecordSet extends DnsRecordSet { /** * @return the target domain names of Ptr records in this record set */ List targetDomainNames(); - - /** - * The entirety of the Ns record set definition. - */ - interface Definition extends - DefinitionStages.Blank, - DefinitionStages.WithTargetDomain, - DefinitionStages.WithCreate { - } - - /** - * Grouping of Ptr record set definition stages. - */ - interface DefinitionStages { - /** - * The first stage of a Ptr record set definition. - */ - interface Blank extends WithTargetDomain { - } - - /** - * The stage of the Ptr record set definition allowing to add a record. - */ - interface WithTargetDomain { - /** - * Creates a Ptr record with the provided target domain in this record set. - * - * @param targetDomainName the name of the target domain - * @return the next stage of the record set definition - */ - WithCreate withTargetDomain(String targetDomainName); - } - - /** - * The stage of the record set definition allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set definition - */ - WithCreate withTimeToLive(long ttlInSeconds); - } - - /** - * The stage of the definition which contains all the minimum required inputs for - * the resource to be created (via {@link WithCreate#create()}), but also allows - * for any other optional settings to be specified. - */ - interface WithCreate extends - Creatable, - Taggable.DefinitionWithTags, - DefinitionStages.WithTargetDomain, - DefinitionStages.WithTtl { - } - } - - /** - * Grouping of Ptr record set update stages. - */ - interface UpdateStages { - /** - * The stage of the Ptr record set definition allowing to add or remove a record. - */ - interface WithTargetDomain { - /** - * Creates a Ptr record with the provided target domain in this record set. - * - * @param targetDomainName the name of the target domain - * @return the next stage of the record set update - */ - Update withTargetDomain(String targetDomainName); - - /** - * Removes a Ptr record with the provided target domain from this record set. - * - * @param targetDomainName the name of the target domain - * @return the next stage of the record set update - */ - Update withoutTargetDomain(String targetDomainName); - } - - /** - * The stage of the record set update allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set update - */ - Update withTimeToLive(long ttlInSeconds); - } - } - - /** - * The template for an update operation, containing all the settings that - * can be modified. - *

- * Call {@link Update#apply()} to apply the changes to the resource in Azure. - */ - interface Update extends - Appliable, - Taggable.UpdateWithTags, - UpdateStages.WithTargetDomain, - UpdateStages.WithTtl { - } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java index da192e8569903..b331d1c7788ce 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java @@ -6,7 +6,7 @@ /** * An immutable client-side representation of a Soa (start of authority) record set in Azure Dns Zone. */ -public interface SoaRecordSet extends DnsRecordSet { +public interface SoaRecordSet extends DnsRecordSet { /** * @return the Soa record in this record set */ diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java index c95b8c47f4767..1688ffcf22272 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SrvRecordSet.java @@ -1,136 +1,13 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; - import java.util.List; /** * An immutable client-side representation of a Srv (service) record set in Azure Dns Zone. */ -public interface SrvRecordSet extends DnsRecordSet { +public interface SrvRecordSet extends DnsRecordSet { /** * @return the Srv records in this record set */ List records(); - - /** - * The entirety of the Srv record set definition. - */ - interface Definition extends - DefinitionStages.Blank, - DefinitionStages.WithRecord, - DefinitionStages.WithCreate { - } - - /** - * Grouping of Srv record set definition stages. - */ - interface DefinitionStages { - /** - * The first stage of a Srv record set definition. - */ - interface Blank extends WithRecord { - } - - /** - * The stage of the srv record set definition allowing to add a Srv record. - */ - interface WithRecord { - /** - * Specifies a service record for a service. - * - * @param target the canonical name of the target host running the service - * @param port the port on which the service is bounded - * @param priority the priority of the target host, lower the value higher the priority - * @param weight the relative weight (preference) of the records with the same priority, higher the value more the preference - * @return the next stage of the record set definition - */ - WithCreate withRecord(String target, int port, int priority, int weight); - } - - /** - * The stage of the record set definition allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set definition - */ - WithCreate withTimeToLive(long ttlInSeconds); - } - - /** - * The stage of the definition which contains all the minimum required inputs for - * the resource to be created (via {@link WithCreate#create()}), but also allows - * for any other optional settings to be specified. - */ - interface WithCreate extends - Creatable, - Taggable.DefinitionWithTags, - DefinitionStages.WithRecord, - DefinitionStages.WithTtl { - } - } - - /** - * Grouping of Srv record set update stages. - */ - interface UpdateStages { - /** - * The stage of the srv record set update allowing to add or remove a Srv record. - */ - interface WithRecord { - /** - * Specifies a service record for a service. - * - * @param target the canonical name of the target host running the service - * @param port the port on which the service is bounded - * @param priority the priority of the target host, lower the value higher the priority - * @param weight the relative weight (preference) of the records with the same priority, higher the value more the preference - * @return the next stage of the record set update - */ - Update withRecord(String target, int port, int priority, int weight); - - /** - * Removes a service record. - * - * @param target the canonical name of the target host running the service - * @param port the port on which the service is bounded - * @param priority the priority of the record - * @param weight the weight of the record - * @return the next stage of the record set update - */ - Update withoutRecord(String target, int port, int priority, int weight); - } - - /** - * The stage of the record set update allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set update - */ - Update withTimeToLive(long ttlInSeconds); - } - } - - /** - * The template for an update operation, containing all the settings that - * can be modified. - *

- * Call {@link Update#apply()} to apply the changes to the resource in Azure. - */ - interface Update extends - Appliable, - Taggable.UpdateWithTags, - UpdateStages.WithRecord, - UpdateStages.WithTtl { - } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java index 8edf6e046222b..aa7281a7efa5f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/TxtRecordSet.java @@ -1,127 +1,13 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; -import com.microsoft.azure.management.resources.fluentcore.model.Creatable; - import java.util.List; /** * An immutable client-side representation of a Txt (text) record set in Azure Dns Zone. */ -public interface TxtRecordSet extends DnsRecordSet { +public interface TxtRecordSet extends DnsRecordSet { /** * @return the Txt records in this record set */ List records(); - - /** - * The entirety of the Txt record set definition. - */ - interface Definition extends - DefinitionStages.Blank, - DefinitionStages.WithText, - DefinitionStages.WithCreate { - } - - /** - * Grouping of Txt record set definition stages. - */ - interface DefinitionStages { - /** - * The first stage of a Txt record set definition. - */ - interface Blank extends WithText { - } - - /** - * The stage of the Txt record set definition allowing to add a record. - */ - interface WithText { - /** - * Creates a Txt record with the given text in this record set. - * - * @param text the text value - * @return the next stage of the record set definition - */ - WithCreate withText(String text); - } - - /** - * The stage of the record set definition allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set definition - */ - WithCreate withTimeToLive(long ttlInSeconds); - } - - /** - * The stage of the definition which contains all the minimum required inputs for - * the resource to be created (via {@link WithCreate#create()}), but also allows - * for any other optional settings to be specified. - */ - interface WithCreate extends - Creatable, - Taggable.DefinitionWithTags, - DefinitionStages.WithText, - DefinitionStages.WithTtl { - } - } - - /** - * Grouping of Txt record set update stages. - */ - interface UpdateStages { - /** - * The stage of the Txt record set definition allowing to add or remove a record. - */ - interface WithText { - /** - * Creates a Txt record with the given text in this record set. - * - * @param text the text value - * @return the next stage of the record set update - */ - Update withText(String text); - - /** - * Removes Txt record with the given text from this record set. - * - * @param text the text value - * @return the next stage of the record set update - */ - Update withoutText(String text); - } - - /** - * The stage of the record set update allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set update - */ - Update withTimeToLive(long ttlInSeconds); - } - } - - /** - * The template for an update operation, containing all the settings that - * can be modified. - *

- * Call {@link Update#apply()} to apply the changes to the resource in Azure. - */ - interface Update extends - Appliable, - Taggable.UpdateWithTags, - UpdateStages.WithText, - UpdateStages.WithTtl { - } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java index ab199a42af155..75260fa31b375 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java @@ -2,13 +2,16 @@ import com.microsoft.azure.management.dns.SoaRecord; import com.microsoft.azure.management.dns.SoaRecordSet; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import rx.Observable; import rx.functions.Func1; /** * Implementation of {@link SoaRecordSet}. */ class SoaRecordSetImpl - extends DnsRecordSetImpl + extends DnsRecordSetImpl implements SoaRecordSet, SoaRecordSet.Update { @@ -23,10 +26,14 @@ public SoaRecord record() { @Override public SoaRecordSetImpl refresh() { - this.refreshInner(); return this; } + @Override + protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + return null; + } + @Override public SoaRecordSetImpl withEmailServer(String emailServerHostName) { this.inner().soaRecord().withEmail(emailServerHostName); @@ -64,7 +71,17 @@ public SoaRecordSetImpl withSerialNumber(long serialNumber) { } @Override - protected Func1 innerToFluentMap() { - return super.innerToFluentMap(this); + public SoaRecordSet apply() { + return null; + } + + @Override + public Observable applyAsync() { + return null; + } + + @Override + public ServiceCall applyAsync(ServiceCallback callback) { + return null; } } From c996db6c9a3cb288b0fc8b735feec753990509f6 Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 3 Nov 2016 17:42:29 -0700 Subject: [PATCH 14/27] cleaning up SoaRecordSetImpl --- .../dns/implementation/SoaRecordSetImpl.java | 81 ++++++------------- 1 file changed, 24 insertions(+), 57 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java index 75260fa31b375..b0fd89bb12cf7 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java @@ -2,19 +2,13 @@ import com.microsoft.azure.management.dns.SoaRecord; import com.microsoft.azure.management.dns.SoaRecordSet; -import com.microsoft.rest.ServiceCall; -import com.microsoft.rest.ServiceCallback; -import rx.Observable; -import rx.functions.Func1; /** * Implementation of {@link SoaRecordSet}. */ class SoaRecordSetImpl extends DnsRecordSetImpl - implements - SoaRecordSet, - SoaRecordSet.Update { + implements SoaRecordSet { SoaRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { super(parentDnsZone, innerModel, client); } @@ -24,64 +18,37 @@ public SoaRecord record() { return this.inner().soaRecord(); } - @Override - public SoaRecordSetImpl refresh() { - return this; - } - @Override protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { - return null; - } + if (resource.soaRecord() == null) { + resource.withSoaRecord(new SoaRecord()); + } - @Override - public SoaRecordSetImpl withEmailServer(String emailServerHostName) { - this.inner().soaRecord().withEmail(emailServerHostName); - return this; - } + if (this.inner().soaRecord().email() != null) { + resource.soaRecord().withEmail(this.inner().soaRecord().email()); + } - @Override - public SoaRecordSetImpl withExpireTimeInSeconds(long expireTimeInSeconds) { - this.inner().soaRecord().withExpireTime(expireTimeInSeconds); - return this; - } + if (this.inner().soaRecord().expireTime() != null) { + resource.soaRecord().withExpireTime(this.inner().soaRecord().expireTime()); + } - @Override - public SoaRecordSetImpl withNegativeResponseCachingTimeToLiveInSeconds(long negativeCachingTimeToLive) { - this.inner().soaRecord().withMinimumTtl(negativeCachingTimeToLive); - return this; - } + if (this.inner().soaRecord().minimumTtl() != null) { + resource.soaRecord().withMinimumTtl(this.inner().soaRecord().minimumTtl()); + } - @Override - public SoaRecordSetImpl withRefreshTimeInSeconds(long refreshTimeInSeconds) { - this.inner().soaRecord().withRefreshTime(refreshTimeInSeconds); - return this; - } + if (this.inner().soaRecord().refreshTime() != null) { + resource.soaRecord().withRefreshTime(this.inner().soaRecord().refreshTime()); + } - @Override - public SoaRecordSetImpl withRetryTimeInSeconds(long refreshTimeInSeconds) { - this.inner().soaRecord().withRetryTime(refreshTimeInSeconds); - return this; - } + if (this.inner().soaRecord().retryTime() != null) { + resource.soaRecord().withRefreshTime(this.inner().soaRecord().retryTime()); + } - @Override - public SoaRecordSetImpl withSerialNumber(long serialNumber) { - this.inner().soaRecord().withSerialNumber(serialNumber); - return this; - } + if (this.inner().soaRecord().serialNumber() != null) { + resource.soaRecord().withSerialNumber(this.inner().soaRecord().serialNumber()); + } - @Override - public SoaRecordSet apply() { - return null; - } - - @Override - public Observable applyAsync() { - return null; - } - - @Override - public ServiceCall applyAsync(ServiceCallback callback) { - return null; + this.inner().withSoaRecord(new SoaRecord()); + return resource; } } From 8611d9b40fe8f3594ed022fca0ffb4fdcf82dd91 Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 3 Nov 2016 18:43:30 -0700 Subject: [PATCH 15/27] renaming merge -> prepareUpdate, expose Soa attribute setters --- .../azure/management/dns/DnsRecordSet.java | 65 ++++++++++ .../azure/management/dns/DnsZone.java | 7 + .../azure/management/dns/SoaRecordSet.java | 120 ------------------ .../dns/implementation/ARecordSetImpl.java | 8 +- .../dns/implementation/AaaaRecordSetImpl.java | 8 +- .../implementation/CnameRecordSetImpl.java | 2 +- .../dns/implementation/DnsRecordSetImpl.java | 63 ++++++++- .../dns/implementation/DnsZoneImpl.java | 5 + .../dns/implementation/MxRecordSetImpl.java | 8 +- .../dns/implementation/NsRecordSetImpl.java | 8 +- .../dns/implementation/PtrRecordSetImpl.java | 8 +- .../dns/implementation/SoaRecordSetImpl.java | 2 +- .../dns/implementation/SrvRecordSetImpl.java | 8 +- .../dns/implementation/TxtRecordSetImpl.java | 8 +- 14 files changed, 167 insertions(+), 153 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index d47209d2e2c46..84a075976e790 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -675,6 +675,7 @@ interface UpdateCombined extends UpdateNsRecordSet, UpdateSrvRecordSet, UpdateTxtRecordSet, + UpdateSoaRecord, Update { } @@ -734,6 +735,14 @@ interface UpdateTxtRecordSet extends Update { } + /** + * The entirety of a Soa record update as a part of parent Dns zone update. + */ + interface UpdateSoaRecord extends + UpdateStages.WithSoaRecordAttributes, + Update { + } + /** * the set of configurations that can be updated for Dns record set irrespective of their type {@link RecordType}. */ @@ -902,6 +911,62 @@ interface WithTxtRecordTextValue { UpdateTxtRecordSet withoutText(String text); } + /** + * The stage of the Soa record definition allowing to update its attributes. + */ + interface WithSoaRecordAttributes { + /** + * Specifies the email server associated with the Soa record. + * + * @param emailServerHostName the email server + * @return the next stage of the record set update + */ + UpdateSoaRecord withEmailServer(String emailServerHostName); + + /** + * Specifies time in seconds that a secondary name server should wait before trying to contact the + * the primary name server for a zone file update. + * + * @param refreshTimeInSeconds the refresh time in seconds + * @return the next stage of the record set update + */ + UpdateSoaRecord withRefreshTimeInSeconds(long refreshTimeInSeconds); + + /** + * Specifies the time in seconds that a secondary name server should wait before trying to contact + * the primary name server again after a failed attempt to check for a zone file update. + * + * @param refreshTimeInSeconds the retry time in seconds + * @return the next stage of the record set update + */ + UpdateSoaRecord withRetryTimeInSeconds(long refreshTimeInSeconds); + + /** + * Specifies the time in seconds that a secondary name server will treat its cached zone file as valid + * when the primary name server cannot be contacted. + * + * @param expireTimeInSeconds the expire time in seconds + * @return the next stage of the record set update + */ + UpdateSoaRecord withExpireTimeInSeconds(long expireTimeInSeconds); + + /** + * Specifies the time in seconds that any name server or resolver should cache a negative response. + * + * @param negativeCachingTimeToLive the Ttl for cached negative response + * @return the next stage of the record set update + */ + UpdateSoaRecord withNegativeResponseCachingTimeToLiveInSeconds(long negativeCachingTimeToLive); + + /** + * Specifies the serial number for the zone file. + * + * @param serialNumber the serial number + * @return the next stage of the record set update + */ + UpdateSoaRecord withSerialNumber(long serialNumber); + } + /** * The stage of the record set update allowing to specify Ttl for the records in this record set. */ diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java index 0fe240855586e..4a04cd9cb1227 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsZone.java @@ -309,6 +309,13 @@ interface WithRecordSet { */ DnsRecordSet.UpdateTxtRecordSet updateTxtRecordSet(String name); + /** + * Begins the description of an update of the Soa record in this Dns zone. + * + * @return the stage representing configuration for the Txt record set + */ + DnsRecordSet.UpdateSoaRecord updateSoaRecord(); + /** * Removes a A record set in the Dns zone. * diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java index b331d1c7788ce..2abfd6731766f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/SoaRecordSet.java @@ -1,8 +1,5 @@ package com.microsoft.azure.management.dns; -import com.microsoft.azure.management.resources.fluentcore.arm.models.Taggable; -import com.microsoft.azure.management.resources.fluentcore.model.Appliable; - /** * An immutable client-side representation of a Soa (start of authority) record set in Azure Dns Zone. */ @@ -11,121 +8,4 @@ public interface SoaRecordSet extends DnsRecordSet { * @return the Soa record in this record set */ SoaRecord record(); - - /** - * Grouping of Soa record set update stages. - */ - interface UpdateStages { - /** - * The stage of the Soa record set definition allowing specify the email server. - */ - interface WithEmailServer { - /** - * Specifies the email server associated with the Soa record. - * - * @param emailServerHostName the email server - * @return the next stage of the record set update - */ - Update withEmailServer(String emailServerHostName); - } - - /** - * The stage of the Soa record set definition allowing to specify the refresh time. - */ - interface WithRefreshTime { - /** - * Specifies time in seconds that a secondary name server should wait before trying to contact the - * the primary name server for a zone file update. - * - * @param refreshTimeInSeconds the refresh time in seconds - * @return the next stage of the record set update - */ - Update withRefreshTimeInSeconds(long refreshTimeInSeconds); - } - - /** - * The stage of the Soa record set definition allowing to specify the retry time. - */ - interface WithRetryTime { - /** - * Specifies the time in seconds that a secondary name server should wait before trying to contact - * the primary name server again after a failed attempt to check for a zone file update. - * - * @param refreshTimeInSeconds the retry time in seconds - * @return the next stage of the record set update - */ - Update withRetryTimeInSeconds(long refreshTimeInSeconds); - } - - /** - * The stage of the Soa record set definition allowing to specify the expire time. - */ - interface WithExpireTime { - /** - * Specifies the time in seconds that a secondary name server will treat its cached zone file as valid - * when the primary name server cannot be contacted. - * - * @param expireTimeInSeconds the expire time in seconds - * @return the next stage of the record set update - */ - Update withExpireTimeInSeconds(long expireTimeInSeconds); - } - - /** - * The stage of the Soa record set definition allowing to specify the Ttl for cached negative response. - */ - interface WithNegativeCachingTtl { - /** - * Specifies the time in seconds that any name server or resolver should cache a negative response. - * - * @param negativeCachingTimeToLive the Ttl for cached negative response - * @return the next stage of the record set update - */ - Update withNegativeResponseCachingTimeToLiveInSeconds(long negativeCachingTimeToLive); - } - - /** - * The stage of the Soa record set definition allowing to specify the serial number. - */ - interface WithSerialNumber { - /** - * Specifies the serial number for the zone file. - * - * @param serialNumber the serial number - * @return the next stage of the record set update - */ - Update withSerialNumber(long serialNumber); - } - - /** - * The stage of the record set update allowing to specify Ttl for the records in this record set. - */ - interface WithTtl { - /** - * Specifies the Ttl for the records in the record set. - * - * @param ttlInSeconds ttl in seconds - * @return the next stage of the record set update - */ - Update withTimeToLive(long ttlInSeconds); - } - } - - /** - * The template for an update operation, containing all the settings that - * can be modified. - *

- * Call {@link Update#apply()} to apply the changes to the resource in Azure. - */ - interface Update extends - Appliable, - Taggable.UpdateWithTags, - UpdateStages.WithEmailServer, - UpdateStages.WithRefreshTime, - UpdateStages.WithRetryTime, - UpdateStages.WithExpireTime, - UpdateStages.WithNegativeCachingTtl, - UpdateStages.WithSerialNumber, - UpdateStages.WithTtl { - } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java index 6f277f85f4b3a..34be8b966d008 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java @@ -29,7 +29,7 @@ public List ipv4Addresses() { } @Override - protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (this.inner().aRecords() != null && this.inner().aRecords().size() > 0) { if (resource.aRecords() == null) { resource.withARecords(new ArrayList()); @@ -41,9 +41,9 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet this.inner().aRecords().clear(); } - if (recordSetRemoveInfo.aRecords().size() > 0) { + if (this.recordSetRemoveInfo.aRecords().size() > 0) { if (resource.aRecords() != null) { - for (ARecord recordToRemove : recordSetRemoveInfo.aRecords()) { + for (ARecord recordToRemove : this.recordSetRemoveInfo.aRecords()) { for (ARecord record : resource.aRecords()) { if (record.ipv4Address().equalsIgnoreCase(recordToRemove.ipv4Address())) { resource.aRecords().remove(record); @@ -52,7 +52,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } - recordSetRemoveInfo.aRecords().clear(); + this.recordSetRemoveInfo.aRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java index 068e120cd1f1d..ab22ebc2f12e7 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java @@ -30,7 +30,7 @@ public List ipv6Addresses() { } @Override - protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (this.inner().aaaaRecords() != null && this.inner().aaaaRecords().size() > 0) { if (resource.aaaaRecords() == null) { resource.withAaaaRecords(new ArrayList()); @@ -42,9 +42,9 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet this.inner().aaaaRecords().clear(); } - if (recordSetRemoveInfo.aaaaRecords().size() > 0) { + if (this.recordSetRemoveInfo.aaaaRecords().size() > 0) { if (resource.aaaaRecords() != null) { - for (AaaaRecord recordToRemove : recordSetRemoveInfo.aaaaRecords()) { + for (AaaaRecord recordToRemove : this.recordSetRemoveInfo.aaaaRecords()) { for (AaaaRecord record : resource.aaaaRecords()) { if (record.ipv6Address().equalsIgnoreCase(recordToRemove.ipv6Address())) { resource.aaaaRecords().remove(record); @@ -53,7 +53,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } - recordSetRemoveInfo.aaaaRecords().clear(); + this.recordSetRemoveInfo.aaaaRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java index 36c93e295848a..12deaa6369e95 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java @@ -21,7 +21,7 @@ public String canonicalName() { } @Override - protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + protected RecordSetInner prepareForUpdate(RecordSetInner resource) { return resource; } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index 9418527501c22..bcda5be7ee9b6 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -33,7 +33,7 @@ abstract class DnsRecordSetImpl extends ExternalChildResourceImpl, DnsRecordSet.UpdateCombined { protected final RecordSetsInner client; - private RecordSetInner recordSetRemoveInfo; + protected final RecordSetInner recordSetRemoveInfo; protected DnsRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { super(innerModel.name(), parent, innerModel); @@ -208,6 +208,42 @@ public DnsRecordSetImpl withoutText(String text) { return this; } + @Override + public DnsRecordSetImpl withEmailServer(String emailServerHostName) { + this.inner().soaRecord().withEmail(emailServerHostName); + return this; + } + + @Override + public DnsRecordSetImpl withRefreshTimeInSeconds(long refreshTimeInSeconds) { + this.inner().soaRecord().withRefreshTime(refreshTimeInSeconds); + return this; + } + + @Override + public DnsRecordSetImpl withRetryTimeInSeconds(long retryTimeInSeconds) { + this.inner().soaRecord().withRetryTime(retryTimeInSeconds); + return this; + } + + @Override + public DnsRecordSetImpl withExpireTimeInSeconds(long expireTimeInSeconds) { + this.inner().soaRecord().withExpireTime(expireTimeInSeconds); + return this; + } + + @Override + public DnsRecordSetImpl withNegativeResponseCachingTimeToLiveInSeconds(long negativeCachingTimeToLive) { + this.inner().soaRecord().withMinimumTtl(negativeCachingTimeToLive); + return this; + } + + @Override + public DnsRecordSetImpl withSerialNumber(long serialNumber) { + this.inner().soaRecord().withSerialNumber(serialNumber); + return this; + } + @Override public DnsRecordSetImpl withTimeToLive(long ttlInSeconds) { this.inner().withTTL(ttlInSeconds); @@ -246,7 +282,7 @@ public Observable updateAsync() { this.parent().name(), this.name(), this.recordType()) .map(new Func1() { public RecordSetInner call(RecordSetInner resource) { - return merge(resource, recordSetRemoveInfo); + return prepare(resource); } }).flatMap(new Func1>() { @Override @@ -293,5 +329,26 @@ public DnsRecordSet call(RecordSetInner inner) { }); } - protected abstract RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo); + private RecordSetInner prepare(RecordSetInner resource) { + if (this.recordSetRemoveInfo.metadata().size() > 0) { + if (resource.metadata() != null) { + for(String key : this.recordSetRemoveInfo.metadata().keySet()) { + resource.metadata().remove(key); + } + } + this.recordSetRemoveInfo.metadata().clear(); + } + if (this.inner().metadata().size() > 0) { + if (resource.metadata() == null) { + resource.withMetadata(new LinkedHashMap()); + } + for(Map.Entry keyVal : this.inner().metadata().entrySet()) { + resource.metadata().put(keyVal.getKey(), keyVal.getValue()); + } + this.inner().metadata().clear(); + } + return prepareForUpdate(resource); + } + + protected abstract RecordSetInner prepareForUpdate(RecordSetInner resource); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java index 9a793a38a78ec..2ad2f4ed63037 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java @@ -190,6 +190,11 @@ public TxtRecordSetImpl updateTxtRecordSet(String name) { return null; } + @Override + public SoaRecordSetImpl updateSoaRecord() { + return null; + } + @Override public DnsZoneImpl withoutARecordSet(String name) { return null; diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java index 2dc5e9d1b474a..5167a5c79e5ac 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -26,7 +26,7 @@ public List records() { } @Override - protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (this.inner().mxRecords() != null && this.inner().mxRecords().size() > 0) { if (resource.mxRecords() == null) { resource.withMxRecords(new ArrayList()); @@ -38,9 +38,9 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet this.inner().mxRecords().clear(); } - if (recordSetRemoveInfo.mxRecords().size() > 0) { + if (this.recordSetRemoveInfo.mxRecords().size() > 0) { if (resource.mxRecords() != null) { - for (MxRecord recordToRemove : recordSetRemoveInfo.mxRecords()) { + for (MxRecord recordToRemove : this.recordSetRemoveInfo.mxRecords()) { for (MxRecord record : resource.mxRecords()) { if (record.exchange().equalsIgnoreCase(recordToRemove.exchange()) && record.preference() == recordToRemove.preference()) { resource.mxRecords().remove(record); @@ -49,7 +49,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } - recordSetRemoveInfo.mxRecords().clear(); + this.recordSetRemoveInfo.mxRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java index 836f683eb1c20..8e90c1e34f143 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java @@ -29,7 +29,7 @@ public List nameServers() { } @Override - protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (this.inner().nsRecords() != null && this.inner().nsRecords().size() > 0) { if (resource.nsRecords() == null) { resource.withNsRecords(new ArrayList()); @@ -41,9 +41,9 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet this.inner().nsRecords().clear(); } - if (recordSetRemoveInfo.nsRecords().size() > 0) { + if (this.recordSetRemoveInfo.nsRecords().size() > 0) { if (resource.nsRecords() != null) { - for (NsRecord recordToRemove : recordSetRemoveInfo.nsRecords()) { + for (NsRecord recordToRemove : this.recordSetRemoveInfo.nsRecords()) { for (NsRecord record : resource.nsRecords()) { if (record.nsdname().equalsIgnoreCase(recordToRemove.nsdname())) { resource.nsRecords().remove(record); @@ -52,7 +52,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } - recordSetRemoveInfo.nsRecords().clear(); + this.recordSetRemoveInfo.nsRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java index 9ac3b27bb0733..ac779e305e0e6 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java @@ -29,7 +29,7 @@ public List targetDomainNames() { } @Override - protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (this.inner().ptrRecords() != null && this.inner().ptrRecords().size() > 0) { if (resource.ptrRecords() == null) { resource.withPtrRecords(new ArrayList()); @@ -41,9 +41,9 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet this.inner().ptrRecords().clear(); } - if (recordSetRemoveInfo.ptrRecords().size() > 0) { + if (this.recordSetRemoveInfo.ptrRecords().size() > 0) { if (resource.ptrRecords() != null) { - for (PtrRecord recordToRemove : recordSetRemoveInfo.ptrRecords()) { + for (PtrRecord recordToRemove : this.recordSetRemoveInfo.ptrRecords()) { for (PtrRecord record : resource.ptrRecords()) { if (record.ptrdname().equalsIgnoreCase(recordToRemove.ptrdname())) { resource.ptrRecords().remove(record); @@ -52,7 +52,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } - recordSetRemoveInfo.ptrRecords().clear(); + this.recordSetRemoveInfo.ptrRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java index b0fd89bb12cf7..59cfc951bb1ec 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java @@ -19,7 +19,7 @@ public SoaRecord record() { } @Override - protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (resource.soaRecord() == null) { resource.withSoaRecord(new SoaRecord()); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java index 8f6e6d55cf25b..0befd95fb0a71 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java @@ -26,7 +26,7 @@ public List records() { } @Override - protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (this.inner().srvRecords() != null && this.inner().srvRecords().size() > 0) { if (resource.srvRecords() == null) { resource.withSrvRecords(new ArrayList()); @@ -38,9 +38,9 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet this.inner().srvRecords().clear(); } - if (recordSetRemoveInfo.srvRecords().size() > 0) { + if (this.recordSetRemoveInfo.srvRecords().size() > 0) { if (resource.srvRecords() != null) { - for (SrvRecord recordToRemove : recordSetRemoveInfo.srvRecords()) { + for (SrvRecord recordToRemove : this.recordSetRemoveInfo.srvRecords()) { for (SrvRecord record : resource.srvRecords()) { if (record.target().equalsIgnoreCase(recordToRemove.target()) && record.port() == recordToRemove.port() @@ -52,7 +52,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } - recordSetRemoveInfo.srvRecords().clear(); + this.recordSetRemoveInfo.srvRecords().clear(); } return resource; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java index 772914f97a423..b30a82c4bbb2e 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java @@ -26,7 +26,7 @@ public List records() { } @Override - protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSetRemoveInfo) { + protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (this.inner().txtRecords() != null && this.inner().txtRecords().size() > 0) { if (resource.txtRecords() == null) { resource.withTxtRecords(new ArrayList()); @@ -38,9 +38,9 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet this.inner().txtRecords().clear(); } - if (recordSetRemoveInfo.txtRecords().size() > 0) { + if (this.recordSetRemoveInfo.txtRecords().size() > 0) { if (resource.txtRecords() != null) { - for (TxtRecord recordToRemove : recordSetRemoveInfo.txtRecords()) { + for (TxtRecord recordToRemove : this.recordSetRemoveInfo.txtRecords()) { for (TxtRecord record : resource.txtRecords()) { if (record.value().size() != 0 && record.value().get(0).equalsIgnoreCase(recordToRemove.value().get(0))) { resource.txtRecords().remove(record); @@ -49,7 +49,7 @@ protected RecordSetInner merge(RecordSetInner resource, RecordSetInner recordSet } } } - recordSetRemoveInfo.txtRecords().clear(); + this.recordSetRemoveInfo.txtRecords().clear(); } return resource; } From 048fc07cff85ae8b8d3ca5b1db58f5d0d4264634 Mon Sep 17 00:00:00 2001 From: anuchan Date: Fri, 4 Nov 2016 17:17:45 -0700 Subject: [PATCH 16/27] Enable non-inline child resource CUD as part of parent CU --- .../dns/implementation/ARecordSetImpl.java | 10 + .../dns/implementation/AaaaRecordSetImpl.java | 10 + .../implementation/CnameRecordSetImpl.java | 11 + .../dns/implementation/DnsRecordSetsImpl.java | 126 ++++++++ .../dns/implementation/DnsZoneImpl.java | 89 +++--- .../dns/implementation/MxRecordSetImpl.java | 10 + .../dns/implementation/NsRecordSetImpl.java | 10 + .../dns/implementation/PtrRecordSetImpl.java | 10 + .../dns/implementation/SrvRecordSetImpl.java | 10 + .../dns/implementation/TxtRecordSetImpl.java | 11 + .../ExternalChildResourceCollectionImpl.java | 241 +++++++++++++++ .../ExternalChildResourcesImpl.java | 278 ++++-------------- .../ExternalNonInlineChildResourcesImpl.java | 82 ++++++ .../ExternalChildResourceImpl.java | 7 + .../TrafficManagerEndpointsImpl.java | 8 +- 15 files changed, 650 insertions(+), 263 deletions(-) create mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java create mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourceCollectionImpl.java create mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalNonInlineChildResourcesImpl.java diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java index 34be8b966d008..7936e8800efaf 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.dns.ARecord; import com.microsoft.azure.management.dns.ARecordSet; +import com.microsoft.azure.management.dns.RecordType; import java.util.ArrayList; import java.util.Collections; @@ -17,6 +18,15 @@ class ARecordSetImpl super(parentDnsZone, innerModel, client); } + static ARecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { + return new ARecordSetImpl(parentDnsZone, + new RecordSetInner() + .withName(name) + .withType(RecordType.A.toString()) + .withARecords(new ArrayList()), + client); + } + @Override public List ipv4Addresses() { List ipv6Addresses = new ArrayList<>(); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java index ab22ebc2f12e7..100e66513a276 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.dns.AaaaRecord; import com.microsoft.azure.management.dns.AaaaRecordSet; +import com.microsoft.azure.management.dns.RecordType; import java.util.ArrayList; import java.util.Collections; @@ -18,6 +19,15 @@ class AaaaRecordSetImpl super(parentDnsZone, innerModel, client); } + static AaaaRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { + return new AaaaRecordSetImpl(parentDnsZone, + new RecordSetInner() + .withName(name) + .withType(RecordType.AAAA.toString()) + .withAaaaRecords(new ArrayList()), + client); + } + @Override public List ipv6Addresses() { List ipv6Addresses = new ArrayList<>(); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java index 12deaa6369e95..1955dd73df523 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java @@ -1,6 +1,8 @@ package com.microsoft.azure.management.dns.implementation; +import com.microsoft.azure.management.dns.CnameRecord; import com.microsoft.azure.management.dns.CnameRecordSet; +import com.microsoft.azure.management.dns.RecordType; /** * Implementation of {@link CnameRecordSet}. @@ -12,6 +14,15 @@ class CnameRecordSetImpl super(parentDnsZone, innerModel, client); } + static CnameRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { + return new CnameRecordSetImpl(parentDnsZone, + new RecordSetInner() + .withName(name) + .withType(RecordType.CNAME.toString()) + .withCnameRecord(new CnameRecord()), + client); + } + @Override public String canonicalName() { if ( this.inner().cnameRecord() != null) { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java new file mode 100644 index 0000000000000..00d4fc0d4d034 --- /dev/null +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java @@ -0,0 +1,126 @@ +package com.microsoft.azure.management.dns.implementation; + +import com.microsoft.azure.management.dns.DnsRecordSet; +import com.microsoft.azure.management.dns.DnsZone; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalNonInlineChildResourcesImpl; + +/** + * Represents an record set collection associated with a Dns zone. + */ +class DnsRecordSetsImpl extends + ExternalNonInlineChildResourcesImpl { + private final RecordSetsInner client; + + /** + * Creates new DnsRecordSetsImpl. + * + * @param client the client to perform REST calls on record sets + * @param parent the parent Dns zone of the record set + */ + DnsRecordSetsImpl(RecordSetsInner client, DnsZoneImpl parent) { + super(parent, "RecordSet"); + this.client = client; + } + + DnsRecordSetImpl defineARecordSet(String name) { + return prepareDefine(ARecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl defineAaaaRecordSet(String name) { + return prepareDefine(AaaaRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + void withCnameRecordSet(String name, String alias) { + CnameRecordSetImpl recordSet = CnameRecordSetImpl.newRecordSet(name, this.parent(), this.client); + recordSet.inner().cnameRecord().withCname(alias); + prepareDefine(recordSet); + } + + DnsRecordSetImpl defineMxRecordSet(String name) { + return prepareDefine(MxRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl defineNsRecordSet(String name) { + return prepareDefine(NsRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl definePtrRecordSet(String name) { + return prepareDefine(PtrRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl defineSrvRecordSet(String name) { + return prepareDefine(SrvRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl defineTxtRecordSet(String name) { + return prepareDefine(TxtRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl updateARecordSet(String name) { + return prepareUpdate(ARecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl updateAaaaRecordSet(String name) { + return prepareUpdate(AaaaRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl updateMxRecordSet(String name) { + return prepareUpdate(MxRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl updateNsRecordSet(String name) { + return prepareUpdate(NsRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl updatePtrRecordSet(String name) { + return prepareUpdate(PtrRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl updateSrvRecordSet(String name) { + return prepareUpdate(SrvRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl updateTxtRecordSet(String name) { + return prepareUpdate(TxtRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + DnsRecordSetImpl updateSoaRecordSet() { + return prepareUpdate(TxtRecordSetImpl.newRecordSet("@", this.parent(), this.client)); + } + + void withoutARecordSet(String name) { + prepareRemove(ARecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + void withoutAaaaRecordSet(String name) { + prepareRemove(AaaaRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + void withoutCnameRecordSet(String name) { + prepareRemove(CnameRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + void withoutMxRecordSet(String name) { + prepareRemove(MxRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + void withoutNsRecordSet(String name) { + prepareRemove(NsRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + void withoutPtrRecordSet(String name) { + prepareRemove(PtrRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + void withoutSrvRecordSet(String name) { + prepareRemove(SrvRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } + + void withoutTxtRecordSet(String name) { + prepareRemove(TxtRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + } +} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java index 2ad2f4ed63037..a79a35a2f78a0 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java @@ -40,6 +40,7 @@ public class DnsZoneImpl private PtrRecordSets ptrRecordSets; private SrvRecordSets srvRecordSets; private TxtRecordSets txtRecordSets; + private DnsRecordSetsImpl recordSetsImpl; DnsZoneImpl(String name, final ZoneInner innerModel, @@ -49,6 +50,7 @@ public class DnsZoneImpl super(name, innerModel, trafficManager); this.innerCollection = innerCollection; this.recordSetsClient = recordSetsClient; + this.recordSetsImpl = new DnsRecordSetsImpl(recordSetsClient, this); initRecordSets(); } @@ -116,123 +118,132 @@ public SoaRecordSet getSoaRecordSet() { // Setters @Override - public ARecordSetImpl defineARecordSet(String name) { - return null; + public DnsRecordSetImpl defineARecordSet(String name) { + return recordSetsImpl.defineARecordSet(name); } @Override - public AaaaRecordSetImpl defineAaaaRecordSet(String name) { - return null; + public DnsRecordSetImpl defineAaaaRecordSet(String name) { + return recordSetsImpl.defineAaaaRecordSet(name); } @Override public DnsZoneImpl withCnameRecordSet(String name, String alias) { - return null; + recordSetsImpl.withCnameRecordSet(name, alias); + return this; } @Override - public MxRecordSetImpl defineMxRecordSet(String name) { - return null; + public DnsRecordSetImpl defineMxRecordSet(String name) { + return recordSetsImpl.defineMxRecordSet(name); } @Override - public NsRecordSetImpl defineNsRecordSet(String name) { - return null; + public DnsRecordSetImpl defineNsRecordSet(String name) { + return recordSetsImpl.defineNsRecordSet(name); } @Override - public PtrRecordSetImpl definePtrRecordSet(String name) { - return null; + public DnsRecordSetImpl definePtrRecordSet(String name) { + return recordSetsImpl.definePtrRecordSet(name); } @Override - public SrvRecordSetImpl defineSrvRecordSet(String name) { - return null; + public DnsRecordSetImpl defineSrvRecordSet(String name) { + return recordSetsImpl.defineSrvRecordSet(name); } @Override - public TxtRecordSetImpl defineTxtRecordSet(String name) { - return null; + public DnsRecordSetImpl defineTxtRecordSet(String name) { + return recordSetsImpl.defineTxtRecordSet(name); } @Override - public ARecordSetImpl updateARecordSet(String name) { - return null; + public DnsRecordSetImpl updateARecordSet(String name) { + return recordSetsImpl.updateARecordSet(name); } @Override - public AaaaRecordSetImpl updateAaaaRecordSet(String name) { - return null; + public DnsRecordSetImpl updateAaaaRecordSet(String name) { + return recordSetsImpl.updateAaaaRecordSet(name); } @Override - public MxRecordSetImpl updateMxRecordSet(String name) { - return null; + public DnsRecordSetImpl updateMxRecordSet(String name) { + return recordSetsImpl.updateMxRecordSet(name); } @Override - public NsRecordSetImpl updateNsRecordSet(String name) { - return null; + public DnsRecordSetImpl updateNsRecordSet(String name) { + return recordSetsImpl.updateNsRecordSet(name); } @Override - public PtrRecordSetImpl updatePtrRecordSet(String name) { - return null; + public DnsRecordSetImpl updatePtrRecordSet(String name) { + return recordSetsImpl.updatePtrRecordSet(name); } @Override - public SrvRecordSetImpl updateSrvRecordSet(String name) { - return null; + public DnsRecordSetImpl updateSrvRecordSet(String name) { + return recordSetsImpl.updateSrvRecordSet(name); } @Override - public TxtRecordSetImpl updateTxtRecordSet(String name) { - return null; + public DnsRecordSetImpl updateTxtRecordSet(String name) { + return recordSetsImpl.updateTxtRecordSet(name); } @Override - public SoaRecordSetImpl updateSoaRecord() { - return null; + public DnsRecordSetImpl updateSoaRecord() { + return recordSetsImpl.updateSoaRecordSet(); } @Override public DnsZoneImpl withoutARecordSet(String name) { - return null; + recordSetsImpl.withoutARecordSet(name); + return this; } @Override public DnsZoneImpl withoutAaaaRecordSet(String name) { - return null; + recordSetsImpl.withoutAaaaRecordSet(name); + return this; } @Override public DnsZoneImpl withoutCnameRecordSet(String name) { - return null; + recordSetsImpl.withoutCnameRecordSet(name); + return this; } @Override public DnsZoneImpl withoutMxRecordSet(String name) { - return null; + recordSetsImpl.withoutMxRecordSet(name); + return this; } @Override public DnsZoneImpl withoutNsRecordSet(String name) { - return null; + recordSetsImpl.withoutNsRecordSet(name); + return this; } @Override public DnsZoneImpl withoutPtrRecordSet(String name) { - return null; + recordSetsImpl.withoutPtrRecordSet(name); + return this; } @Override public DnsZoneImpl withoutSrvRecordSet(String name) { - return null; + recordSetsImpl.withoutSrvRecordSet(name); + return this; } @Override public DnsZoneImpl withoutTxtRecordSet(String name) { - return null; + recordSetsImpl.withoutTxtRecordSet(name); + return this; } @Override diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java index 5167a5c79e5ac..114a03e4b78cc 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.dns.MxRecord; import com.microsoft.azure.management.dns.MxRecordSet; +import com.microsoft.azure.management.dns.RecordType; import java.util.ArrayList; import java.util.Collections; @@ -17,6 +18,15 @@ class MxRecordSetImpl super(parentDnsZone, innerModel, client); } + static MxRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { + return new MxRecordSetImpl(parentDnsZone, + new RecordSetInner() + .withName(name) + .withType(RecordType.MX.toString()) + .withMxRecords(new ArrayList()), + client); + } + @Override public List records() { if (this.inner().mxRecords() != null) { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java index 8e90c1e34f143..d51350f83f911 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.dns.NsRecord; import com.microsoft.azure.management.dns.NsRecordSet; +import com.microsoft.azure.management.dns.RecordType; import java.util.ArrayList; import java.util.Collections; @@ -17,6 +18,15 @@ class NsRecordSetImpl super(parentDnsZone, innerModel, client); } + static NsRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { + return new NsRecordSetImpl(parentDnsZone, + new RecordSetInner() + .withName(name) + .withType(RecordType.NS.toString()) + .withNsRecords(new ArrayList()), + client); + } + @Override public List nameServers() { List nameServers = new ArrayList<>(); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java index ac779e305e0e6..54b5751de4874 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.dns.PtrRecord; import com.microsoft.azure.management.dns.PtrRecordSet; +import com.microsoft.azure.management.dns.RecordType; import java.util.ArrayList; import java.util.Collections; @@ -17,6 +18,15 @@ class PtrRecordSetImpl super(parentDnsZone, innerModel, client); } + static PtrRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { + return new PtrRecordSetImpl(parentDnsZone, + new RecordSetInner() + .withName(name) + .withType(RecordType.PTR.toString()) + .withPtrRecords(new ArrayList()), + client); + } + @Override public List targetDomainNames() { List targetDomainNames = new ArrayList<>(); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java index 0befd95fb0a71..3818a4c65fcb7 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java @@ -1,5 +1,6 @@ package com.microsoft.azure.management.dns.implementation; +import com.microsoft.azure.management.dns.RecordType; import com.microsoft.azure.management.dns.SrvRecord; import com.microsoft.azure.management.dns.SrvRecordSet; @@ -17,6 +18,15 @@ class SrvRecordSetImpl super(parentDnsZone, innerModel, client); } + static SrvRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { + return new SrvRecordSetImpl(parentDnsZone, + new RecordSetInner() + .withName(name) + .withType(RecordType.SRV.toString()) + .withSrvRecords(new ArrayList()), + client); + } + @Override public List records() { if (this.inner().srvRecords() != null) { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java index b30a82c4bbb2e..3e81983b4a850 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java @@ -1,5 +1,7 @@ package com.microsoft.azure.management.dns.implementation; +import com.microsoft.azure.management.dns.RecordType; +import com.microsoft.azure.management.dns.SrvRecord; import com.microsoft.azure.management.dns.TxtRecord; import com.microsoft.azure.management.dns.TxtRecordSet; @@ -17,6 +19,15 @@ class TxtRecordSetImpl super(parentDnsZone, innerModel, client); } + static TxtRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { + return new TxtRecordSetImpl(parentDnsZone, + new RecordSetInner() + .withName(name) + .withType(RecordType.TXT.toString()) + .withTxtRecords(new ArrayList()), + client); + } + @Override public List records() { if (this.inner().txtRecords() != null) { diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourceCollectionImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourceCollectionImpl.java new file mode 100644 index 0000000000000..ee38cefde3786 --- /dev/null +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourceCollectionImpl.java @@ -0,0 +1,241 @@ +package com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; +import rx.Observable; +import rx.exceptions.CompositeException; +import rx.functions.Action0; +import rx.functions.Action1; +import rx.functions.Action2; +import rx.functions.Func0; +import rx.functions.Func1; +import rx.subjects.PublishSubject; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * Base class for externalized child resource collection abstract implementation. + * (Internal use only) + * + * @param the implementation of {@param FluentModelT} + * @param the fluent model type of the child resource + * @param Azure inner resource class type representing the child resource + * @param the parent Azure resource impl class type that implements {@link ParentT} + * @param the parent interface + */ +public abstract class ExternalChildResourceCollectionImpl< + FluentModelTImpl extends ExternalChildResourceImpl, + FluentModelT extends ExternalChildResource, + InnerModelT, + ParentImplT extends ParentT, + ParentT> { + /** + * The parent resource of this collection of child resources. + */ + private final ParentImplT parent; + + /** + * The child resource instances that this collection contains. + */ + protected ConcurrentMap childCollection = new ConcurrentHashMap<>(); + + /** + * Used to construct error string, this is user friendly name of the child resource (e.g. Subnet, Extension). + */ + protected final String childResourceName; + + /** + * Creates a new ExternalChildResourcesImpl. + * + * @param parent the parent Azure resource + * @param childResourceName the child resource name + */ + protected ExternalChildResourceCollectionImpl(ParentImplT parent, String childResourceName) { + this.parent = parent; + this.childResourceName = childResourceName; + } + + /** + * Commits the changes in the external child resource childCollection. + *

+ * This method returns an observable stream, its observer's onNext will be called for each successfully + * committed resource followed by 'one call to onCompleted' or one call to onError with a + * {@link CompositeException } containing the list of exceptions where each exception describes the reason + * for failure of a resource commit. + * + * @return the observable stream + */ + public Observable commitAsync() { + final ExternalChildResourceCollectionImpl self = this; + List items = new ArrayList<>(); + for (FluentModelTImpl item : this.childCollection.values()) { + items.add(item); + } + + final List exceptionsList = Collections.synchronizedList(new ArrayList()); + Observable deleteStream = Observable.from(items) + .filter(new Func1() { + @Override + public Boolean call(FluentModelTImpl childResource) { + return childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeRemoved; + } + }).flatMap(new Func1>() { + @Override + public Observable call(final FluentModelTImpl childResource) { + return childResource.deleteAsync() + .map(new Func1() { + @Override + public FluentModelTImpl call(Void response) { + return childResource; + } + }).doOnNext(new Action1() { + @Override + public void call(FluentModelTImpl childResource) { + childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.None); + self.childCollection.remove(childResource.name()); + } + }) + .onErrorResumeNext(new Func1>() { + @Override + public Observable call(Throwable throwable) { + exceptionsList.add(throwable); + return Observable.empty(); + } + }); + } + }); + + Observable createStream = Observable.from(items) + .filter(new Func1() { + @Override + public Boolean call(FluentModelTImpl childResource) { + return childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated; + } + }).flatMap(new Func1>() { + @Override + public Observable call(final FluentModelTImpl childResource) { + return childResource.createAsync() + .map(new Func1() { + @Override + public FluentModelTImpl call(FluentModelT fluentModelT) { + return childResource; + } + }) + .doOnNext(new Action1() { + @Override + public void call(FluentModelTImpl fluentModelT) { + childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.None); + } + }) + .onErrorResumeNext(new Func1>() { + @Override + public Observable call(Throwable throwable) { + self.childCollection.remove(childResource.name()); + exceptionsList.add(throwable); + return Observable.empty(); + } + }); + } + }); + + Observable updateStream = Observable.from(items) + .filter(new Func1() { + @Override + public Boolean call(FluentModelTImpl childResource) { + return childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeUpdated; + } + }).flatMap(new Func1>() { + @Override + public Observable call(final FluentModelTImpl childResource) { + return childResource.updateAsync() + .map(new Func1() { + @Override + public FluentModelTImpl call(FluentModelT e) { + return childResource; + } + }) + .doOnNext(new Action1() { + @Override + public void call(FluentModelTImpl childResource) { + childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.None); + } + }) + .onErrorResumeNext(new Func1>() { + @Override + public Observable call(Throwable throwable) { + exceptionsList.add(throwable); + return Observable.empty(); + } + }); + } + }); + + final PublishSubject aggregatedErrorStream = PublishSubject.create(); + Observable operationsStream = Observable.merge(deleteStream, + createStream, + updateStream).doOnTerminate(new Action0() { + @Override + public void call() { + if (exceptionsList.isEmpty()) { + aggregatedErrorStream.onCompleted(); + } else { + aggregatedErrorStream.onError(new CompositeException(exceptionsList)); + } + } + }); + + Observable stream = Observable.concat(operationsStream, aggregatedErrorStream); + return stream; + } + + /** + * Commits the changes in the external child resource childCollection. + *

+ * This method returns a observable stream, either its observer's onError will be called with + * {@link CompositeException} if some resources failed to commit or onNext will be called if all resources + * committed successfully. + * + * @return the observable stream + */ + public Observable> commitAndGetAllAsync() { + return commitAsync().collect( + new Func0>() { + public List call() { + return new ArrayList<>(); + } + }, + new Action2, FluentModelTImpl>() { + public void call(List state, FluentModelTImpl item) { + state.add(item); + } + }); + } + + + /** + * Finds a child resource with the given key. + * + * @param key the child resource key + * @return null if no child resource exists with the given name else the child resource + */ + protected FluentModelTImpl find(String key) { + for (Map.Entry entry : this.childCollection.entrySet()) { + if (entry.getKey().equalsIgnoreCase(key)) { + return entry.getValue(); + } + } + return null; + } + + /** + * @return the parent Azure resource of the external child resource + */ + protected ParentImplT parent() { + return parent; + } +} diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java index ef02604187e10..ad6bb4bd6962a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java @@ -2,21 +2,8 @@ import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; -import rx.Observable; -import rx.exceptions.CompositeException; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action2; -import rx.functions.Func0; -import rx.functions.Func1; -import rx.subjects.PublishSubject; - -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; /** * Externalized child resource collection abstract implementation. @@ -33,20 +20,8 @@ public abstract class ExternalChildResourcesImpl< FluentModelT extends ExternalChildResource, InnerModelT, ParentImplT extends ParentT, - ParentT> { - /** - * The parent resource of this collection of child resources. - */ - private final ParentImplT parent; - /** - * Used to construct error string, this is user friendly name of the child resource (e.g. Subnet, Extension). - */ - private final String childResourceName; - /** - * The child resource instances that this collection contains. - */ - private ConcurrentMap collection = new ConcurrentHashMap<>(); - + ParentT> + extends ExternalChildResourceCollectionImpl { /** * Creates a new ExternalChildResourcesImpl. * @@ -54,196 +29,43 @@ public abstract class ExternalChildResourcesImpl< * @param childResourceName the child resource name */ protected ExternalChildResourcesImpl(ParentImplT parent, String childResourceName) { - this.parent = parent; - this.childResourceName = childResourceName; + super(parent, childResourceName); } /** - * Refresh the collection. + * Refresh the childCollection. */ public void refresh() { initializeCollection(); } /** - * Commits the changes in the external child resource collection. - *

- * This method returns an observable stream, its observer's onNext will be called for each successfully - * committed resource followed by 'one call to onCompleted' or one call to onError with a - * {@link CompositeException } containing the list of exceptions where each exception describes the reason - * for failure of a resource commit. - * - * @return the observable stream + * @return the childCollection of external child resources. */ - public Observable commitAsync() { - final ExternalChildResourcesImpl self = this; - List items = new ArrayList<>(); - for (FluentModelTImpl item : this.collection.values()) { - items.add(item); - } - - final List exceptionsList = Collections.synchronizedList(new ArrayList()); - Observable deleteStream = Observable.from(items) - .filter(new Func1() { - @Override - public Boolean call(FluentModelTImpl childResource) { - return childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeRemoved; - } - }).flatMap(new Func1>() { - @Override - public Observable call(final FluentModelTImpl childResource) { - return childResource.deleteAsync() - .map(new Func1() { - @Override - public FluentModelTImpl call(Void response) { - return childResource; - } - }).doOnNext(new Action1() { - @Override - public void call(FluentModelTImpl childResource) { - childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.None); - self.collection.remove(childResource.name()); - } - }) - .onErrorResumeNext(new Func1>() { - @Override - public Observable call(Throwable throwable) { - exceptionsList.add(throwable); - return Observable.empty(); - } - }); - } - }); - - Observable createStream = Observable.from(items) - .filter(new Func1() { - @Override - public Boolean call(FluentModelTImpl childResource) { - return childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated; - } - }).flatMap(new Func1>() { - @Override - public Observable call(final FluentModelTImpl childResource) { - return childResource.createAsync() - .map(new Func1() { - @Override - public FluentModelTImpl call(FluentModelT fluentModelT) { - return childResource; - } - }) - .doOnNext(new Action1() { - @Override - public void call(FluentModelTImpl fluentModelT) { - childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.None); - } - }) - .onErrorResumeNext(new Func1>() { - @Override - public Observable call(Throwable throwable) { - self.collection.remove(childResource.name()); - exceptionsList.add(throwable); - return Observable.empty(); - } - }); - } - }); - - Observable updateStream = Observable.from(items) - .filter(new Func1() { - @Override - public Boolean call(FluentModelTImpl childResource) { - return childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeUpdated; - } - }).flatMap(new Func1>() { - @Override - public Observable call(final FluentModelTImpl childResource) { - return childResource.updateAsync() - .map(new Func1() { - @Override - public FluentModelTImpl call(FluentModelT e) { - return childResource; - } - }) - .doOnNext(new Action1() { - @Override - public void call(FluentModelTImpl childResource) { - childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.None); - } - }) - .onErrorResumeNext(new Func1>() { - @Override - public Observable call(Throwable throwable) { - exceptionsList.add(throwable); - return Observable.empty(); - } - }); - } - }); - - final PublishSubject aggregatedErrorStream = PublishSubject.create(); - Observable operationsStream = Observable.merge(deleteStream, - createStream, - updateStream).doOnTerminate(new Action0() { - @Override - public void call() { - if (exceptionsList.isEmpty()) { - aggregatedErrorStream.onCompleted(); - } else { - aggregatedErrorStream.onError(new CompositeException(exceptionsList)); - } - } - }); - - Observable stream = Observable.concat(operationsStream, aggregatedErrorStream); - return stream; + protected Map collection() { + return this.childCollection; } /** - * Commits the changes in the external child resource collection. - *

- * This method returns a observable stream, either its observer's onError will be called with - * {@link CompositeException} if some resources failed to commit or onNext will be called if all resources - * committed successfully. + * Prepare for definition of a new external child resource. * - * @return the observable stream - */ - public Observable> commitAndGetAllAsync() { - return commitAsync().collect( - new Func0>() { - public List call() { - return new ArrayList<>(); - } - }, - new Action2, FluentModelTImpl>() { - public void call(List state, FluentModelTImpl item) { - state.add(item); - } - }); - } - - /** - * @return the parent Azure resource of the external child resource - */ - protected ParentImplT parent() { - return parent; - } - - /** - * @return the collection of external child resources. + * @param name the name for the new external child resource + * @return the child resource */ - protected Map collection() { - return this.collection; + protected FluentModelTImpl prepareDefine(String name) { + return prepareDefine(name, name); } /** * Prepare for definition of a new external child resource. * - * @param name the name for the new external child resource + * @param name the name of the new external child resource + * @param key the key * @return the child resource */ - protected FluentModelTImpl prepareDefine(String name) { - if (find(name) != null) { - throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name '" + name + "' already exists"); + protected FluentModelTImpl prepareDefine(String name, String key) { + if (find(key) != null) { + throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' already exists"); } FluentModelTImpl childResource = newChildResource(name); childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeCreated); @@ -257,13 +79,24 @@ protected FluentModelTImpl prepareDefine(String name) { * @return the external child resource to be updated */ protected FluentModelTImpl prepareUpdate(String name) { - FluentModelTImpl childResource = find(name); + return prepareUpdate(name, name); + } + + /** + * Prepare for an external child resource update. + * + * @param name the name of the external child resource + * @param key the key + * @return the external child resource to be updated + */ + protected FluentModelTImpl prepareUpdate(String name, String key) { + FluentModelTImpl childResource = find(key); if (childResource == null || childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated) { - throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name '" + name + "' not found"); + throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' not found"); } if (childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeRemoved) { - throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name '" + name + "' is marked for deletion"); + throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' is marked for deletion"); } childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeUpdated); return childResource; @@ -275,30 +108,50 @@ protected FluentModelTImpl prepareUpdate(String name) { * @param name the name of the external child resource */ protected void prepareRemove(String name) { - FluentModelTImpl childResource = find(name); + prepareRemove(name, name); + } + + /** + * Mark an external child resource with given key as to be removed. + * + * @param name the name of the external child resource + * @param key the key + */ + protected void prepareRemove(String name, String key) { + FluentModelTImpl childResource = find(key); if (childResource == null || childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated) { - throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name '" + name + "' not found"); + throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' not found"); } childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeRemoved); } /** - * Adds an external child resource to the collection. + * Adds an external child resource to the childCollection. * * @param childResource the external child resource */ protected void addChildResource(FluentModelTImpl childResource) { - this.collection.put(childResource.name(), childResource); + this.addChildResource(childResource.name(), childResource); + } + + /** + * Adds an external child resource to the childCollection. + * + * @param key the key + * @param childResource the external child resource + */ + protected void addChildResource(String key, FluentModelTImpl childResource) { + this.childCollection.put(key, childResource); } /** - * Initializes the external child resource collection. + * Initializes the external child resource childCollection. */ protected void initializeCollection() { - this.collection.clear(); + this.childCollection.clear(); for (FluentModelTImpl childResource : this.listChildResources()) { - this.collection.put(childResource.name(), childResource); + this.childCollection.put(childResource.childResourceKey(), childResource); } } @@ -316,19 +169,4 @@ protected void initializeCollection() { * @return the new child resource */ protected abstract FluentModelTImpl newChildResource(String name); - - /** - * Finds a child resource with the given name. - * - * @param name the child resource name - * @return null if no child resource exists with the given name else the child resource - */ - private FluentModelTImpl find(String name) { - for (Map.Entry entry : this.collection.entrySet()) { - if (entry.getKey().equalsIgnoreCase(name)) { - return entry.getValue(); - } - } - return null; - } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalNonInlineChildResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalNonInlineChildResourcesImpl.java new file mode 100644 index 0000000000000..d86767a9240c3 --- /dev/null +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalNonInlineChildResourcesImpl.java @@ -0,0 +1,82 @@ +package com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; + +/** + * Externalized child resource collection abstract implementation. + * (Internal use only) + * + * @param the implementation of {@param FluentModelT} + * @param the fluent model type of the child resource + * @param Azure inner resource class type representing the child resource + * @param the parent Azure resource impl class type that implements {@link ParentT} + * @param the parent interface + */ +public class ExternalNonInlineChildResourcesImpl< + FluentModelTImpl extends ExternalChildResourceImpl, + FluentModelT extends ExternalChildResource, + InnerModelT, + ParentImplT extends ParentT, + ParentT> + extends ExternalChildResourceCollectionImpl { + /** + * Creates a new ExternalNonInlineChildResourcesImpl. + * + * @param parent the parent Azure resource + * @param childResourceName the child resource name + */ + protected ExternalNonInlineChildResourcesImpl(ParentImplT parent, String childResourceName) { + super(parent, childResourceName); + } + + /** + * Prepare a given model of an external child resource for create. + * + * @param model the model to track create changes + * @return the external child resource prepared for create + */ + protected FluentModelTImpl prepareDefine(FluentModelTImpl model) { + FluentModelTImpl childResource = find(model.childResourceKey()); + if (childResource != null) { + throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); + } + childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeCreated); + this.childCollection.put(model.childResourceKey(), childResource); + return childResource; + } + + /** + * Prepare a given model of an external child resource for update. + * + * @param model the model to track update changes + * @return the external child resource prepared for update + */ + protected FluentModelTImpl prepareUpdate(FluentModelTImpl model) { + FluentModelTImpl childResource = find(model.childResourceKey()); + if (childResource != null) { + throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); + } + childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeUpdated); + this.childCollection.put(model.childResourceKey(), childResource); + return childResource; + } + + /** + * Prepare a given model of an external child resource for remove. + * + * @param model the model representing child resource to remove + */ + protected void prepareRemove(FluentModelTImpl model) { + FluentModelTImpl childResource = find(model.childResourceKey()); + if (childResource != null) { + throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); + } + childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeRemoved); + this.childCollection.put(model.childResourceKey(), childResource); + } + + private String pendingOperationMessage(String name, String key) { + return "There is already an operation pending on a child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")'"; + } +} diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java index aa787ce3e38d1..3ecb5c1bf9418 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java @@ -92,6 +92,13 @@ public void setPendingOperation(PendingOperation pendingOperation) { */ public abstract Observable deleteAsync(); + /** + * @return the key of this child resource in the collection maintained by ExternalChildResourcesImpl + */ + public String childResourceKey() { + return name(); + } + /** * The possible operation pending on a child resource in-memory. */ diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java index 842479fd1e0b1..1fd1cf13dcec5 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java @@ -24,10 +24,10 @@ */ class TrafficManagerEndpointsImpl extends ExternalChildResourcesImpl { + TrafficManagerEndpoint, + EndpointInner, + TrafficManagerProfileImpl, + TrafficManagerProfile> { private final EndpointsInner client; /** From f549fee2a8069701a2a7b8f56ec00c5240087817 Mon Sep 17 00:00:00 2001 From: anuchan Date: Fri, 4 Nov 2016 17:33:01 -0700 Subject: [PATCH 17/27] override childResourceKey in DnsRecordSetImpl --- .../management/dns/implementation/DnsRecordSetImpl.java | 6 +++++- .../models/implementation/ExternalChildResourceImpl.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index bcda5be7ee9b6..b4d2b8be3312d 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -300,10 +300,14 @@ public Observable deleteAsync() { @Override public DnsZoneImpl attach() { - // TODO add record return this.parent(); } + @Override + public String childResourceKey() { + return this.name() + "_" + this.recordType(); + } + @Override public DnsRecordSetImpl refresh() { this.setInner(this.client.get(this.parent().resourceGroupName(), diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java index 3ecb5c1bf9418..6971fe3ea0ba9 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java @@ -93,7 +93,7 @@ public void setPendingOperation(PendingOperation pendingOperation) { public abstract Observable deleteAsync(); /** - * @return the key of this child resource in the collection maintained by ExternalChildResourcesImpl + * @return the key of this child resource in the collection maintained by ExternalChildResourceCollectionImpl */ public String childResourceKey() { return name(); From 19578742359b85f9987e340ff0a96c5dab28583b Mon Sep 17 00:00:00 2001 From: anuchan Date: Fri, 4 Nov 2016 17:54:58 -0700 Subject: [PATCH 18/27] removing duplicate initialization of inner properties --- .../azure/management/dns/DnsRecordSet.java | 27 +++--------------- .../dns/implementation/DnsRecordSetImpl.java | 28 ------------------- .../dns/implementation/DnsRecordSetsImpl.java | 2 +- .../dns/implementation/SoaRecordSetImpl.java | 10 +++++++ 4 files changed, 15 insertions(+), 52 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index 84a075976e790..13caff52a8b46 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -6,8 +6,6 @@ import com.microsoft.azure.management.resources.fluentcore.model.Settable; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; -import java.util.Map; - /** * An immutable client-side representation of a record set in Azure Dns Zone. */ @@ -315,15 +313,9 @@ interface WithTtl { * @param the return type of {@link UpdateDefinitionStages.WithAttach#attach()} */ interface WithTags { - /** - * Specifies tags for the resource as a {@link Map}. - * @param tags a {@link Map} of tags - * @return the next stage of the record set definition - */ - WithAttach withTags(Map tags); - /** * Adds a tag to the resource. + * * @param key the key for the tag * @param value the value for the tag * @return the next stage of the record set definition @@ -634,15 +626,9 @@ interface WithTtl { * @param the return type of {@link WithAttach#attach()} */ interface WithTags { - /** - * Specifies tags for the resource as a {@link Map}. - * @param tags a {@link Map} of tags - * @return the next stage of the record set update - */ - WithAttach withTags(Map tags); - /** * Adds a tag to the resource. + * * @param key the key for the tag * @param value the value for the tag * @return the next stage of the record set definition @@ -984,15 +970,9 @@ interface WithTtl { * An update allowing tags to be modified for the resource. */ interface UpdateWithTags { - /** - * Specifies tags for the record set as a {@link Map}. - * @param tags a {@link Map} of tags - * @return the next stage of the record set update - */ - Update withTags(Map tags); - /** * Adds a tag to the record set. + * * @param key the key for the tag * @param value the value for the tag * @return the next stage of the record set update @@ -1001,6 +981,7 @@ interface UpdateWithTags { /** * Removes a tag from the record set. + * * @param key the key of the tag to remove * @return the next stage of the record set update */ diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index b4d2b8be3312d..c025d2948303a 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -16,7 +16,6 @@ import rx.functions.Func1; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -71,9 +70,6 @@ public long timeToLive() { @Override public DnsRecordSetImpl withIpv4Address(String ipv4Address) { - if (this.inner().aRecords() == null) { - this.inner().withARecords(new ArrayList()); - } this.inner() .aRecords() .add(new ARecord().withIpv4Address(ipv4Address)); @@ -90,9 +86,6 @@ public DnsRecordSetImpl withoutIpv4Address(String ipv4Address) { @Override public DnsRecordSetImpl withIpv6Address(String ipv6Address) { - if (this.inner().aaaaRecords() == null) { - this.inner().withAaaaRecords(new ArrayList()); - } this.inner() .aaaaRecords() .add(new AaaaRecord().withIpv6Address(ipv6Address)); @@ -109,9 +102,6 @@ public DnsRecordSetImpl withoutIpv6Address(String ipv6Address) { @Override public DnsRecordSetImpl withMailExchange(String mailExchangeHostName, int priority) { - if (this.inner().mxRecords() == null) { - this.inner().withMxRecords(new ArrayList()); - } this.inner() .mxRecords() .add(new MxRecord().withExchange(mailExchangeHostName).withPreference(priority)); @@ -128,9 +118,6 @@ public DnsRecordSetImpl withoutMailExchange(String mailExchangeHostName, int pri @Override public DnsRecordSetImpl withNameServer(String nameServerHostName) { - if (this.inner().nsRecords() == null) { - this.inner().withNsRecords(new ArrayList()); - } this.inner() .nsRecords() .add(new NsRecord().withNsdname(nameServerHostName)); @@ -147,9 +134,6 @@ public DnsRecordSetImpl withoutNameServer(String nameServerHostName) { @Override public DnsRecordSetImpl withTargetDomainName(String targetDomainName) { - if (this.inner().ptrRecords() == null) { - this.inner().withPtrRecords(new ArrayList()); - } this.inner() .ptrRecords() .add(new PtrRecord().withPtrdname(targetDomainName)); @@ -166,9 +150,6 @@ public DnsRecordSetImpl withoutTargetDomainName(String targetDomainName) { @Override public DnsRecordSetImpl withRecord(String target, int port, int priority, int weight) { - if (this.inner().srvRecords() == null) { - this.inner().withSrvRecords(new ArrayList()); - } this.inner().srvRecords().add(new SrvRecord() .withTarget(target) .withPort(port) @@ -190,9 +171,6 @@ public DnsRecordSetImpl withoutRecord(String target, int port, int priority, int @Override public DnsRecordSetImpl withText(String text) { - if (this.inner().txtRecords() == null) { - this.inner().withTxtRecords(new ArrayList()); - } List value = new ArrayList<>(); value.add(text); this.inner().txtRecords().add(new TxtRecord().withValue(value)); @@ -250,12 +228,6 @@ public DnsRecordSetImpl withTimeToLive(long ttlInSeconds) { return this; } - @Override - public DnsRecordSetImpl withTags(Map tags) { - this.inner().withMetadata(new HashMap<>(tags)); - return this; - } - @Override public DnsRecordSetImpl withTag(String key, String value) { this.inner().metadata().put(key, value); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java index 00d4fc0d4d034..d88841e750b7e 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java @@ -89,7 +89,7 @@ DnsRecordSetImpl updateTxtRecordSet(String name) { } DnsRecordSetImpl updateSoaRecordSet() { - return prepareUpdate(TxtRecordSetImpl.newRecordSet("@", this.parent(), this.client)); + return prepareUpdate(SoaRecordSetImpl.newRecordSet(this.parent(), this.client)); } void withoutARecordSet(String name) { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java index 59cfc951bb1ec..57ed21f1d0290 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java @@ -1,5 +1,6 @@ package com.microsoft.azure.management.dns.implementation; +import com.microsoft.azure.management.dns.RecordType; import com.microsoft.azure.management.dns.SoaRecord; import com.microsoft.azure.management.dns.SoaRecordSet; @@ -13,6 +14,15 @@ class SoaRecordSetImpl super(parentDnsZone, innerModel, client); } + static SoaRecordSetImpl newRecordSet(final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { + return new SoaRecordSetImpl(parentDnsZone, + new RecordSetInner() + .withName("@") + .withType(RecordType.SOA.toString()) + .withSoaRecord(new SoaRecord()), + client); + } + @Override public SoaRecord record() { return this.inner().soaRecord(); From 3d512080c4cd9a2a866e800f3198a6a0ee5c4f1c Mon Sep 17 00:00:00 2001 From: anuchan Date: Sat, 5 Nov 2016 13:12:57 -0700 Subject: [PATCH 19/27] Enables external child resources to support both inline and non-inline external child resources. --- .../ApplicationPackagesImpl.java | 6 ++-- .../implementation/ApplicationsImpl.java | 6 ++-- .../VirtualMachineExtensionsImpl.java | 14 ++++---- .../dns/implementation/ARecordSetImpl.java | 20 +++++------ .../dns/implementation/AaaaRecordSetImpl.java | 12 +++---- .../implementation/CnameRecordSetImpl.java | 8 ++--- .../dns/implementation/DnsRecordSetImpl.java | 2 +- .../dns/implementation/DnsRecordSetsImpl.java | 16 +++++---- .../dns/implementation/DnsZoneImpl.java | 19 ++++++++-- .../dns/implementation/MxRecordSetImpl.java | 12 +++---- .../dns/implementation/NsRecordSetImpl.java | 12 +++---- .../dns/implementation/PtrRecordSetImpl.java | 14 ++++---- .../dns/implementation/SoaRecordSetImpl.java | 10 +++--- .../dns/implementation/SrvRecordSetImpl.java | 12 +++---- .../dns/implementation/TxtRecordSetImpl.java | 12 +++---- .../ExternalChildResourceCollectionImpl.java | 13 +++++-- ... => ExternalChildResourcesCachedImpl.java} | 35 ++++++++++++------- ... ExternalChildResourcesNonCachedImpl.java} | 25 +++++++++---- .../ExternalChildResourceImpl.java | 2 +- .../resources/childresource/PulletsImpl.java | 6 ++-- .../TrafficManagerEndpointsImpl.java | 14 ++++---- 21 files changed, 154 insertions(+), 116 deletions(-) rename azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/{ExternalChildResourcesImpl.java => ExternalChildResourcesCachedImpl.java} (82%) rename azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/{ExternalNonInlineChildResourcesImpl.java => ExternalChildResourcesNonCachedImpl.java} (74%) diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackagesImpl.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackagesImpl.java index 9c8edd4b6d22b..deb2109c762c8 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackagesImpl.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/ApplicationPackagesImpl.java @@ -9,7 +9,7 @@ import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.batch.Application; import com.microsoft.azure.management.batch.ApplicationPackage; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesCachedImpl; import java.util.List; import java.util.Map; @@ -22,7 +22,7 @@ */ @LangDefinition class ApplicationPackagesImpl extends - ExternalChildResourcesImpl asMap() { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java index 12a5cfaf712ad..ffee13ebb66c7 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java @@ -2,7 +2,7 @@ import com.microsoft.azure.management.compute.VirtualMachine; import com.microsoft.azure.management.compute.VirtualMachineExtension; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesCachedImpl; import java.util.ArrayList; import java.util.Collections; @@ -14,11 +14,11 @@ * Represents a extension collection associated with a virtual machine. */ class VirtualMachineExtensionsImpl extends - ExternalChildResourcesImpl { + ExternalChildResourcesCachedImpl { private final VirtualMachineExtensionsInner client; /** @@ -30,7 +30,7 @@ class VirtualMachineExtensionsImpl extends VirtualMachineExtensionsImpl(VirtualMachineExtensionsInner client, VirtualMachineImpl parent) { super(parent, "VirtualMachineExtension"); this.client = client; - this.initializeCollection(); + this.cacheCollection(); } /** diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java index 7936e8800efaf..c48328b5c3228 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/ARecordSetImpl.java @@ -14,12 +14,12 @@ class ARecordSetImpl extends DnsRecordSetImpl implements ARecordSet { - ARecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(parentDnsZone, innerModel, client); + ARecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parent, innerModel, client); } - static ARecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { - return new ARecordSetImpl(parentDnsZone, + static ARecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent, final RecordSetsInner client) { + return new ARecordSetImpl(parent, new RecordSetInner() .withName(name) .withType(RecordType.A.toString()) @@ -29,13 +29,13 @@ static ARecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDn @Override public List ipv4Addresses() { - List ipv6Addresses = new ArrayList<>(); - if (this.inner().aaaaRecords() != null) { + List ipv4Addresses = new ArrayList<>(); + if (this.inner().aRecords() != null) { for (ARecord aRecord : this.inner().aRecords()) { - ipv6Addresses.add(aRecord.ipv4Address()); + ipv4Addresses.add(aRecord.ipv4Address()); } } - return Collections.unmodifiableList(ipv6Addresses); + return Collections.unmodifiableList(ipv4Addresses); } @Override @@ -45,9 +45,7 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { resource.withARecords(new ArrayList()); } - for (ARecord recordToAdd : this.inner().aRecords()) { - resource.aRecords().add(recordToAdd); - } + resource.aRecords().addAll(this.inner().aRecords()); this.inner().aRecords().clear(); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java index 100e66513a276..bb9bd0f86cd7f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/AaaaRecordSetImpl.java @@ -15,12 +15,12 @@ class AaaaRecordSetImpl extends DnsRecordSetImpl implements AaaaRecordSet { - AaaaRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(parentDnsZone, innerModel, client); + AaaaRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parent, innerModel, client); } - static AaaaRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { - return new AaaaRecordSetImpl(parentDnsZone, + static AaaaRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent, final RecordSetsInner client) { + return new AaaaRecordSetImpl(parent, new RecordSetInner() .withName(name) .withType(RecordType.AAAA.toString()) @@ -46,9 +46,7 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { resource.withAaaaRecords(new ArrayList()); } - for (AaaaRecord recordToAdd : this.inner().aaaaRecords()) { - resource.aaaaRecords().add(recordToAdd); - } + resource.aaaaRecords().addAll(this.inner().aaaaRecords()); this.inner().aaaaRecords().clear(); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java index 1955dd73df523..bef49261e76ec 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java @@ -10,12 +10,12 @@ class CnameRecordSetImpl extends DnsRecordSetImpl implements CnameRecordSet { - CnameRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(parentDnsZone, innerModel, client); + CnameRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parent, innerModel, client); } - static CnameRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { - return new CnameRecordSetImpl(parentDnsZone, + static CnameRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent, final RecordSetsInner client) { + return new CnameRecordSetImpl(parent, new RecordSetInner() .withName(name) .withType(RecordType.CNAME.toString()) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index c025d2948303a..188da0e334e8d 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -277,7 +277,7 @@ public DnsZoneImpl attach() { @Override public String childResourceKey() { - return this.name() + "_" + this.recordType(); + return this.name() + "_" + this.recordType().toString(); } @Override diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java index d88841e750b7e..fc082ca249efd 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java @@ -2,17 +2,17 @@ import com.microsoft.azure.management.dns.DnsRecordSet; import com.microsoft.azure.management.dns.DnsZone; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalNonInlineChildResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesNonCachedImpl; /** * Represents an record set collection associated with a Dns zone. */ class DnsRecordSetsImpl extends - ExternalNonInlineChildResourcesImpl { + ExternalChildResourcesNonCachedImpl { private final RecordSetsInner client; /** @@ -123,4 +123,8 @@ void withoutSrvRecordSet(String name) { void withoutTxtRecordSet(String name) { prepareRemove(TxtRecordSetImpl.newRecordSet(name, this.parent(), this.client)); } + + final void clearPendingOperations() { + this.childCollection.clear(); + } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java index a79a35a2f78a0..9f71182348f31 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.management.dns.TxtRecordSets; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; import rx.Observable; +import rx.functions.Func1; import java.util.List; @@ -248,8 +249,21 @@ public DnsZoneImpl withoutTxtRecordSet(String name) { @Override public Observable createResourceAsync() { + final DnsZoneImpl self = this; return this.innerCollection.createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner()) - .map(innerToFluentMap(this)); + .map(innerToFluentMap(this)) + .flatMap(new Func1>() { + @Override + public Observable call(DnsZone dnsZone) { + return self.recordSetsImpl.commitAndGetAllAsync() + .map(new Func1, DnsZone>() { + @Override + public DnsZone call(List recordSets) { + return self; + } + }); + } + }); } @Override @@ -262,12 +276,13 @@ public DnsZone refresh() { private void initRecordSets() { this.aRecordSets = new ARecordSetsImpl(this, this.recordSetsClient); - this.aaaaRecordSets = new AaaaRecordSetsImpl(this, this.recordSetsClient); + this.aaaaRecordSets = new AaaaRecordSetsImpl(this, this.recordSetsClient); this.cnameRecordSets = new CnameRecordSetsImpl(this, this.recordSetsClient); this.mxRecordSets = new MxRecordSetsImpl(this, this.recordSetsClient); this.nsRecordSets = new NsRecordSetsImpl(this, this.recordSetsClient); this.ptrRecordSets = new PtrRecordSetsImpl(this, this.recordSetsClient); this.srvRecordSets = new SrvRecordSetsImpl(this, this.recordSetsClient); this.txtRecordSets = new TxtRecordSetsImpl(this, this.recordSetsClient); + this.recordSetsImpl.clearPendingOperations(); } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java index 114a03e4b78cc..a37ee36718d59 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -14,12 +14,12 @@ class MxRecordSetImpl extends DnsRecordSetImpl implements MxRecordSet { - MxRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(parentDnsZone, innerModel, client); + MxRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parent, innerModel, client); } - static MxRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { - return new MxRecordSetImpl(parentDnsZone, + static MxRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent, final RecordSetsInner client) { + return new MxRecordSetImpl(parent, new RecordSetInner() .withName(name) .withType(RecordType.MX.toString()) @@ -42,9 +42,7 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { resource.withMxRecords(new ArrayList()); } - for (MxRecord recordToAdd : this.inner().mxRecords()) { - resource.mxRecords().add(recordToAdd); - } + resource.mxRecords().addAll(this.inner().mxRecords()); this.inner().mxRecords().clear(); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java index d51350f83f911..0a70130af7190 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java @@ -14,12 +14,12 @@ class NsRecordSetImpl extends DnsRecordSetImpl implements NsRecordSet { - NsRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(parentDnsZone, innerModel, client); + NsRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parent, innerModel, client); } - static NsRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { - return new NsRecordSetImpl(parentDnsZone, + static NsRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent, final RecordSetsInner client) { + return new NsRecordSetImpl(parent, new RecordSetInner() .withName(name) .withType(RecordType.NS.toString()) @@ -45,8 +45,8 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { resource.withNsRecords(new ArrayList()); } - for (NsRecord recordToAdd : this.inner().nsRecords()) { - resource.nsRecords().add(recordToAdd); + for (NsRecord record : this.inner().nsRecords()) { + resource.nsRecords().add(record); } this.inner().nsRecords().clear(); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java index 54b5751de4874..bc82845d80372 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/PtrRecordSetImpl.java @@ -14,12 +14,12 @@ class PtrRecordSetImpl extends DnsRecordSetImpl implements PtrRecordSet { - PtrRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(parentDnsZone, innerModel, client); + PtrRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parent, innerModel, client); } - static PtrRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { - return new PtrRecordSetImpl(parentDnsZone, + static PtrRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent, final RecordSetsInner client) { + return new PtrRecordSetImpl(parent, new RecordSetInner() .withName(name) .withType(RecordType.PTR.toString()) @@ -30,7 +30,7 @@ static PtrRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent @Override public List targetDomainNames() { List targetDomainNames = new ArrayList<>(); - if (this.inner().aaaaRecords() != null) { + if (this.inner().ptrRecords() != null) { for (PtrRecord ptrRecord : this.inner().ptrRecords()) { targetDomainNames.add(ptrRecord.ptrdname()); } @@ -45,9 +45,7 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { resource.withPtrRecords(new ArrayList()); } - for (PtrRecord recordToAdd : this.inner().ptrRecords()) { - resource.ptrRecords().add(recordToAdd); - } + resource.ptrRecords().addAll(this.inner().ptrRecords()); this.inner().ptrRecords().clear(); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java index 57ed21f1d0290..94378dbca8462 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SoaRecordSetImpl.java @@ -10,12 +10,12 @@ class SoaRecordSetImpl extends DnsRecordSetImpl implements SoaRecordSet { - SoaRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(parentDnsZone, innerModel, client); + SoaRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parent, innerModel, client); } - static SoaRecordSetImpl newRecordSet(final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { - return new SoaRecordSetImpl(parentDnsZone, + static SoaRecordSetImpl newRecordSet(final DnsZoneImpl parent, final RecordSetsInner client) { + return new SoaRecordSetImpl(parent, new RecordSetInner() .withName("@") .withType(RecordType.SOA.toString()) @@ -51,7 +51,7 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { } if (this.inner().soaRecord().retryTime() != null) { - resource.soaRecord().withRefreshTime(this.inner().soaRecord().retryTime()); + resource.soaRecord().withRetryTime(this.inner().soaRecord().retryTime()); } if (this.inner().soaRecord().serialNumber() != null) { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java index 3818a4c65fcb7..bef64cf7cfbc4 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java @@ -14,12 +14,12 @@ class SrvRecordSetImpl extends DnsRecordSetImpl implements SrvRecordSet { - SrvRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(parentDnsZone, innerModel, client); + SrvRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parent, innerModel, client); } - static SrvRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { - return new SrvRecordSetImpl(parentDnsZone, + static SrvRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent, final RecordSetsInner client) { + return new SrvRecordSetImpl(parent, new RecordSetInner() .withName(name) .withType(RecordType.SRV.toString()) @@ -42,9 +42,7 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { resource.withSrvRecords(new ArrayList()); } - for (SrvRecord recordToAdd : this.inner().srvRecords()) { - resource.srvRecords().add(recordToAdd); - } + resource.srvRecords().addAll(this.inner().srvRecords()); this.inner().srvRecords().clear(); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java index 3e81983b4a850..46bd7170ad6c0 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java @@ -15,12 +15,12 @@ class TxtRecordSetImpl extends DnsRecordSetImpl implements TxtRecordSet { - TxtRecordSetImpl(final DnsZoneImpl parentDnsZone, final RecordSetInner innerModel, final RecordSetsInner client) { - super(parentDnsZone, innerModel, client); + TxtRecordSetImpl(final DnsZoneImpl parent, final RecordSetInner innerModel, final RecordSetsInner client) { + super(parent, innerModel, client); } - static TxtRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parentDnsZone, final RecordSetsInner client) { - return new TxtRecordSetImpl(parentDnsZone, + static TxtRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent, final RecordSetsInner client) { + return new TxtRecordSetImpl(parent, new RecordSetInner() .withName(name) .withType(RecordType.TXT.toString()) @@ -43,9 +43,7 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { resource.withTxtRecords(new ArrayList()); } - for (TxtRecord recordToAdd : this.inner().txtRecords()) { - resource.txtRecords().add(recordToAdd); - } + resource.txtRecords().addAll(this.inner().txtRecords()); this.inner().txtRecords().clear(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourceCollectionImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourceCollectionImpl.java index ee38cefde3786..2512a2a0a0274 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourceCollectionImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourceCollectionImpl.java @@ -19,7 +19,8 @@ import java.util.concurrent.ConcurrentMap; /** - * Base class for externalized child resource collection abstract implementation. + * Base class for cached {@link ExternalChildResourcesCachedImpl} and non-cached {@link ExternalChildResourcesNonCachedImpl} + * externalized child resource collection. * (Internal use only) * * @param the implementation of {@param FluentModelT} @@ -64,7 +65,7 @@ protected ExternalChildResourceCollectionImpl(ParentImplT parent, String childRe * Commits the changes in the external child resource childCollection. *

* This method returns an observable stream, its observer's onNext will be called for each successfully - * committed resource followed by 'one call to onCompleted' or one call to onError with a + * committed resource followed by one call to 'onCompleted' or one call to 'onError' with a * {@link CompositeException } containing the list of exceptions where each exception describes the reason * for failure of a resource commit. * @@ -181,6 +182,9 @@ public Observable call(Throwable throwable) { updateStream).doOnTerminate(new Action0() { @Override public void call() { + if (clearAfterCommit()) { + self.childCollection.clear(); + } if (exceptionsList.isEmpty()) { aggregatedErrorStream.onCompleted(); } else { @@ -238,4 +242,9 @@ protected FluentModelTImpl find(String key) { protected ParentImplT parent() { return parent; } + + /** + * @return true if the child resource collection needs to be cleared after the commit. + */ + protected abstract boolean clearAfterCommit(); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesCachedImpl.java similarity index 82% rename from azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java rename to azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesCachedImpl.java index ad6bb4bd6962a..3162cbb9474ec 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesCachedImpl.java @@ -6,8 +6,14 @@ import java.util.Map; /** - * Externalized child resource collection abstract implementation. + * Externalized cache-able child resource collection abstract implementation. * (Internal use only) + *

+ * An external child resource collection is considered as cache-able when it is present as an inline + * property of it's parent resource. + * Consider using non-cached version {@link ExternalChildResourcesNonCachedImpl} if the child resources + * are not present in the parent payload, using cached version in this case requires fetching the child resource + * using separate GET call, that can be expensive if the child resources are pagable. * * @param the implementation of {@param FluentModelT} * @param the fluent model type of the child resource @@ -15,7 +21,7 @@ * @param the parent Azure resource impl class type that implements {@link ParentT} * @param the parent interface */ -public abstract class ExternalChildResourcesImpl< +public abstract class ExternalChildResourcesCachedImpl< FluentModelTImpl extends ExternalChildResourceImpl, FluentModelT extends ExternalChildResource, InnerModelT, @@ -28,15 +34,15 @@ public abstract class ExternalChildResourcesImpl< * @param parent the parent Azure resource * @param childResourceName the child resource name */ - protected ExternalChildResourcesImpl(ParentImplT parent, String childResourceName) { + protected ExternalChildResourcesCachedImpl(ParentImplT parent, String childResourceName) { super(parent, childResourceName); } /** - * Refresh the childCollection. + * Refresh the child resource collection. */ public void refresh() { - initializeCollection(); + cacheCollection(); } /** @@ -63,7 +69,7 @@ protected FluentModelTImpl prepareDefine(String name) { * @param key the key * @return the child resource */ - protected FluentModelTImpl prepareDefine(String name, String key) { + protected final FluentModelTImpl prepareDefine(String name, String key) { if (find(key) != null) { throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' already exists"); } @@ -78,7 +84,7 @@ protected FluentModelTImpl prepareDefine(String name, String key) { * @param name the name of the external child resource * @return the external child resource to be updated */ - protected FluentModelTImpl prepareUpdate(String name) { + protected final FluentModelTImpl prepareUpdate(String name) { return prepareUpdate(name, name); } @@ -89,7 +95,7 @@ protected FluentModelTImpl prepareUpdate(String name) { * @param key the key * @return the external child resource to be updated */ - protected FluentModelTImpl prepareUpdate(String name, String key) { + protected final FluentModelTImpl prepareUpdate(String name, String key) { FluentModelTImpl childResource = find(key); if (childResource == null || childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated) { @@ -107,7 +113,7 @@ protected FluentModelTImpl prepareUpdate(String name, String key) { * * @param name the name of the external child resource */ - protected void prepareRemove(String name) { + protected final void prepareRemove(String name) { prepareRemove(name, name); } @@ -117,7 +123,7 @@ protected void prepareRemove(String name) { * @param name the name of the external child resource * @param key the key */ - protected void prepareRemove(String name, String key) { + protected final void prepareRemove(String name, String key) { FluentModelTImpl childResource = find(key); if (childResource == null || childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated) { @@ -146,15 +152,20 @@ protected void addChildResource(String key, FluentModelTImpl childResource) { } /** - * Initializes the external child resource childCollection. + * Initializes the external child resource collection. */ - protected void initializeCollection() { + protected void cacheCollection() { this.childCollection.clear(); for (FluentModelTImpl childResource : this.listChildResources()) { this.childCollection.put(childResource.childResourceKey(), childResource); } } + @Override + protected final boolean clearAfterCommit() { + return false; + } + /** * Gets the list of external child resources. * diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalNonInlineChildResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesNonCachedImpl.java similarity index 74% rename from azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalNonInlineChildResourcesImpl.java rename to azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesNonCachedImpl.java index d86767a9240c3..1b951df88df3e 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalNonInlineChildResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesNonCachedImpl.java @@ -4,8 +4,14 @@ import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; /** - * Externalized child resource collection abstract implementation. + * Externalized non cache-able child resource collection abstract implementation. * (Internal use only) + *

+ * An external child resource collection is considered as non cache-able when it is not present as an inline + * property of its parent resource i.e. a separate call is required to fetch them. + * Consider using the cached version {@link ExternalChildResourcesCachedImpl} if the external child resources + * present in the parent payload, in case of update this can save addition GET operation required before the + * child resource PUT if PATCH is not supported. * * @param the implementation of {@param FluentModelT} * @param the fluent model type of the child resource @@ -13,7 +19,7 @@ * @param the parent Azure resource impl class type that implements {@link ParentT} * @param the parent interface */ -public class ExternalNonInlineChildResourcesImpl< +public abstract class ExternalChildResourcesNonCachedImpl< FluentModelTImpl extends ExternalChildResourceImpl, FluentModelT extends ExternalChildResource, InnerModelT, @@ -26,7 +32,7 @@ public class ExternalNonInlineChildResourcesImpl< * @param parent the parent Azure resource * @param childResourceName the child resource name */ - protected ExternalNonInlineChildResourcesImpl(ParentImplT parent, String childResourceName) { + protected ExternalChildResourcesNonCachedImpl(ParentImplT parent, String childResourceName) { super(parent, childResourceName); } @@ -36,7 +42,7 @@ protected ExternalNonInlineChildResourcesImpl(ParentImplT parent, String childRe * @param model the model to track create changes * @return the external child resource prepared for create */ - protected FluentModelTImpl prepareDefine(FluentModelTImpl model) { + protected final FluentModelTImpl prepareDefine(FluentModelTImpl model) { FluentModelTImpl childResource = find(model.childResourceKey()); if (childResource != null) { throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); @@ -52,7 +58,7 @@ protected FluentModelTImpl prepareDefine(FluentModelTImpl model) { * @param model the model to track update changes * @return the external child resource prepared for update */ - protected FluentModelTImpl prepareUpdate(FluentModelTImpl model) { + protected final FluentModelTImpl prepareUpdate(FluentModelTImpl model) { FluentModelTImpl childResource = find(model.childResourceKey()); if (childResource != null) { throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); @@ -67,7 +73,7 @@ protected FluentModelTImpl prepareUpdate(FluentModelTImpl model) { * * @param model the model representing child resource to remove */ - protected void prepareRemove(FluentModelTImpl model) { + protected final void prepareRemove(FluentModelTImpl model) { FluentModelTImpl childResource = find(model.childResourceKey()); if (childResource != null) { throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); @@ -76,7 +82,12 @@ protected void prepareRemove(FluentModelTImpl model) { this.childCollection.put(model.childResourceKey(), childResource); } + @Override + protected final boolean clearAfterCommit() { + return true; + } + private String pendingOperationMessage(String name, String key) { - return "There is already an operation pending on a child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")'"; + return "There is already an operation pending on the child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")'"; } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java index 6971fe3ea0ba9..4f6c82166cc1c 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/ExternalChildResourceImpl.java @@ -8,7 +8,7 @@ * Inorder to be eligible for an external child resource following criteria must be satisfied: * 1. It's is always associated with a parent resource and has no existence without parent * i.e. if you delete parent then child resource will be deleted automatically. - * 2. Parent will contain collection of child resources. this is not a hard requirement. + * 2. Parent may or may not contain collection of child resources (i.e. as inline collection property). * 3. It's has an ID and can be created, updated, fetched and deleted independent of the parent * i.e. CRUD on child resource does not require CRUD on the parent * (Internal use only) diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletsImpl.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletsImpl.java index 94b110bca0ab5..2779efd42cdbf 100644 --- a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletsImpl.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/childresource/PulletsImpl.java @@ -1,13 +1,13 @@ package com.microsoft.azure.management.resources.childresource; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesCachedImpl; import java.util.ArrayList; import java.util.List; -class PulletsImpl extends ExternalChildResourcesImpl { +class PulletsImpl extends ExternalChildResourcesCachedImpl { PulletsImpl(ChickenImpl parent) { super(parent, "Pullet"); - initializeCollection(); + cacheCollection(); } public PulletImpl define(String name) { diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java index 1fd1cf13dcec5..de6d419fe3aef 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java @@ -5,7 +5,7 @@ */ package com.microsoft.azure.management.trafficmanager.implementation; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesCachedImpl; import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; import com.microsoft.azure.management.trafficmanager.TrafficManagerEndpoint; import com.microsoft.azure.management.trafficmanager.EndpointType; @@ -23,11 +23,11 @@ * Represents an endpoint collection associated with a traffic manager profile. */ class TrafficManagerEndpointsImpl extends - ExternalChildResourcesImpl { + ExternalChildResourcesCachedImpl { private final EndpointsInner client; /** @@ -39,7 +39,7 @@ class TrafficManagerEndpointsImpl extends TrafficManagerEndpointsImpl(EndpointsInner client, TrafficManagerProfileImpl parent) { super(parent, "Endpoint"); this.client = client; - this.initializeCollection(); + this.cacheCollection(); } /** From 7397b5b6c40e57815c7e1c92197d3026415ff1df Mon Sep 17 00:00:00 2001 From: anuchan Date: Sat, 5 Nov 2016 13:19:42 -0700 Subject: [PATCH 20/27] Revert Resource.java changes --- .../fluentcore/arm/models/Resource.java | 59 +++++++++++++--- .../fluentcore/arm/models/Taggable.java | 67 ------------------- 2 files changed, 50 insertions(+), 76 deletions(-) delete mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Taggable.java diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java index d158c44f6227c..c2eab0339fe7f 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java @@ -10,15 +10,16 @@ import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.model.Indexable; +import java.util.Map; + /** -* Base interfaces for fluent resources. -*/ + * Base interfaces for fluent resources. + */ @LangDefinition() public interface Resource extends - Indexable, - HasId, - HasName, - Taggable { + Indexable, + HasId, + HasName { /** * @return the type of the resource @@ -35,6 +36,11 @@ public interface Resource extends */ Region region(); + /** + * @return the tags for the resource + */ + Map tags(); + /** * A resource definition allowing a location be selected for the resource. * @@ -63,7 +69,21 @@ interface DefinitionWithRegion { * @param the type of the next stage resource definition */ @LangDefinition(ContainerName = "Resource.Definition", ContainerFileName = "IDefinition") - interface DefinitionWithTags extends Taggable.DefinitionWithTags { + interface DefinitionWithTags { + /** + * Specifies tags for the resource as a {@link Map}. + * @param tags a {@link Map} of tags + * @return the next stage of the resource definition + */ + T withTags(Map tags); + + /** + * Adds a tag to the resource. + * @param key the key for the tag + * @param value the value for the tag + * @return the next stage of the resource definition + */ + T withTag(String key, String value); } /** @@ -72,6 +92,27 @@ interface DefinitionWithTags extends Taggable.DefinitionWithTags { * @param the type of the next stage resource update */ @LangDefinition(ContainerName = "Resource.Update", ContainerFileName = "IUpdate") - interface UpdateWithTags extends Taggable.UpdateWithTags { + interface UpdateWithTags { + /** + * Specifies tags for the resource as a {@link Map}. + * @param tags a {@link Map} of tags + * @return the next stage of the resource update + */ + T withTags(Map tags); + + /** + * Adds a tag to the resource. + * @param key the key for the tag + * @param value the value for the tag + * @return the next stage of the resource update + */ + T withTag(String key, String value); + + /** + * Removes a tag from the resource. + * @param key the key of the tag to remove + * @return the next stage of the resource update + */ + T withoutTag(String key); } -} +} \ No newline at end of file diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Taggable.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Taggable.java deleted file mode 100644 index 0085f4f1688ca..0000000000000 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Taggable.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.microsoft.azure.management.resources.fluentcore.arm.models; - -import com.microsoft.azure.management.apigeneration.Fluent; - -import java.util.Map; - -/** - * An interface representing a resource that has tags. - */ -@Fluent -public interface Taggable { - /** - * @return the tags associated with the resource - */ - Map tags(); - - /** - * A resource definition allowing tags to be modified for the resource. - * - * @param the type of the next stage resource definition - */ - interface DefinitionWithTags { - /** - * Specifies tags for the resource as a {@link Map}. - * @param tags a {@link Map} of tags - * @return the next stage of the resource definition - */ - T withTags(Map tags); - - /** - * Adds a tag to the resource. - * @param key the key for the tag - * @param value the value for the tag - * @return the next stage of the resource definition - */ - T withTag(String key, String value); - } - - /** - * An update allowing tags to be modified for the resource. - * - * @param the type of the next stage resource update - */ - interface UpdateWithTags { - /** - * Specifies tags for the resource as a {@link Map}. - * @param tags a {@link Map} of tags - * @return the next stage of the resource update - */ - T withTags(Map tags); - - /** - * Adds a tag to the resource. - * @param key the key for the tag - * @param value the value for the tag - * @return the next stage of the resource update - */ - T withTag(String key, String value); - - /** - * Removes a tag from the resource. - * @param key the key of the tag to remove - * @return the next stage of the resource update - */ - T withoutTag(String key); - } -} From 1bcabeefbf58ab866b6310e4f10e5e5c92669d2f Mon Sep 17 00:00:00 2001 From: anuchan Date: Sun, 6 Nov 2016 15:01:33 -0800 Subject: [PATCH 21/27] Setting default record set ttl and adding unit test --- .../azure/management/dns/DnsRecordSet.java | 2 +- .../dns/implementation/DnsRecordSetsImpl.java | 24 +- .../dns/implementation/DnsZoneManager.java | 4 +- .../dns/implementation/DnsZonesImpl.java | 18 +- .../ExternalChildResourcesNonCachedImpl.java | 16 +- .../com/microsoft/azure/management/Azure.java | 10 + .../azure/management/AzureTests.java | 6 + .../microsoft/azure/management/TestDns.java | 212 ++++++++++++++++++ .../azure/management/TestTrafficManager.java | 2 +- 9 files changed, 271 insertions(+), 23 deletions(-) create mode 100644 azure/src/test/java/com/microsoft/azure/management/TestDns.java diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index 13caff52a8b46..a36706efdd17f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -144,7 +144,7 @@ interface WithMxRecordMailExchange { * @param priority the priority for the mail exchange host, lower the value higher the priority * @return the next stage of the record set definition */ - WithMxRecordMailExchangeOrAttachable withMailExchange(String mailExchangeHostName, int priority); + WithMxRecordMailExchangeOrAttachable withMailExchange(String mailExchangeHostName, int priority); } /** diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java index fc082ca249efd..68d0987eab911 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetsImpl.java @@ -14,6 +14,10 @@ class DnsRecordSetsImpl extends DnsZoneImpl, DnsZone> { private final RecordSetsInner client; + /** + * The default record set ttl in seconds. + */ + private final long defaultTtlInSeconds = 3600; /** * Creates new DnsRecordSetsImpl. @@ -27,37 +31,37 @@ class DnsRecordSetsImpl extends } DnsRecordSetImpl defineARecordSet(String name) { - return prepareDefine(ARecordSetImpl.newRecordSet(name, this.parent(), this.client)); + return setDefaults(prepareDefine(ARecordSetImpl.newRecordSet(name, this.parent(), this.client))); } DnsRecordSetImpl defineAaaaRecordSet(String name) { - return prepareDefine(AaaaRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + return setDefaults(prepareDefine(AaaaRecordSetImpl.newRecordSet(name, this.parent(), this.client))); } void withCnameRecordSet(String name, String alias) { CnameRecordSetImpl recordSet = CnameRecordSetImpl.newRecordSet(name, this.parent(), this.client); recordSet.inner().cnameRecord().withCname(alias); - prepareDefine(recordSet); + setDefaults(prepareDefine(recordSet.withTimeToLive(defaultTtlInSeconds))); } DnsRecordSetImpl defineMxRecordSet(String name) { - return prepareDefine(MxRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + return setDefaults(prepareDefine(MxRecordSetImpl.newRecordSet(name, this.parent(), this.client))); } DnsRecordSetImpl defineNsRecordSet(String name) { - return prepareDefine(NsRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + return setDefaults(prepareDefine(NsRecordSetImpl.newRecordSet(name, this.parent(), this.client))); } DnsRecordSetImpl definePtrRecordSet(String name) { - return prepareDefine(PtrRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + return setDefaults(prepareDefine(PtrRecordSetImpl.newRecordSet(name, this.parent(), this.client))); } DnsRecordSetImpl defineSrvRecordSet(String name) { - return prepareDefine(SrvRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + return setDefaults(prepareDefine(SrvRecordSetImpl.newRecordSet(name, this.parent(), this.client))); } DnsRecordSetImpl defineTxtRecordSet(String name) { - return prepareDefine(TxtRecordSetImpl.newRecordSet(name, this.parent(), this.client)); + return setDefaults(prepareDefine(TxtRecordSetImpl.newRecordSet(name, this.parent(), this.client))); } DnsRecordSetImpl updateARecordSet(String name) { @@ -127,4 +131,8 @@ void withoutTxtRecordSet(String name) { final void clearPendingOperations() { this.childCollection.clear(); } + + private DnsRecordSetImpl setDefaults(DnsRecordSetImpl recordSet) { + return recordSet.withTimeToLive(defaultTtlInSeconds); + } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java index 170ca666ee353..8efa9d7526d11 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java @@ -53,7 +53,7 @@ public static DnsZoneManager authenticate(RestClient restClient, String subscrip */ public interface Configurable extends AzureConfigurable { /** - * Creates an instance of DnsZoneManager that exposes traffic manager management API entry points. + * Creates an instance of DnsZoneManager that exposes Dns zone API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID @@ -81,7 +81,7 @@ private DnsZoneManager(RestClient restClient, String subscriptionId) { } /** - * @return entry point to Dns zone manager profile management + * @return entry point to Dns zone manager zone management */ public DnsZones zones() { if (this.zones == null) { diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZonesImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZonesImpl.java index 4612d57f3232f..4f715c01d45ff 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZonesImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZonesImpl.java @@ -5,6 +5,7 @@ import com.microsoft.azure.management.dns.DnsZones; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import rx.Observable; +import rx.functions.Func1; /** * Implementation of {@link DnsZones}. @@ -42,13 +43,18 @@ public DnsZone getByGroup(String groupName, String name) { @Override public Observable deleteByGroupAsync(String groupName, String name) { - this.innerCollection.deleteAsync(groupName, name); - return Observable.just(null); + return this.innerCollection.deleteAsync(groupName, name) + .map(new Func1() { + @Override + public Void call(ZoneDeleteResultInner zoneDeleteResultInner) { + return null; + } + }); } @Override public DnsZoneImpl define(String name) { - return wrapModel(name); + return setDefaults(wrapModel(name)); } @Override @@ -68,4 +74,10 @@ protected DnsZoneImpl wrapModel(ZoneInner inner) { this.recordSetsClient, this.myManager); } + + private DnsZoneImpl setDefaults(DnsZoneImpl dnsZone) { + // Zone location must be 'global' irrespective of region of the resource group it resides. + dnsZone.inner().withLocation("global"); + return dnsZone; + } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesNonCachedImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesNonCachedImpl.java index 1b951df88df3e..998b5ed835d5a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesNonCachedImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ExternalChildResourcesNonCachedImpl.java @@ -47,9 +47,9 @@ protected final FluentModelTImpl prepareDefine(FluentModelTImpl model) { if (childResource != null) { throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); } - childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeCreated); - this.childCollection.put(model.childResourceKey(), childResource); - return childResource; + model.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeCreated); + this.childCollection.put(model.childResourceKey(), model); + return model; } /** @@ -63,9 +63,9 @@ protected final FluentModelTImpl prepareUpdate(FluentModelTImpl model) { if (childResource != null) { throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); } - childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeUpdated); - this.childCollection.put(model.childResourceKey(), childResource); - return childResource; + model.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeUpdated); + this.childCollection.put(model.childResourceKey(), model); + return model; } /** @@ -78,8 +78,8 @@ protected final void prepareRemove(FluentModelTImpl model) { if (childResource != null) { throw new IllegalArgumentException(pendingOperationMessage(model.name(), model.childResourceKey())); } - childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeRemoved); - this.childCollection.put(model.childResourceKey(), childResource); + model.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeRemoved); + this.childCollection.put(model.childResourceKey(), model); } @Override diff --git a/azure/src/main/java/com/microsoft/azure/management/Azure.java b/azure/src/main/java/com/microsoft/azure/management/Azure.java index 4c563bad3d12a..29fad54cf8699 100644 --- a/azure/src/main/java/com/microsoft/azure/management/Azure.java +++ b/azure/src/main/java/com/microsoft/azure/management/Azure.java @@ -19,6 +19,8 @@ import com.microsoft.azure.management.compute.VirtualMachineScaleSets; import com.microsoft.azure.management.compute.VirtualMachines; import com.microsoft.azure.management.compute.implementation.ComputeManager; +import com.microsoft.azure.management.dns.DnsZones; +import com.microsoft.azure.management.dns.implementation.DnsZoneManager; import com.microsoft.azure.management.keyvault.Vaults; import com.microsoft.azure.management.keyvault.implementation.KeyVaultManager; import com.microsoft.azure.management.network.LoadBalancers; @@ -66,6 +68,7 @@ public final class Azure { private final BatchManager batchManager; private final TrafficManager trafficManager; private final RedisManager redisManager; + private final DnsZoneManager dnsZoneManager; private final String subscriptionId; /** @@ -270,6 +273,7 @@ private Azure(RestClient restClient, String subscriptionId, String tenantId) { this.batchManager = BatchManager.authenticate(restClient, subscriptionId); this.trafficManager = TrafficManager.authenticate(restClient, subscriptionId); this.redisManager = RedisManager.authenticate(restClient, subscriptionId); + this.dnsZoneManager = DnsZoneManager.authenticate(restClient, subscriptionId); this.subscriptionId = subscriptionId; } @@ -455,4 +459,10 @@ public RedisCaches redisCaches() { return redisManager.redisCaches(); } + /** + * @return entry point to managing Dns zones. + */ + public DnsZones dnsZones() { + return dnsZoneManager.zones(); + } } diff --git a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java index dfe835d1a437d..ad8ba424e3440 100644 --- a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java @@ -329,4 +329,10 @@ public void testTrafficManager() throws Exception { new TestTrafficManager(azure.resourceGroups(), azure.publicIpAddresses()) .runTest(azure.trafficManagerProfiles(), azure.resourceGroups()); } + + @Test + public void testDnsZones() throws Exception { + new TestDns() + .runTest(azure.dnsZones(), azure.resourceGroups()); + } } diff --git a/azure/src/test/java/com/microsoft/azure/management/TestDns.java b/azure/src/test/java/com/microsoft/azure/management/TestDns.java new file mode 100644 index 0000000000000..458eed38c557b --- /dev/null +++ b/azure/src/test/java/com/microsoft/azure/management/TestDns.java @@ -0,0 +1,212 @@ +package com.microsoft.azure.management; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.dns.ARecordSet; +import com.microsoft.azure.management.dns.AaaaRecordSet; +import com.microsoft.azure.management.dns.CnameRecordSet; +import com.microsoft.azure.management.dns.DnsZone; +import com.microsoft.azure.management.dns.DnsZones; +import com.microsoft.azure.management.dns.MxRecord; +import com.microsoft.azure.management.dns.MxRecordSet; +import com.microsoft.azure.management.dns.NsRecordSet; +import com.microsoft.azure.management.dns.PtrRecordSet; +import com.microsoft.azure.management.dns.SoaRecord; +import com.microsoft.azure.management.dns.SoaRecordSet; +import com.microsoft.azure.management.dns.SrvRecord; +import com.microsoft.azure.management.dns.SrvRecordSet; +import com.microsoft.azure.management.dns.TxtRecord; +import com.microsoft.azure.management.dns.TxtRecordSet; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; + +/** + * Test of Dns management. + */ +public class TestDns extends TestTemplate { + @Override + public DnsZone createResource(DnsZones dnsZones) throws Exception { + final Region region = Region.US_EAST; + final String groupName = "rg" + this.testId; + + DnsZone dnsZone = dnsZones.define("www.contoso.com") + .withNewResourceGroup(groupName, region) + .defineARecordSet("www") + .withIpv4Address("23.96.104.40") + .withIpv4Address("24.97.105.41") + .attach() + .defineAaaaRecordSet("www") + .withIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7334") + .withIpv6Address("2002:0db9:85a4:0000:0000:8a2e:0371:7335") + .attach() + .defineMxRecordSet("email") + .withMailExchange("mail.contoso-mail-exchange1.com", 1) + .withMailExchange("mail.contoso-mail-exchange2.com", 2) + .attach() + .defineNsRecordSet("partners") + .withNameServer("ns1-05.azure-dns.com") + .withNameServer("ns2-05.azure-dns.net") + .withNameServer("ns3-05.azure-dns.org") + .withNameServer("ns4-05.azure-dns.info") + .attach() + .defineTxtRecordSet("@") + .withText("windows-apps-verification=2ZzjfideIJFLFje83") + .attach() + .defineTxtRecordSet("www") + .withText("some info about www.contoso.com") + .attach() + .defineSrvRecordSet("_sip._tcp") + .withRecord("bigbox.contoso-service.com", 5060, 10, 60) + .withRecord("smallbox1.contoso-service.com", 5060, 10, 20) + .withRecord("smallbox2.contoso-service.com", 5060, 10, 20) + .withRecord("backupbox.contoso-service.com", 5060, 10, 0) + .attach() + .definePtrRecordSet("40") + .withTargetDomainName("www.contoso.com") + .withTargetDomainName("mail.contoso.com") + .attach() + .definePtrRecordSet("41") + .withTargetDomainName("www.contoso.com") + .withTargetDomainName("mail.contoso.com") + .attach() + .withCnameRecordSet("documents", "doc.contoso.com") + .withCnameRecordSet("userguide", "doc.contoso.com") + .withTag("a", "aa") + .withTag("b", "bb") + .create(); + return dnsZone; + } + + @Override + public DnsZone updateResource(DnsZone dnsZone) throws Exception { + return dnsZone; + } + + @Override + public void print(DnsZone dnsZone) { + StringBuilder info = new StringBuilder(); + info.append("Dns Zone: ").append(dnsZone.id()) + .append("\n\tName (Top level domain): ").append(dnsZone.name()) + .append("\n\tResource group: ").append(dnsZone.resourceGroupName()) + .append("\n\tRegion: ").append(dnsZone.regionName()) + .append("\n\tTags: ").append(dnsZone.tags()) + .append("\n\tName servers:"); + for (String nameServer: dnsZone.nameServers()) { + info.append("\n\t\t").append(nameServer); + } + SoaRecordSet soaRecordSet = dnsZone.getSoaRecordSet(); + SoaRecord soaRecord = soaRecordSet.record(); + info.append("\n\tSOA Record:") + .append("\n\t\tHost:").append(soaRecord.host()) + .append("\n\t\tEmail:").append(soaRecord.email()) + .append("\n\t\tExpire time (seconds):").append(soaRecord.expireTime()) + .append("\n\t\tRefresh time (seconds):").append(soaRecord.refreshTime()) + .append("\n\t\tRetry time (seconds):").append(soaRecord.retryTime()) + .append("\n\t\tNegative response cache ttl (seconds):").append(soaRecord.minimumTtl()) + .append("\n\t\tTtl (seconds):").append(soaRecordSet.timeToLive()); + + PagedList aRecordSets = dnsZone.aRecordSets().list(); + info.append("\n\tA Record sets:"); + for (ARecordSet aRecordSet : aRecordSets) { + info.append("\n\t\tId: ").append(aRecordSet.id()) + .append("\n\t\tName: ").append(aRecordSet.name()) + .append("\n\t\tTtl (seconds): ").append(aRecordSet.timeToLive()) + .append("\n\t\tIp v4 addresses: "); + for (String ipAddress : aRecordSet.ipv4Addresses()) { + info.append("\n\t\t\t").append(ipAddress); + } + } + + PagedList aaaaRecordSets = dnsZone.aaaaRecordSets().list(); + info.append("\n\tAAAA Record sets:"); + for (AaaaRecordSet aaaaRecordSet : aaaaRecordSets) { + info.append("\n\t\tId: ").append(aaaaRecordSet.id()) + .append("\n\t\tName: ").append(aaaaRecordSet.name()) + .append("\n\t\tTtl (seconds): ").append(aaaaRecordSet.timeToLive()) + .append("\n\t\tIp v6 addresses: "); + for (String ipAddress : aaaaRecordSet.ipv6Addresses()) { + info.append("\n\t\t\t").append(ipAddress); + } + } + + PagedList cnameRecordSets = dnsZone.cnameRecordSets().list(); + info.append("\n\tCNAME Record sets:"); + for (CnameRecordSet cnameRecordSet : cnameRecordSets) { + info.append("\n\t\tId: ").append(cnameRecordSet.id()) + .append("\n\t\tName: ").append(cnameRecordSet.name()) + .append("\n\t\tTtl (seconds): ").append(cnameRecordSet.timeToLive()) + .append("\n\t\tCanonical name: ").append(cnameRecordSet.canonicalName()); + } + + PagedList mxRecordSets = dnsZone.mxRecordSets().list(); + info.append("\n\tMX Record sets:"); + for (MxRecordSet mxRecordSet : mxRecordSets) { + info.append("\n\t\tId: ").append(mxRecordSet.id()) + .append("\n\t\tName: ").append(mxRecordSet.name()) + .append("\n\t\tTtl (seconds): ").append(mxRecordSet.timeToLive()) + .append("\n\t\tRecords: "); + for (MxRecord mxRecord : mxRecordSet.records()) { + info.append("\n\t\t\tExchange server, Preference: ") + .append(mxRecord.exchange()) + .append(" ") + .append(mxRecord.preference()); + } + } + + PagedList nsRecordSets = dnsZone.nsRecordSets().list(); + info.append("\n\tNS Record sets:"); + for (NsRecordSet nsRecordSet : nsRecordSets) { + info.append("\n\t\tId: ").append(nsRecordSet.id()) + .append("\n\t\tName: ").append(nsRecordSet.name()) + .append("\n\t\tTtl (seconds): ").append(nsRecordSet.timeToLive()) + .append("\n\t\tName servers: "); + for (String nameServer : nsRecordSet.nameServers()) { + info.append("\n\t\t\t").append(nameServer); + } + } + + PagedList ptrRecordSets = dnsZone.ptrRecordSets().list(); + info.append("\n\tPTR Record sets:"); + for (PtrRecordSet ptrRecordSet : ptrRecordSets) { + info.append("\n\t\tId: ").append(ptrRecordSet.id()) + .append("\n\t\tName: ").append(ptrRecordSet.name()) + .append("\n\t\tTtl (seconds): ").append(ptrRecordSet.timeToLive()) + .append("\n\t\tTarget domain names: "); + for (String domainNames : ptrRecordSet.targetDomainNames()) { + info.append("\n\t\t\t").append(domainNames); + } + } + + PagedList srvRecordSets = dnsZone.srvRecordSets().list(); + info.append("\n\tSRV Record sets:"); + for (SrvRecordSet srvRecordSet : srvRecordSets) { + info.append("\n\t\tId: ").append(srvRecordSet.id()) + .append("\n\t\tName: ").append(srvRecordSet.name()) + .append("\n\t\tTtl (seconds): ").append(srvRecordSet.timeToLive()) + .append("\n\t\tRecords: "); + for (SrvRecord srvRecord : srvRecordSet.records()) { + info.append("\n\t\t\tTarget, Port, Priority, Weight: ") + .append(srvRecord.target()) + .append(", ") + .append(srvRecord.port()) + .append(", ") + .append(srvRecord.priority()) + .append(", ") + .append(srvRecord.weight()); + } + } + + PagedList txtRecordSets = dnsZone.txtRecordSets().list(); + info.append("\n\tTXT Record sets:"); + for (TxtRecordSet txtRecordSet : txtRecordSets) { + info.append("\n\t\tId: ").append(txtRecordSet.id()) + .append("\n\t\tName: ").append(txtRecordSet.name()) + .append("\n\t\tTtl (seconds): ").append(txtRecordSet.timeToLive()) + .append("\n\t\tRecords: "); + for (TxtRecord txtRecord : txtRecordSet.records()) { + if (txtRecord.value().size() > 0) { + info.append("\n\t\t\tValue: ").append(txtRecord.value().get(0)); + } + } + } + System.out.println(info.toString()); + } +} diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java index 2addd76f404cc..46f84c54e0c46 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java @@ -18,7 +18,7 @@ import java.util.Map; /** - * Test of virtual network management. + * Test of traffic manager management. */ public class TestTrafficManager extends TestTemplate { From c8167e9b7a262e585c31791ea3b4e50c890d0d30 Mon Sep 17 00:00:00 2001 From: anuchan Date: Sun, 6 Nov 2016 15:13:02 -0800 Subject: [PATCH 22/27] Some cleanup --- .../azure/management/dns/DnsRecordSets.java | 12 ------------ .../microsoft/azure/management/dns/NsRecordSet.java | 3 +++ .../dns/implementation/CnameRecordSetImpl.java | 2 +- .../dns/implementation/DnsRecordSetImpl.java | 4 ++-- .../dns/implementation/DnsZoneManager.java | 2 +- .../dns/implementation/TxtRecordSetImpl.java | 1 - 6 files changed, 7 insertions(+), 17 deletions(-) delete mode 100644 azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java deleted file mode 100644 index 4a7f3ab06afc8..0000000000000 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSets.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.microsoft.azure.management.dns; - -import com.microsoft.azure.management.apigeneration.Fluent; - -/** - * Base interface for various Dns record sets. - * - * @param the type of the record set - */ -@Fluent -public interface DnsRecordSets { -} diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java index 49003cde7742f..a6dec486ae60b 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/NsRecordSet.java @@ -2,6 +2,9 @@ import java.util.List; +/** + * An immutable client-side representation of an Ns (name server) record set in Azure Dns Zone. + */ public interface NsRecordSet extends DnsRecordSet { /** * @return the name server names of Ns (name server) records in this record set diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java index bef49261e76ec..e6c7fd560d575 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/CnameRecordSetImpl.java @@ -25,7 +25,7 @@ static CnameRecordSetImpl newRecordSet(final String name, final DnsZoneImpl pare @Override public String canonicalName() { - if ( this.inner().cnameRecord() != null) { + if (this.inner().cnameRecord() != null) { return this.inner().cnameRecord().cname(); } return null; diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index 188da0e334e8d..2becb9a6cb087 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -308,7 +308,7 @@ public DnsRecordSet call(RecordSetInner inner) { private RecordSetInner prepare(RecordSetInner resource) { if (this.recordSetRemoveInfo.metadata().size() > 0) { if (resource.metadata() != null) { - for(String key : this.recordSetRemoveInfo.metadata().keySet()) { + for (String key : this.recordSetRemoveInfo.metadata().keySet()) { resource.metadata().remove(key); } } @@ -318,7 +318,7 @@ private RecordSetInner prepare(RecordSetInner resource) { if (resource.metadata() == null) { resource.withMetadata(new LinkedHashMap()); } - for(Map.Entry keyVal : this.inner().metadata().entrySet()) { + for (Map.Entry keyVal : this.inner().metadata().entrySet()) { resource.metadata().put(keyVal.getKey(), keyVal.getValue()); } this.inner().metadata().clear(); diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java index 8efa9d7526d11..8c555f99503ef 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsZoneManager.java @@ -10,7 +10,7 @@ /** * Entry point to Azure Dns zone manager management. */ -public class DnsZoneManager extends Manager { +public final class DnsZoneManager extends Manager { // Collections private DnsZones zones; diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java index 46bd7170ad6c0..5ce58aaedb3bf 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/TxtRecordSetImpl.java @@ -1,7 +1,6 @@ package com.microsoft.azure.management.dns.implementation; import com.microsoft.azure.management.dns.RecordType; -import com.microsoft.azure.management.dns.SrvRecord; import com.microsoft.azure.management.dns.TxtRecord; import com.microsoft.azure.management.dns.TxtRecordSet; From f35aa33269f8b77f9aea29576f80a6111ba17872 Mon Sep 17 00:00:00 2001 From: anuchan Date: Sun, 6 Nov 2016 20:26:31 -0800 Subject: [PATCH 23/27] Update unit tests and fixes --- .../azure/management/dns/DnsRecordSet.java | 2 +- .../dns/implementation/DnsRecordSetImpl.java | 11 +- .../dns/implementation/MxRecordSetImpl.java | 2 +- .../dns/implementation/NsRecordSetImpl.java | 2 +- .../dns/implementation/SrvRecordSetImpl.java | 6 +- .../microsoft/azure/management/TestDns.java | 142 ++++++++++++++++++ 6 files changed, 158 insertions(+), 7 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index a36706efdd17f..8ddb8fc19cee2 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -457,7 +457,7 @@ interface WithMxRecordMailExchange { * @param priority the priority for the mail exchange host, lower the value higher the priority * @return the next stage of the record set definition */ - WithMxRecordMailExchangeOrAttachable withMailExchange(String mailExchangeHostName, int priority); + WithMxRecordMailExchangeOrAttachable withMailExchange(String mailExchangeHostName, int priority); } /** diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index 2becb9a6cb087..a1e2ddcef92dd 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -230,6 +230,9 @@ public DnsRecordSetImpl withTimeToLive(long ttlInSeconds) { @Override public DnsRecordSetImpl withTag(String key, String value) { + if (this.inner().metadata() == null) { + this.inner().withMetadata(new LinkedHashMap()); + } this.inner().metadata().put(key, value); return this; } @@ -314,7 +317,7 @@ private RecordSetInner prepare(RecordSetInner resource) { } this.recordSetRemoveInfo.metadata().clear(); } - if (this.inner().metadata().size() > 0) { + if (this.inner().metadata() != null && this.inner().metadata().size() > 0) { if (resource.metadata() == null) { resource.withMetadata(new LinkedHashMap()); } @@ -323,6 +326,12 @@ private RecordSetInner prepare(RecordSetInner resource) { } this.inner().metadata().clear(); } + + if (this.inner().tTL() != null) { + resource.withTTL(this.inner().tTL()); + this.inner().withTTL(null); + } + return prepareForUpdate(resource); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java index a37ee36718d59..65bb597296b39 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -50,7 +50,7 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (resource.mxRecords() != null) { for (MxRecord recordToRemove : this.recordSetRemoveInfo.mxRecords()) { for (MxRecord record : resource.mxRecords()) { - if (record.exchange().equalsIgnoreCase(recordToRemove.exchange()) && record.preference() == recordToRemove.preference()) { + if (record.exchange().equalsIgnoreCase(recordToRemove.exchange()) && (record.preference() == recordToRemove.preference())) { resource.mxRecords().remove(record); break; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java index 0a70130af7190..df49221f83b05 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/NsRecordSetImpl.java @@ -30,7 +30,7 @@ static NsRecordSetImpl newRecordSet(final String name, final DnsZoneImpl parent, @Override public List nameServers() { List nameServers = new ArrayList<>(); - if (this.inner().aaaaRecords() != null) { + if (this.inner().nsRecords() != null) { for (NsRecord nsRecord : this.inner().nsRecords()) { nameServers.add(nsRecord.nsdname()); } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java index bef64cf7cfbc4..d971f2d267059 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java @@ -51,9 +51,9 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { for (SrvRecord recordToRemove : this.recordSetRemoveInfo.srvRecords()) { for (SrvRecord record : resource.srvRecords()) { if (record.target().equalsIgnoreCase(recordToRemove.target()) - && record.port() == recordToRemove.port() - && record.weight() == recordToRemove.weight() - && record.priority() == recordToRemove.priority()) { + && (record.port() == recordToRemove.port()) + && (record.weight() == recordToRemove.weight()) + && (record.priority() == recordToRemove.priority())) { resource.srvRecords().remove(record); break; } diff --git a/azure/src/test/java/com/microsoft/azure/management/TestDns.java b/azure/src/test/java/com/microsoft/azure/management/TestDns.java index 458eed38c557b..3076f1500b976 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestDns.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestDns.java @@ -17,6 +17,7 @@ import com.microsoft.azure.management.dns.TxtRecord; import com.microsoft.azure.management.dns.TxtRecordSet; import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import org.junit.Assert; /** * Test of Dns management. @@ -32,6 +33,7 @@ public DnsZone createResource(DnsZones dnsZones) throws Exception { .defineARecordSet("www") .withIpv4Address("23.96.104.40") .withIpv4Address("24.97.105.41") + .withTimeToLive(7200) // Overwrite default 3600 seconds .attach() .defineAaaaRecordSet("www") .withIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7334") @@ -72,11 +74,151 @@ public DnsZone createResource(DnsZones dnsZones) throws Exception { .withTag("a", "aa") .withTag("b", "bb") .create(); + + // Check Dns zone properties + Assert.assertTrue(dnsZone.name().startsWith("www.contoso.com")); + Assert.assertTrue(dnsZone.nameServers().size() > 0); // Default '@' name servers + Assert.assertTrue(dnsZone.tags().size() == 2); + + // Check SOA record - external child resource (created by default) + SoaRecordSet soaRecordSet = dnsZone.getSoaRecordSet(); + Assert.assertTrue(soaRecordSet.name().startsWith("@")); + SoaRecord soaRecord = soaRecordSet.record(); + Assert.assertNotNull(soaRecord); + + // Check explicitly created external child resources [A, AAAA, MX, NS, TXT, SRV, PTR, CNAME] + // + + // Check A records + PagedList aRecordSets = dnsZone.aRecordSets().list(); + Assert.assertTrue(aRecordSets.size() == 1); + Assert.assertTrue(aRecordSets.get(0).timeToLive() == 7200); + + // Check AAAA records + PagedList aaaaRecordSets = dnsZone.aaaaRecordSets().list(); + Assert.assertTrue(aaaaRecordSets.size() == 1); + Assert.assertTrue(aaaaRecordSets.get(0).name().startsWith("www")); + Assert.assertTrue(aaaaRecordSets.get(0).ipv6Addresses().size() == 2); + + // Check MX records + PagedList mxRecordSets = dnsZone.mxRecordSets().list(); + Assert.assertTrue(mxRecordSets.size() == 1); + MxRecordSet mxRecordSet = mxRecordSets.get(0); + Assert.assertNotNull(mxRecordSet); + Assert.assertTrue(mxRecordSet.name().startsWith("email")); + Assert.assertTrue(mxRecordSet.records().size() == 2); + for (MxRecord mxRecord : mxRecordSet.records()) { + Assert.assertTrue(mxRecord.exchange().startsWith("mail.contoso-mail-exchange1.com") + || mxRecord.exchange().startsWith("mail.contoso-mail-exchange2.com")); + Assert.assertTrue(mxRecord.preference() == 1 + || mxRecord.preference() == 2); + } + + // Check NS records + PagedList nsRecordSets = dnsZone.nsRecordSets().list(); + Assert.assertTrue(nsRecordSets.size() == 2); // One created above with name 'partners' + the default '@' + + // Check TXT records + PagedList txtRecordSets = dnsZone.txtRecordSets().list(); + Assert.assertTrue(txtRecordSets.size() == 2); + + // Check SRV records + PagedList srvRecordSets = dnsZone.srvRecordSets().list(); + Assert.assertTrue(srvRecordSets.size() == 1); + + // Check PTR records + PagedList ptrRecordSets = dnsZone.ptrRecordSets().list(); + Assert.assertTrue(ptrRecordSets.size() == 2); + + // Check CNAME records + PagedList cnameRecordSets = dnsZone.cnameRecordSets().list(); + Assert.assertTrue(cnameRecordSets.size() == 2); return dnsZone; } @Override public DnsZone updateResource(DnsZone dnsZone) throws Exception { + dnsZone.update() + .withoutTxtRecordSet("www") + .withoutCnameRecordSet("userguide") + .withCnameRecordSet("help", "doc.contoso.com") + .updateNsRecordSet("partners") + .withoutNameServer("ns4-05.azure-dns.info") + .withNameServer("ns4-06.azure-dns.info") + .parent() + .updateARecordSet("www") + .withoutIpv4Address("23.96.104.40") + .withIpv4Address("23.96.104.42") + .parent() + .updateSrvRecordSet("_sip._tcp") + .withoutRecord("bigbox.contoso-service.com", 5060, 10, 60) + .withRecord("mainbox.contoso-service.com", 5060, 10, 60) + .parent() + .updateSoaRecord() + .withNegativeResponseCachingTimeToLiveInSeconds(600) + .withTimeToLive(7200) + .parent() + .defineMxRecordSet("email-internal") + .withMailExchange("mail.contoso-mail-exchange1.com", 1) + .withMailExchange("mail.contoso-mail-exchange2.com", 2) + .attach() + .apply(); + + // Check TXT records + PagedList txtRecordSets = dnsZone.txtRecordSets().list(); + Assert.assertEquals(txtRecordSets.size(), 1); + + // Check CNAME records + PagedList cnameRecordSets = dnsZone.cnameRecordSets().list(); + Assert.assertEquals(cnameRecordSets.size(), 2); + for (CnameRecordSet cnameRecordSet : cnameRecordSets) { + Assert.assertTrue(cnameRecordSet.canonicalName().startsWith("doc.contoso.com")); + Assert.assertTrue(cnameRecordSet.name().startsWith("documents") || cnameRecordSet.name().startsWith("help")); + } + + // Check NS records + PagedList nsRecordSets = dnsZone.nsRecordSets().list(); + Assert.assertTrue(nsRecordSets.size() == 2); // One created above with name 'partners' + the default '@' + for (NsRecordSet nsRecordSet : nsRecordSets) { + Assert.assertTrue(nsRecordSet.name().startsWith("partners") || nsRecordSet.name().startsWith("@")); + if (nsRecordSet.name().startsWith("partners")) { + Assert.assertEquals(nsRecordSet.nameServers().size(), 4); + for (String nameServer : nsRecordSet.nameServers()) { + Assert.assertFalse(nameServer.startsWith("ns4-05.azure-dns.info")); + } + } + } + + // Check A records + PagedList aRecordSets = dnsZone.aRecordSets().list(); + Assert.assertEquals(aRecordSets.size(), 1); + ARecordSet aRecordSet = aRecordSets.get(0); + Assert.assertEquals(aRecordSet.ipv4Addresses().size(), 2); + for (String ipV4Address : aRecordSet.ipv4Addresses()) { + Assert.assertFalse(ipV4Address.startsWith("23.96.104.40")); + } + + // Check SRV records + PagedList srvRecordSets = dnsZone.srvRecordSets().list(); + Assert.assertTrue(srvRecordSets.size() == 1); + SrvRecordSet srvRecordSet = srvRecordSets.get(0); + Assert.assertTrue(srvRecordSet.records().size() == 4); + for (SrvRecord srvRecord : srvRecordSet.records()) { + Assert.assertFalse(srvRecord.target().startsWith("bigbox.contoso-service.com")); + } + + // Check SOA Records + SoaRecordSet soaRecordSet = dnsZone.getSoaRecordSet(); + Assert.assertTrue(soaRecordSet.name().startsWith("@")); + SoaRecord soaRecord = soaRecordSet.record(); + Assert.assertNotNull(soaRecord); + Assert.assertEquals(soaRecord.minimumTtl(), Long.valueOf(600)); + Assert.assertTrue(soaRecordSet.timeToLive() == 7200); + + // Check MX records + PagedList mxRecordSets = dnsZone.mxRecordSets().list(); + Assert.assertTrue(mxRecordSets.size() == 2); + return dnsZone; } From 51db91a07ce198df3e43ab7b9e00b60884100da0 Mon Sep 17 00:00:00 2001 From: anuchan Date: Mon, 7 Nov 2016 08:18:32 -0800 Subject: [PATCH 24/27] covering few more cases in unit test --- .../dns/implementation/MxRecordSetImpl.java | 3 ++- .../dns/implementation/SrvRecordSetImpl.java | 6 +++--- .../microsoft/azure/management/TestDns.java | 19 +++++++++++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java index 65bb597296b39..43bee9ca95dbe 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/MxRecordSetImpl.java @@ -50,7 +50,8 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { if (resource.mxRecords() != null) { for (MxRecord recordToRemove : this.recordSetRemoveInfo.mxRecords()) { for (MxRecord record : resource.mxRecords()) { - if (record.exchange().equalsIgnoreCase(recordToRemove.exchange()) && (record.preference() == recordToRemove.preference())) { + if (record.exchange().equalsIgnoreCase(recordToRemove.exchange()) + && (record.preference() == recordToRemove.preference())) { resource.mxRecords().remove(record); break; } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java index d971f2d267059..558d2c7a84285 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/SrvRecordSetImpl.java @@ -51,9 +51,9 @@ protected RecordSetInner prepareForUpdate(RecordSetInner resource) { for (SrvRecord recordToRemove : this.recordSetRemoveInfo.srvRecords()) { for (SrvRecord record : resource.srvRecords()) { if (record.target().equalsIgnoreCase(recordToRemove.target()) - && (record.port() == recordToRemove.port()) - && (record.weight() == recordToRemove.weight()) - && (record.priority() == recordToRemove.priority())) { + && (record.port().intValue() == recordToRemove.port().intValue()) + && (record.weight().intValue() == recordToRemove.weight().intValue()) + && (record.priority().intValue() == recordToRemove.priority().intValue())) { resource.srvRecords().remove(record); break; } diff --git a/azure/src/test/java/com/microsoft/azure/management/TestDns.java b/azure/src/test/java/com/microsoft/azure/management/TestDns.java index 3076f1500b976..b30fefa69cbb4 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestDns.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestDns.java @@ -27,8 +27,9 @@ public class TestDns extends TestTemplate { public DnsZone createResource(DnsZones dnsZones) throws Exception { final Region region = Region.US_EAST; final String groupName = "rg" + this.testId; + final String topLevelDomain = "www.contoso" + this.testId + ".com"; - DnsZone dnsZone = dnsZones.define("www.contoso.com") + DnsZone dnsZone = dnsZones.define(topLevelDomain) .withNewResourceGroup(groupName, region) .defineARecordSet("www") .withIpv4Address("23.96.104.40") @@ -76,7 +77,7 @@ public DnsZone createResource(DnsZones dnsZones) throws Exception { .create(); // Check Dns zone properties - Assert.assertTrue(dnsZone.name().startsWith("www.contoso.com")); + Assert.assertTrue(dnsZone.name().startsWith(topLevelDomain)); Assert.assertTrue(dnsZone.nameServers().size() > 0); // Default '@' name servers Assert.assertTrue(dnsZone.tags().size() == 2); @@ -219,6 +220,20 @@ public DnsZone updateResource(DnsZone dnsZone) throws Exception { PagedList mxRecordSets = dnsZone.mxRecordSets().list(); Assert.assertTrue(mxRecordSets.size() == 2); + dnsZone.update() + .updateMxRecordSet("email") + .withoutMailExchange("mail.contoso-mail-exchange2.com", 2) + .withTag("c", "cc") + .parent() + .withTag("d", "dd") + .apply(); + + Assert.assertTrue(dnsZone.tags().size() == 3); + // Check "mail" MX record + MxRecordSet mxRecordSet = dnsZone.mxRecordSets().getByName("email"); + Assert.assertTrue(mxRecordSet.records().size() == 1); + Assert.assertTrue(mxRecordSet.records().get(0).exchange().startsWith("mail.contoso-mail-exchange1.com")); + return dnsZone; } From 4c0136a2e9848a4326acb8c3791d13dc7afa8d7e Mon Sep 17 00:00:00 2001 From: anuchan Date: Mon, 7 Nov 2016 10:45:49 -0800 Subject: [PATCH 25/27] Exposing recordSet::tags getter --- .../com/microsoft/azure/management/dns/DnsRecordSet.java | 7 +++++++ .../management/dns/implementation/DnsRecordSetImpl.java | 9 +++++++++ .../java/com/microsoft/azure/management/TestDns.java | 8 +++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index 8ddb8fc19cee2..83e1500d66289 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -6,6 +6,8 @@ import com.microsoft.azure.management.resources.fluentcore.model.Settable; import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; +import java.util.Map; + /** * An immutable client-side representation of a record set in Azure Dns Zone. */ @@ -23,6 +25,11 @@ public interface DnsRecordSet extends */ long timeToLive(); + /** + * @return the tags associated with this record set. + */ + Map tags(); + /** * The entirety of a Dns zone record set definition as a part of parent definition. * diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index a1e2ddcef92dd..8fba90e065e4f 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -16,6 +16,7 @@ import rx.functions.Func1; import java.util.ArrayList; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -66,6 +67,14 @@ public long timeToLive() { return this.inner().tTL(); } + @Override + public Map tags() { + if (this.inner().metadata() == null) { + return Collections.unmodifiableMap(new LinkedHashMap()); + } + return Collections.unmodifiableMap(this.inner().metadata()); + } + // Setters @Override diff --git a/azure/src/test/java/com/microsoft/azure/management/TestDns.java b/azure/src/test/java/com/microsoft/azure/management/TestDns.java index b30fefa69cbb4..d3046dfa1ec51 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestDns.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestDns.java @@ -43,6 +43,8 @@ public DnsZone createResource(DnsZones dnsZones) throws Exception { .defineMxRecordSet("email") .withMailExchange("mail.contoso-mail-exchange1.com", 1) .withMailExchange("mail.contoso-mail-exchange2.com", 2) + .withTag("mxa", "mxaa") + .withTag("mxb", "mxbb") .attach() .defineNsRecordSet("partners") .withNameServer("ns1-05.azure-dns.com") @@ -107,6 +109,7 @@ public DnsZone createResource(DnsZones dnsZones) throws Exception { MxRecordSet mxRecordSet = mxRecordSets.get(0); Assert.assertNotNull(mxRecordSet); Assert.assertTrue(mxRecordSet.name().startsWith("email")); + Assert.assertTrue(mxRecordSet.tags().size() == 2); Assert.assertTrue(mxRecordSet.records().size() == 2); for (MxRecord mxRecord : mxRecordSet.records()) { Assert.assertTrue(mxRecord.exchange().startsWith("mail.contoso-mail-exchange1.com") @@ -223,7 +226,9 @@ public DnsZone updateResource(DnsZone dnsZone) throws Exception { dnsZone.update() .updateMxRecordSet("email") .withoutMailExchange("mail.contoso-mail-exchange2.com", 2) - .withTag("c", "cc") + .withoutTag("mxa") + .withTag("mxc", "mxcc") + .withTag("mxd", "mxdd") .parent() .withTag("d", "dd") .apply(); @@ -232,6 +237,7 @@ public DnsZone updateResource(DnsZone dnsZone) throws Exception { // Check "mail" MX record MxRecordSet mxRecordSet = dnsZone.mxRecordSets().getByName("email"); Assert.assertTrue(mxRecordSet.records().size() == 1); + Assert.assertTrue(mxRecordSet.tags().size() == 3); Assert.assertTrue(mxRecordSet.records().get(0).exchange().startsWith("mail.contoso-mail-exchange1.com")); return dnsZone; From 137919151ec711eb8beccc4dcc746a7baf0c6c1c Mon Sep 17 00:00:00 2001 From: anuchan Date: Tue, 8 Nov 2016 10:10:25 -0800 Subject: [PATCH 26/27] Revert RecordSet::tags -> RecordSet::metadata --- .../azure/management/dns/DnsRecordSet.java | 50 +++++++++---------- .../dns/implementation/DnsRecordSetImpl.java | 6 +-- .../microsoft/azure/management/TestDns.java | 14 +++--- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index 83e1500d66289..a3543aee732ff 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -26,9 +26,9 @@ public interface DnsRecordSet extends long timeToLive(); /** - * @return the tags associated with this record set. + * @return the metadata associated with this record set. */ - Map tags(); + Map metadata(); /** * The entirety of a Dns zone record set definition as a part of parent definition. @@ -315,19 +315,19 @@ interface WithTtl { } /** - * The stage of the record set definition allowing to specify tags. + * The stage of the record set definition allowing to specify metadata. * * @param the return type of {@link UpdateDefinitionStages.WithAttach#attach()} */ - interface WithTags { + interface WithMetadata { /** - * Adds a tag to the resource. + * Adds a metadata to the resource. * - * @param key the key for the tag - * @param value the value for the tag + * @param key the key for the metadata + * @param value the value for the metadata * @return the next stage of the record set definition */ - WithAttach withTag(String key, String value); + WithAttach withMetadata(String key, String value); } /** The final stage of the Dns zone record set definition. @@ -338,7 +338,7 @@ interface WithTags { */ interface WithAttach extends Attachable.InDefinition, - DefinitionStages.WithTags, + WithMetadata, DefinitionStages.WithTtl { } } @@ -628,19 +628,19 @@ interface WithTtl { } /** - * The stage of the record set definition allowing to specify tags. + * The stage of the record set definition allowing to specify metadata. * * @param the return type of {@link WithAttach#attach()} */ - interface WithTags { + interface WithMetadata { /** * Adds a tag to the resource. * - * @param key the key for the tag - * @param value the value for the tag + * @param key the key for the metadata + * @param value the value for the metadata * @return the next stage of the record set definition */ - WithAttach withTag(String key, String value); + WithAttach withMetadata(String key, String value); } /** The final stage of the Dns zone record set definition. @@ -652,7 +652,7 @@ interface WithTags { */ interface WithAttach extends Attachable.InUpdate, - UpdateDefinitionStages.WithTags, + WithMetadata, UpdateDefinitionStages.WithTtl { } } @@ -741,7 +741,7 @@ interface UpdateSoaRecord extends */ interface Update extends Settable, - UpdateStages.UpdateWithTags, + UpdateStages.WithMetadata, UpdateStages.WithTtl { } @@ -974,25 +974,25 @@ interface WithTtl { } /** - * An update allowing tags to be modified for the resource. + * An update allowing metadata to be modified for the resource. */ - interface UpdateWithTags { + interface WithMetadata { /** - * Adds a tag to the record set. + * Adds a metadata to the record set. * - * @param key the key for the tag - * @param value the value for the tag + * @param key the key for the metadata + * @param value the value for the metadata * @return the next stage of the record set update */ - Update withTag(String key, String value); + Update withMetadata(String key, String value); /** - * Removes a tag from the record set. + * Removes a metadata from the record set. * - * @param key the key of the tag to remove + * @param key the key of the metadata to remove * @return the next stage of the record set update */ - Update withoutTag(String key); + Update withoutMetadata(String key); } } } diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java index 8fba90e065e4f..4d81416ed0650 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/implementation/DnsRecordSetImpl.java @@ -68,7 +68,7 @@ public long timeToLive() { } @Override - public Map tags() { + public Map metadata() { if (this.inner().metadata() == null) { return Collections.unmodifiableMap(new LinkedHashMap()); } @@ -238,7 +238,7 @@ public DnsRecordSetImpl withTimeToLive(long ttlInSeconds) { } @Override - public DnsRecordSetImpl withTag(String key, String value) { + public DnsRecordSetImpl withMetadata(String key, String value) { if (this.inner().metadata() == null) { this.inner().withMetadata(new LinkedHashMap()); } @@ -247,7 +247,7 @@ public DnsRecordSetImpl withTag(String key, String value) { } @Override - public DnsRecordSetImpl withoutTag(String key) { + public DnsRecordSetImpl withoutMetadata(String key) { this.recordSetRemoveInfo .metadata().put(key, null); return this; diff --git a/azure/src/test/java/com/microsoft/azure/management/TestDns.java b/azure/src/test/java/com/microsoft/azure/management/TestDns.java index d3046dfa1ec51..c61f6716d254c 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestDns.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestDns.java @@ -43,8 +43,8 @@ public DnsZone createResource(DnsZones dnsZones) throws Exception { .defineMxRecordSet("email") .withMailExchange("mail.contoso-mail-exchange1.com", 1) .withMailExchange("mail.contoso-mail-exchange2.com", 2) - .withTag("mxa", "mxaa") - .withTag("mxb", "mxbb") + .withMetadata("mxa", "mxaa") + .withMetadata("mxb", "mxbb") .attach() .defineNsRecordSet("partners") .withNameServer("ns1-05.azure-dns.com") @@ -109,7 +109,7 @@ public DnsZone createResource(DnsZones dnsZones) throws Exception { MxRecordSet mxRecordSet = mxRecordSets.get(0); Assert.assertNotNull(mxRecordSet); Assert.assertTrue(mxRecordSet.name().startsWith("email")); - Assert.assertTrue(mxRecordSet.tags().size() == 2); + Assert.assertTrue(mxRecordSet.metadata().size() == 2); Assert.assertTrue(mxRecordSet.records().size() == 2); for (MxRecord mxRecord : mxRecordSet.records()) { Assert.assertTrue(mxRecord.exchange().startsWith("mail.contoso-mail-exchange1.com") @@ -226,9 +226,9 @@ public DnsZone updateResource(DnsZone dnsZone) throws Exception { dnsZone.update() .updateMxRecordSet("email") .withoutMailExchange("mail.contoso-mail-exchange2.com", 2) - .withoutTag("mxa") - .withTag("mxc", "mxcc") - .withTag("mxd", "mxdd") + .withoutMetadata("mxa") + .withMetadata("mxc", "mxcc") + .withMetadata("mxd", "mxdd") .parent() .withTag("d", "dd") .apply(); @@ -237,7 +237,7 @@ public DnsZone updateResource(DnsZone dnsZone) throws Exception { // Check "mail" MX record MxRecordSet mxRecordSet = dnsZone.mxRecordSets().getByName("email"); Assert.assertTrue(mxRecordSet.records().size() == 1); - Assert.assertTrue(mxRecordSet.tags().size() == 3); + Assert.assertTrue(mxRecordSet.metadata().size() == 3); Assert.assertTrue(mxRecordSet.records().get(0).exchange().startsWith("mail.contoso-mail-exchange1.com")); return dnsZone; From 07839308083605146b4059f9c3c3f90b0b76d2a0 Mon Sep 17 00:00:00 2001 From: anuchan Date: Tue, 8 Nov 2016 10:16:00 -0800 Subject: [PATCH 27/27] Adding missing UpdateDefinitionStages. prefix --- .../java/com/microsoft/azure/management/dns/DnsRecordSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java index a3543aee732ff..9f6e68f3e2aa7 100644 --- a/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java +++ b/azure-mgmt-dns/src/main/java/com/microsoft/azure/management/dns/DnsRecordSet.java @@ -652,7 +652,7 @@ interface WithMetadata { */ interface WithAttach extends Attachable.InUpdate, - WithMetadata, + UpdateDefinitionStages.WithMetadata, UpdateDefinitionStages.WithTtl { } }