Class ResourceClientBase<M,J>

java.lang.Object
com.eqixiac.equinix.core.client.ClientBase
com.eqixiac.equinix.core.client.ResourceClientBase<M,J>
Type Parameters:
M - the public model type
J - the JSON model type
All Implemented Interfaces:
Pageable<M>, PageablePost<M>
Direct Known Subclasses:
AccountClientImpl, AccountClientImpl, ACLTemplateClientImpl, AgentClientImpl, AgentTemplateClientImpl, AssetClientImpl, AttachmentClientImpl, BackupClientImpl, BetaResourceClient, BGPPeeringClientImpl, BillingAccountClientImpl, BillingAccountSearchClientImpl, CabinetClientImpl, CageClientImpl, CloudEventClientImpl, CloudRouterActionClientImpl, CloudRouterClientImpl, CloudRouterCommandClientImpl, CloudRouterPackageClientImpl, CompanyProfileClientImpl, ConnectionClientImpl, ConnectionServiceClientImpl, CustomerRouteConfigurationClientImpl, DedicatedBandwidthConfigurationClientImpl, DedicatedPortDefaultConfigurationClientImpl, DeviceClientImpl, DeviceLinkClientImpl, DeviceTypeClientImpl, EiaServiceClientImpl, EnvironmentalClientImpl, IbxClientImpl, IbxV1ClientImpl, InternetAccessServiceClientImpl, InvoiceDetailClientImpl, InvoiceSummaryClientImpl, IpBlockClientImpl, MarketplaceSubscriptionClientImpl, MetricClientImpl, MetroClientImpl, MetroClientImpl, NetworkClientImpl, OperationalUnitClientImpl, OrderClientImpl, OrderClientImpl, PatchPanelClientImpl, PortClientImpl, PortConfigurationClientImpl, PowerEventClientImpl, PrecisionTimeClientImpl, PriceClientImpl, PricingClientImpl, ProjectClientImpl, PublicKeyClientImpl, PurchaseOrderClientImpl, QuoteClientImpl, ReportClientImpl, RouteAggregationAttachmentClientImpl, RouteAggregationClientImpl, RouteAggregationRuleClientImpl, RouteFilterAttachmentClientImpl, RouteFilterClientImpl, RouteFilterRuleClientImpl, RouteTableEntryClientImpl, RoutingConfigurationClientImpl, RoutingProtocolClientImpl, ServiceProfileClientImpl, ServiceTokenClientImpl, SignaturePolicyClientImpl, StreamAlertRuleClientImpl, StreamAssetClientImpl, StreamClientImpl, StreamingSubscriptionClientImpl, StreamSubscriptionClientImpl, SupportPlanClientImpl, SystemAlertClientImpl, TagClientImpl, TermsClientImpl, TroubleTicketClientImpl, VirtualBandwidthConfigurationClientImpl, VirtualConnectionDefaultConfigurationClientImpl, VPNClientImpl

public abstract class ResourceClientBase<M,J> extends ClientBase implements PageablePost<M>
Generic base for internal resource clients, collapsing the request-build -> invoke -> response-handle boilerplate that was previously copy-pasted across every *ClientImpl.

Parameterized over the public model type M and its JSON model J. The response TypeReference is derived from J (see RequestAssembler.deriveResponseType(RequestType, Class)), and the paging nextPage(...) methods are provided once here. Subclasses supply the JSON class and a wrap(Object) factory (which binds this client for refresh/paging) and then implement each operation as a one-line call to the protected helpers below, passing only the service-endpoint name.

Clients whose apiParams endpoint names follow the standard convention can additionally pass a resource name at construction and use the no-endpoint-name helper overloads: the default endpoint names are derived as List+plural, Search+plural, Get/ Create/Update/Delete+singular. Operations whose apiParams names deviate keep calling the explicit-name helpers.

