Class ResourceClientBase<M,J>
- Type Parameters:
M- the public model typeJ- 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
*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
-
Nested Class Summary
Nested classes/interfaces inherited from class ClientBase
ClientBase.EquinixRequestBuilderModifier and TypeClassDescriptionprotected classFluent builder for constructingEquinixRequestinstances. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedResourceClientBase(Config configClient, String functionalArea, String requestParent, Class<J> jsonClass) protectedResourceClientBase(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 toresourceName + "s"); use the explicit-name helpers for any operation whose apiParams name deviates from the convention.protectedResourceClientBase(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. -
Method Summary
Modifier and TypeMethodDescriptionprotected Jcreate(body)via the derivedCreate<Singular>endpoint name.protected Jprotected Jprotected JdeleteOneByUuid(String uuid) delete(uuid)via the derivedDelete<Singular>endpoint name.protected JdryRunCreate(String serviceEndpoint, Object body) protected JdryRunCreate(String serviceEndpoint, Object body, com.fasterxml.jackson.databind.ser.FilterProvider filters) protected JdryRunPatch(String serviceEndpoint, String uuid, List<PatchOperation> operations) Dry-run variant ofpatchOne(String, String, List): sends the identical RFC 6902 JSON Patch request (sameapplication/json-patch+jsoncontent type) plus thedryRun=truequery parameter - per the spec, an "option to verify that API calls will succeed".protected JdryRunUpdate(String serviceEndpoint, String uuid, Object body) Dry-run variant ofupdateOne(String, String, Object): sends the identical update request (same defaultapplication/jsoncontent type) plus thedryRun=truequery parameter - per the spec, an "option to verify that API calls will succeed".protected Jprotected Jprotected JgetOneByUuid(String uuid) get(uuid)via the derivedGet<Singular>endpoint name.listPage()list()via the derivedList<Plural>endpoint name.listPagePath(String serviceEndpoint, Map<String, String> pathParams) nextPage(PaginatedPostRequest<M> equinixRequest) Fetches the next page for the given POST-search request (its body's pagination has already been advanced by the paging pipeline).nextPage(PaginatedRequest<M> equinixRequest) protected JpatchOne(String serviceEndpoint, String uuid, List<PatchOperation> operations) PATCH a resource by uuid with an RFC 6902 JSON Patch operations array, sent with content-typeapplication/json-patch+json.protected Jprotected Jprotected JpostOne(String serviceEndpoint, Object body, com.fasterxml.jackson.databind.ser.FilterProvider filters) protected JsearchPage(Object filterSortBody) search(body)via the derivedSearch<Plural>endpoint name.searchPage(String serviceEndpoint, Object filterSortBody) searchPageQueryPaginated(String serviceEndpoint, Object filterBody) POST search whose pagination travels asoffset/limitquery parameters (per the endpoint's spec) rather than inside the body - e.g. assets v1 and the EIA services/prices searches.searchPageQueryPaginated(String serviceEndpoint, Map<String, List<String>> queryParams, Object filterBody) Variant ofsearchPageQueryPaginated(String, Object)carrying additional query parameters (e.g.protected Jprotected Jprotected JupdateOneByUuid(String uuid, Object body) update(uuid, body)via the derivedUpdate<Singular>endpoint name.protected abstract MWraps a JSON model into its public model type, binding this client so the returned object can refresh/delete/page itself.Methods inherited from class ClientBase
booleanOp, buildRequest, buildRequest, buildRequestWithPathParams, buildRequestWithQueryParams, bytesOp, createReturningLocationUuid, getAs, getAs, getConfigClient, invoke, listAs, mapOp, newRequest, postAs, postForType, postForType, postForType, postListAs, stringOp, voidOpModifier and TypeMethodDescriptionprotected booleanbooleanOp(String serviceEndpoint, RequestType requestType, Map<String, String> pathParams, Map<String, List<String>> queryParams, Object body) protected <T> EquinixRequest<T> buildRequest(String serviceEndpoint, RequestType requestType, Class<?> jsonClass) protected <T> EquinixRequest<T> buildRequest(String serviceEndpoint, RequestType requestType, Map<String, String> pathParams, Map<String, List<String>> queryParams, Class<?> jsonClass) protected <T> EquinixRequest<T> buildRequestWithPathParams(String serviceEndpoint, RequestType requestType, Map<String, String> pathParams, Class<?> jsonClass) protected <T> EquinixRequest<T> buildRequestWithQueryParams(String serviceEndpoint, RequestType requestType, Map<String, List<String>> queryParams, Class<?> jsonClass) protected byte[]bytesOp(String serviceEndpoint, Map<String, String> pathParams, Map<String, List<String>> queryParams) protected StringcreateReturningLocationUuid(String serviceEndpoint, Map<String, String> pathParams, Map<String, List<String>> queryParams, Object body) POST a body, then return the created resource's uuid parsed from the responseLocationheader (for endpoints that return201 Location: .../{uuid}rather than a body).protected <R> Rprotected <R> RgetAs(String serviceEndpoint, Map<String, String> pathParams, Map<String, List<String>> queryParams, Class<R> responseType) protected Configprotected <T> EquinixResponse<T> invoke(EquinixRequest<T> equinixRequest) protected <R> List<R> listAs(String serviceEndpoint, Map<String, String> pathParams, Map<String, List<String>> queryParams, Class<R> elementType) mapOp(String serviceEndpoint, RequestType requestType, Map<String, String> pathParams, Map<String, List<String>> queryParams, Object body) protected ClientBase.EquinixRequestBuildernewRequest(String serviceEndpoint) Creates a fluent request builder for the given service endpoint.protected <R> Rprotected <R> RpostForType(String serviceEndpoint, Object body, com.fasterxml.jackson.core.type.TypeReference<?> typeReference) protected <R> RpostForType(String serviceEndpoint, Map<String, String> pathParams, Object body, com.fasterxml.jackson.core.type.TypeReference<?> typeReference) protected <R> RpostForType(String serviceEndpoint, Map<String, String> pathParams, Map<String, List<String>> queryParams, Object body, com.fasterxml.jackson.core.type.TypeReference<?> typeReference) protected <R> List<R> postListAs(String serviceEndpoint, Object body, Class<R> elementType) protected StringstringOp(String serviceEndpoint, RequestType requestType, Map<String, String> pathParams, Map<String, List<String>> queryParams, Object body) protected voidvoidOp(String serviceEndpoint, RequestType requestType, Map<String, String> pathParams, Map<String, List<String>> queryParams, Object body) Execute a request for its side effect only - the response body is validated (throws on API error) and discarded.
-
Constructor Details
-
ResourceClientBase
-
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 toresourceName + "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
-
listPage
-
searchPage
-
getOneByUuid
-
createOne
-
updateOneByUuid
-
deleteOneByUuid
-
listPage
-
listPage
-
searchPage
-
searchPageQueryPaginated
POST search whose pagination travels asoffset/limitquery parameters (per the endpoint's spec) rather than inside the body - e.g. assets v1 and the EIA services/prices searches. Builds aPaginatedRequest(so the shared paging pipeline advances the query-parameter offset between pages, re-sending the same filter body) instead of aPaginatedPostRequest(whose paging advances state inside the body). -
searchPageQueryPaginated
-
getOne
-
postOne
-
updateOne
-
deleteOne
-
patchOne
PATCH a resource by uuid with an RFC 6902 JSON Patch operations array, sent with content-typeapplication/json-patch+json. The endpoint's HTTP method (PATCH) comes fromapiParams; the returned JSON is the server's updated resource. -
postOne
-
dryRunCreate
-
dryRunCreate
-
dryRunPatch
Dry-run variant ofpatchOne(String, String, List): sends the identical RFC 6902 JSON Patch request (sameapplication/json-patch+jsoncontent type) plus thedryRun=truequery 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
Dry-run variant ofupdateOne(String, String, Object): sends the identical update request (same defaultapplication/jsoncontent type) plus thedryRun=truequery 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
-
getOne
-
postOne
-
updateOne
-
deleteOne
-
patchOne
-
nextPage
-
nextPage
Description copied from interface:PageablePostFetches the next page for the given POST-search request (its body's pagination has already been advanced by the paging pipeline).- Specified by:
nextPagein interfacePageablePost<M>- Parameters:
equinixRequest- the search request carrying the live search body- Returns:
- the next page of mapped results
-