@RestLiCollection(name = "policies", namespace = "org.apache.gobblin.restli.throttling") public class PoliciesResource extends CollectionResourceTemplate<String, Policy> {
/** * @param collectionAnno {@link RestLiCollection} annotation */ public RestLiAnnotationData(RestLiCollection collectionAnno) { _parent = collectionAnno.parent(); _name = collectionAnno.name(); _namespace = collectionAnno.namespace(); _keys = null; _keyName = RestAnnotations.DEFAULT.equals(collectionAnno.keyName()) ? null : collectionAnno.keyName(); _typerefInfoClass = RestAnnotations.NULL_TYPEREF_INFO.class.equals(collectionAnno.keyTyperefClass()) ? null : collectionAnno.keyTyperefClass(); }
@RestLiCollection(name = "jobExecutions", namespace = "org.apache.gobblin.rest") public class JobExecutionInfoResource extends ComplexKeyResourceTemplate<JobExecutionQuery, EmptyRecord, JobExecutionQueryResult> {
@RestLiCollection(name = "flowstatuses", namespace = "org.apache.gobblin.service", keyName = "id") public class FlowStatusResource extends ComplexKeyResourceTemplate<FlowStatusId, EmptyRecord, FlowStatus> { private static final Logger LOG = LoggerFactory.getLogger(FlowStatusResource.class);
@RestLiCollection(name = "flowconfigsV2", namespace = "org.apache.gobblin.service", keyName = "id") public class FlowConfigsV2Resource extends ComplexKeyResourceTemplate<FlowId, FlowStatusId, FlowConfig> { private static final Logger LOG = LoggerFactory.getLogger(FlowConfigsV2Resource.class);
@RestLiCollection(name = "flowconfigs", namespace = "org.apache.gobblin.service", keyName = "id") public class FlowConfigsResource extends ComplexKeyResourceTemplate<FlowId, EmptyRecord, FlowConfig> { private static final Logger LOG = LoggerFactory.getLogger(FlowConfigsResource.class);
@RestLiCollection(name = "permits", namespace = "org.apache.gobblin.restli.throttling") public class LimiterServerResource extends ComplexKeyResourceAsyncTemplate<PermitRequest, EmptyRecord, PermitAllocation> {
/** * This resource models a (very simple) custom collection resource that produces unstructured data as results. */ @RestLiCollection(name = "customGreetingCollectionUnstructuredData", namespace = "com.linkedin.restli.examples.greetings.client") public class CustomGreetingCollectionUnstructuredDataResource extends ResourceContextHolder implements KeyUnstructuredDataResource<String> { @RestMethod.Get public void get(String key, @UnstructuredDataWriterParam UnstructuredDataWriter writer) { respondGoodUnstructuredData(writer); } }
/** * A subresource of the REST endpoint without namespace * * @author Keren Jin */ @RestLiCollection(parent = NoNamespaceResource.class, name = "noNamespaceSub") public class NoNamespaceSubResource extends CollectionResourceTemplate<Long, Greeting> { }
/** * An REST endpoint without namespace * * @author Keren Jin */ @RestLiCollection(name = NoNamespaceResource.RESOURCE_NAME) public class NoNamespaceResource extends CollectionResourceTemplate<Long, Greeting> { public static final String RESOURCE_NAME = "noNamespace"; }
/** * @author Keren Jin */ @RestLiCollection(parent = NoNamespaceSubResource.class, name = "subSub") public class SubSubResource extends CollectionResourceTemplate<Long, ToneFacet> { }
@RestLiCollection(name = "greetingCollectionUnstructuredDataTask", namespace = "com.linkedin.restli.examples.greetings.client") public class GreetingUnstructuredDataCollectionResourceTask extends UnstructuredDataCollectionResourceTaskTemplate<String> { private static final ScheduledExecutorService _scheduler = Executors.newScheduledThreadPool(1); @Override public Task<Void> get(String key, final @UnstructuredDataWriterParam UnstructuredDataWriter writer) { return Task.blocking("fetchBytes", () -> { GreetingUnstructuredDataUtils.respondGoodUnstructuredData(writer); return null; }, _scheduler); } }
/** * A Subresource whose unqualified name is identical to its parent * * N.B. The only reason a namespace is specified on this resource is to avoid clashing when the * client builders are generated. * * @author Keren Jin */ @RestLiCollection(parent = NoNamespaceResource.class, name = NoNamespaceResource.RESOURCE_NAME, namespace = "com.linkedin.restli.examples") public class IdenticallyNamedSubResource extends CollectionResourceTemplate<Long, Greeting> { }
/** * @author Moira Tagle * @version $Revision: $ */ @RestLiCollection(name="customTypes4", namespace = "com.linkedin.restli.examples.greetings.client", keyTyperefClass = CustomLongRef.class, parent = CustomTypesResource2.class) public class CustomTypesResource4 extends CollectionResourceTemplate<CustomLong, Greeting> { @Override public Greeting get(CustomLong lo) { CustomLong customTypes2Id = (CustomLong)getContext().getPathKeys().get("customTypes2Id"); return new Greeting().setId(customTypes2Id.toLong() * lo.toLong()); } }
/** * Demonstrates a resource with a complex key that consists of a field of Bytes typeref. * @author mnchen * */ @RestLiCollection( name = "complexByteKeys", namespace = "com.linkedin.restli.examples.greetings.client", keyName="keys" ) public class ComplexByteKeysResource extends ComplexKeyResourceTemplate<TyperefRecord, TwoPartKey, TyperefRecord> { private static ComplexKeysDataProvider _dataProvider = new ComplexKeysDataProvider(); @Override public TyperefRecord get(final ComplexResourceKey<TyperefRecord, TwoPartKey> complexKey) { TyperefRecord key = complexKey.getKey(); return new TyperefRecord().setBytes(key.getBytes()); } }
@RestLiCollection(name = "greetingCollectionUnstructuredDataAsync", namespace = "com.linkedin.restli.examples.greetings.client") public class GreetingUnstructuredDataCollectionResourceAsync extends UnstructuredDataCollectionResourceAsyncTemplate<String> { private static final ScheduledExecutorService _scheduler = Executors.newScheduledThreadPool(1); private static final int DELAY = 100; @Override public void get(String key, @UnstructuredDataWriterParam UnstructuredDataWriter writer, @CallbackParam Callback<Void> callback) { _scheduler.schedule(() -> { try { GreetingUnstructuredDataUtils.respondGoodUnstructuredData(writer); callback.onSuccess(null); } catch (final Throwable throwable) { callback.onError(throwable); } }, DELAY, TimeUnit.MILLISECONDS); } }
@SuppressWarnings("deprecation") @RestLiCollection(name = "greetingCollectionUnstructuredDataPromise", namespace = "com.linkedin.restli.examples.greetings.client") public class GreetingUnstructuredDataCollectionResourcePromise extends com.linkedin.restli.server.resources.unstructuredData.UnstructuredDataCollectionResourcePromiseTemplate<String> { // Use full-qualified classname here since we cannot add @SuppressWarnings("deprecation") in import private static final ScheduledExecutorService _scheduler = Executors.newScheduledThreadPool(1); private static final int DELAY = 100; @Override public Promise<Void> get(String key, @UnstructuredDataWriterParam UnstructuredDataWriter writer) { final SettablePromise<Void> result = Promises.settable(); _scheduler.schedule(() -> { try { GreetingUnstructuredDataUtils.respondGoodUnstructuredData(writer); result.done(null); } catch (final Throwable throwable) { result.fail(throwable); } }, DELAY, TimeUnit.MILLISECONDS); return result; } }
/** * @author xma */ @RestLiCollection(name = "typerefKeys", namespace = "com.linkedin.restli.examples.greetings.client", keyTyperefClass = LongRef.class) public class TyperefKeysResource extends CollectionResourceTemplate<Long, Greeting> { @Override public CreateResponse create(Greeting entity) { return new CreateResponse(entity.getId()); } @Override public Map<Long, Greeting> batchGet(Set<Long> keys) { Map<Long, Greeting> result = new HashMap<Long, Greeting>(); for (Long key : keys) { result.put(key, new Greeting().setId(key)); } return result; } }
/** * This resource models a collection resource that produces unstructured data entities as results. */ @RestLiCollection(name = "greetingCollectionUnstructuredData", namespace = "com.linkedin.restli.examples.greetings.client") public class GreetingUnstructuredDataCollectionResource extends UnstructuredDataCollectionResourceTemplate<String> { @Override public void get(String key, @UnstructuredDataWriterParam UnstructuredDataWriter writer) { switch (key) { case "good": respondGoodUnstructuredData(writer); break; case "goodInline": getContext().setResponseHeader(HEADER_CONTENT_DISPOSITION, CONTENT_DISPOSITION_VALUE); respondGoodUnstructuredData(writer); break; case "missingHeaders": respondBadUnstructuredData(writer); break; case "exception": throw new RestLiServiceException(HttpStatus.S_500_INTERNAL_SERVER_ERROR, "internal service exception"); default: throw new RestLiServiceException(HttpStatus.S_503_SERVICE_UNAVAILABLE, "unexpected unstructured data key, something wrong with the test."); } } }
@RestLiCollection(name = "exceptions3", namespace = "com.linkedin.restli.examples.greetings.client") public class ExceptionsResource3 extends CollectionResourceTemplate<Long, Greeting>