public class ServiceProfileClientImpl extends ResourceClientBase<ServiceProfile, ServiceProfileJson>
        implements ServiceProfileClient<ServiceProfile> {
    public ServiceProfileClientImpl(FabricConfigImpl c) {
        super(c, "Fabric", "ServiceProfiles", ServiceProfileJson.class);
    }
    protected ServiceProfile wrap(ServiceProfileJson j) { return new ServiceProfileWrapper(j, this); }
    public Page<ServiceProfileJson> list()          { return listPage("ListServiceProfiles"); }
    public ServiceProfileJson getByUuid(String uuid) { return getOne("GetServiceProfile", uuid); }
    // ...
}
Author:
ianjones
  • Constructor Details

    • ResourceClientBase

      protected ResourceClientBase(Config configClient, String functionalArea, String requestParent, Class<J> jsonClass)
    • ResourceClientBase

      protected ResourceClientBase(Config configClient, String functionalArea, String requestParent, Class<J> jsonClass, String resourceName)
      Creates a resource client whose default endpoint names are derived from the resource name (plural defaults to resourceName + "s"); use the explicit-name helpers for any operation whose apiParams name deviates from the convention.
      Parameters:
      resourceName - the singular resource name as it appears in apiParams endpoint names
    • ResourceClientBase

      protected ResourceClientBase(Config configClient, String functionalArea, String requestParent, Class<J> jsonClass, String resourceNameSingular, String resourceNamePlural)
      Creates a resource client whose default endpoint names are derived from an irregularly pluralized resource name.
      Parameters:
      resourceNameSingular - the singular resource name (drives Get/Create/Update/Delete)
      resourceNamePlural - the plural resource name (drives List/Search)
  • Method Details

    • wrap

      protected abstract M wrap(J json)
      Wraps a JSON model into its public model type, binding this client so the returned object can refresh/delete/page itself.
      Parameters:
      json - the deserialized JSON model
      Returns:
      the public model wrapper
    • listPage

      protected Page<J> listPage()
      list() via the derived List<Plural> endpoint name.
    • searchPage

      protected Page<J> searchPage(Object filterSortBody)
      search(body) via the derived Search<Plural> endpoint name.
    • getOneByUuid

      protected J getOneByUuid(String uuid)
      get(uuid) via the derived Get<Singular> endpoint name.
    • createOne

      protected J createOne(Object creatorBody)
      create(body) via the derived Create<Singular> endpoint name.
    • updateOneByUuid

      protected J updateOneByUuid(String uuid, Object body)
      update(uuid, body) via the derived Update<Singular> endpoint name.
    • deleteOneByUuid

      protected J deleteOneByUuid(String uuid)
      delete(uuid) via the derived Delete<Singular> endpoint name.
    • listPage

      protected Page<J> listPage(String serviceEndpoint)
    • listPage

      protected Page<J> listPage(String serviceEndpoint, Map<String, List<String>> queryParams)
    • searchPage

      protected Page<J> searchPage(String serviceEndpoint, Object filterSortBody)
    • searchPageQueryPaginated

      protected Page<J> searchPageQueryPaginated(String serviceEndpoint, Object filterBody)
      POST search whose pagination travels as offset/limit query parameters (per the endpoint's spec) rather than inside the body - e.g. assets v1 and the EIA services/prices searches. Builds a PaginatedRequest (so the shared paging pipeline advances the query-parameter offset between pages, re-sending the same filter body) instead of a PaginatedPostRequest (whose paging advances state inside the body).
    • searchPageQueryPaginated

      protected Page<J> searchPageQueryPaginated(String serviceEndpoint, Map<String, List<String>> queryParams, Object filterBody)
      Variant of searchPageQueryPaginated(String, Object) carrying additional query parameters (e.g. q/exactMatch/sorts on the assets search).
    • getOne

      protected J getOne(String serviceEndpoint, String uuid)
    • postOne

      protected J postOne(String serviceEndpoint, Object creatorBody)
    • updateOne

      protected J updateOne(String serviceEndpoint, String uuid, Object body)
    • deleteOne

      protected J deleteOne(String serviceEndpoint, String uuid)
    • patchOne

      protected J patchOne(String serviceEndpoint, String uuid, List<PatchOperation> operations)
      PATCH a resource by uuid with an RFC 6902 JSON Patch operations array, sent with content-type application/json-patch+json. The endpoint's HTTP method (PATCH) comes from apiParams; the returned JSON is the server's updated resource.
    • postOne

      protected J postOne(String serviceEndpoint, Object body, com.fasterxml.jackson.databind.ser.FilterProvider filters)
    • dryRunCreate

      protected J dryRunCreate(String serviceEndpoint, Object body)
    • dryRunCreate

      protected J dryRunCreate(String serviceEndpoint, Object body, com.fasterxml.jackson.databind.ser.FilterProvider filters)
    • dryRunPatch

      protected J dryRunPatch(String serviceEndpoint, String uuid, List<PatchOperation> operations)
      Dry-run variant of patchOne(String, String, List): sends the identical RFC 6902 JSON Patch request (same application/json-patch+json content type) plus the dryRun=true query parameter - per the spec, an "option to verify that API calls will succeed". Nothing is persisted; the returned JSON is the server's simulation of the patched resource.
    • dryRunUpdate

      protected J dryRunUpdate(String serviceEndpoint, String uuid, Object body)
      Dry-run variant of updateOne(String, String, Object): sends the identical update request (same default application/json content type) plus the dryRun=true query parameter - per the spec, an "option to verify that API calls will succeed". Nothing is persisted; the returned JSON is the server's simulation of the updated resource.
    • listPagePath

      protected Page<J> listPagePath(String serviceEndpoint, Map<String,String> pathParams)
    • getOne

      protected J getOne(String serviceEndpoint, Map<String,String> pathParams)
    • postOne

      protected J postOne(String serviceEndpoint, Map<String,String> pathParams, Object body)
    • updateOne

      protected J updateOne(String serviceEndpoint, Map<String,String> pathParams, Object body)
    • deleteOne

      protected J deleteOne(String serviceEndpoint, Map<String,String> pathParams)
    • patchOne

      protected J patchOne(String serviceEndpoint, Map<String,String> pathParams, List<PatchOperation> operations)
    • nextPage

      public PaginatedList<M> nextPage(PaginatedRequest<M> equinixRequest)
      Specified by:
      nextPage in interface Pageable<M>
    • nextPage

      public PaginatedFilteredList<M> nextPage(PaginatedPostRequest<M> equinixRequest)
      Description copied from interface: PageablePost
      Fetches the next page for the given POST-search request (its body's pagination has already been advanced by the paging pipeline).
      Specified by:
      nextPage in interface PageablePost<M>
      Parameters:
      equinixRequest - the search request carrying the live search body
      Returns:
      the next page of mapped results