You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an incomplete and changing spec for building models and collections in the new fluent SDK (master branch).
Example service
The example we use to demonstrate the guidelines is Azure Pet store management client. It has a Pets collection which supports all kinds of operations on type Pet.
Pets reside in resource group and have a location property.
Where AutoRest generated types reside?
AutoRest emits the following artifacts to implementation/api directory:
Non-top level model : These are usually simple models, the top level model composed of these models. In our example, PetInner.java composes Profile.java.
Where Fluent model and collection types reside?
interfaces
The definition of fluent interfaces for each collection and top level model should reside in the same level as implementation directory.
e.g. Pets.java (fluent collection interface) and Pet.java (fluent model interface)
// public accesspublicinterfacePetextendsGroupableResource {
}
PetImpl.java
// internal accessed implclassPetImplimplementsPet {
// internal accessed constructor// takes an inner model and inner collectionPetImpl(PetInnerinnerModel, PetsInnerclient, ResourceGroupsresourceGroups) {
super(innerModel.id(), innerModel, resourceGroups);
}
/* Some other methods to implement */@Overridepublicvoidrefresh() throwsCloudException, IOException {
this.setInner(client.get(innerModel.id()));
returnthis;
}
}
Fluent collections
Pets.java
// public accesspublicinterfacePetsextendsSupportsCreating<Pet.DefinitionBlank>,
SupportsListing<Pet>,
SupportsListingByGroup<Pet>,
SupportsGetting<Pet>,
SupportsGettingByGroup<Pet>,
SupportsDeleting,
SupportsDeletingByGroup {
// public access from external will be publicinterfaceInGroupextendsSupportsListing<Pet>,
SupportsGetting<Pet>,
SupportsCreating<Pet.DefinitionWithGroup>,
SupportsDeleting {
}
}
Pets interface represents the operations that can be performed on the Pets collection across all resource groups in the service.
Pets.InGroup represents the operations that can be performed on the Pets collection in a specific resource group.
Since the most common operations that can be performed on a collection are CRUD, these operations are extracted out as runtime interfaces. The fluent collection interface extends from these runtime interfaces. Refer the section Runtime CRUD interfaces for details.
Manager serve as a container for all fluent collections associated with a service. Each manager will have 3 static methods that consumers can use to authenticate and get an instance of manager.
Each fluent collection interface (e.g. Pets.java) should expose methods that allows users to perform C (Create), R (Read), U (Update) and D (Delete) operations on the collection. Exposing one of these method depends on whether service supports corresponding operation or not.
This is an incomplete and changing spec for building models and collections in the new fluent SDK (
master
branch).Example service
The example we use to demonstrate the guidelines is Azure Pet store management client. It has a
Pets
collection which supports all kinds of operations on typePet
.Pets reside in resource group and have a location property.
Where AutoRest generated types reside?
AutoRest emits the following artifacts to
implementation/api
directory:Terminology
Top level model : Inner models that represents service request or response payload. In our example
PetInner.java
is a top level model.Given below a sample payload to create a Pet entry.
Non-top level model : These are usually simple models, the top level model composed of these models. In our example,
PetInner.java
composesProfile.java
.Where Fluent model and collection types reside?
interfaces
The definition of fluent
interfaces
for each collection and top level model should reside in the same level asimplementation
directory.e.g.
Pets.java
(fluent collection interface) andPet.java
(fluent model interface)Note that
Profile.java
is a non-top level model so there is no fluent model interface for this.implementations
Implementation for fluent model and collection interfaces should reside under
implementation
directory.e.g.
PetsImpl.java
(fluent collection implementation) andPetImpl.java
(fluent model implementation)Authoring fluent types
Fluent models
Pet.java
PetImpl.java
Fluent collections
Pets.java
Pets
interface represents the operations that can be performed on the Pets collection across all resource groups in the service.Pets.InGroup
represents the operations that can be performed on the Pets collection in a specific resource group.Since the most common operations that can be performed on a collection are CRUD, these operations are extracted out as runtime interfaces. The fluent collection interface extends from these runtime interfaces. Refer the section Runtime CRUD interfaces for details.
PetsImpl.java
PetsInGroupImpl.java
Fluent manager
Manager serve as a container for all fluent collections associated with a service. Each manager will have 3 static methods that consumers can use to
authenticate
and get an instance of manager.Runtime CRUD interfaces
Each fluent collection interface (e.g.
Pets.java
) should expose methods that allows users to perform C (Create), R (Read), U (Update) and D (Delete) operations on the collection. Exposing one of these method depends on whether service supports corresponding operation or not.Create interface
Read interfaces
Update interface
Delete interface
Example
The text was updated successfully, but these errors were encountered: