brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahgittin <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #810: REST API for bundles, types, and subtypes
Date Fri, 22 Sep 2017 09:39:21 GMT
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/810#discussion_r140451739
  
    --- Diff: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/TypeTransformer.java
---
    @@ -0,0 +1,194 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.rest.transform;
    +
    +import static org.apache.brooklyn.rest.util.WebResourceUtils.serviceUriBuilder;
    +
    +import java.net.URI;
    +import java.util.Collections;
    +import java.util.Map;
    +import java.util.Set;
    +import java.util.concurrent.atomic.AtomicInteger;
    +
    +import javax.ws.rs.core.UriBuilder;
    +import javax.ws.rs.core.UriInfo;
    +
    +import org.apache.brooklyn.api.effector.Effector;
    +import org.apache.brooklyn.api.entity.Entity;
    +import org.apache.brooklyn.api.entity.EntitySpec;
    +import org.apache.brooklyn.api.entity.EntityType;
    +import org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec;
    +import org.apache.brooklyn.api.location.Location;
    +import org.apache.brooklyn.api.mgmt.ManagementContext;
    +import org.apache.brooklyn.api.objs.EntityAdjunct;
    +import org.apache.brooklyn.api.objs.SpecParameter;
    +import org.apache.brooklyn.api.policy.Policy;
    +import org.apache.brooklyn.api.sensor.Enricher;
    +import org.apache.brooklyn.api.sensor.Feed;
    +import org.apache.brooklyn.api.sensor.Sensor;
    +import org.apache.brooklyn.api.typereg.ManagedBundle;
    +import org.apache.brooklyn.api.typereg.RegisteredType;
    +import org.apache.brooklyn.core.entity.EntityDynamicType;
    +import org.apache.brooklyn.core.mgmt.ha.OsgiBundleInstallationResult;
    +import org.apache.brooklyn.core.objs.BrooklynTypes;
    +import org.apache.brooklyn.core.typereg.RegisteredTypePredicates;
    +import org.apache.brooklyn.core.typereg.RegisteredTypes;
    +import org.apache.brooklyn.rest.api.TypeApi;
    +import org.apache.brooklyn.rest.domain.AdjunctConfigSummary;
    +import org.apache.brooklyn.rest.domain.BundleInstallationRestResult;
    +import org.apache.brooklyn.rest.domain.BundleSummary;
    +import org.apache.brooklyn.rest.domain.EffectorSummary;
    +import org.apache.brooklyn.rest.domain.EntityConfigSummary;
    +import org.apache.brooklyn.rest.domain.SensorSummary;
    +import org.apache.brooklyn.rest.domain.SummaryComparators;
    +import org.apache.brooklyn.rest.domain.TypeDetail;
    +import org.apache.brooklyn.rest.domain.TypeSummary;
    +import org.apache.brooklyn.rest.util.BrooklynRestResourceUtils;
    +import org.apache.brooklyn.util.collections.MutableMap;
    +import org.apache.brooklyn.util.exceptions.Exceptions;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.collect.Sets;
    +
    +public class TypeTransformer {
    +
    +    private static final org.slf4j.Logger log = LoggerFactory.getLogger(TypeTransformer.class);
    +    
    +    public static <T extends Entity> TypeSummary summary(BrooklynRestResourceUtils
b, RegisteredType item, UriBuilder ub) {
    +        return embellish(new TypeSummary(item), item, false, b, ub);
    +    }
    +
    +    public static TypeDetail detail(BrooklynRestResourceUtils b, RegisteredType item,
UriBuilder ub) {
    +        return embellish(new TypeDetail(item), item, true, b, ub);
    +    }
    +
    +    private static <T extends TypeSummary> T embellish(T result, RegisteredType
item, boolean detail, BrooklynRestResourceUtils b, UriBuilder ub) {
    +        result.getExtraFields().put("links", makeLinks(item, ub));
    --- End diff --
    
    agree


---

Mime
View raw message