// Path: fiat-core/src/main/java/com/netflix/spinnaker/fiat/model/resources/Application.java
// @Component
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class Application extends BaseAccessControlled<Application> implements Viewable {
//   final ResourceType resourceType = ResourceType.APPLICATION;
// 
//   private String name;
//   private Permissions permissions = Permissions.EMPTY;
// 
//   private Map<String, Object> details = new HashMap<>();
// 
//   @JsonAnySetter
//   public void setDetails(String name, Object value) {
//     this.details.put(name, value);
//   }
// 
//   @JsonIgnore
//   public View getView(Set<Role> userRoles, boolean isAdmin) {
//     return new View(this, userRoles, isAdmin);
//   }
// 
//   @Data
//   @EqualsAndHashCode(callSuper = false)
//   @NoArgsConstructor
//   public static class View extends BaseView implements Authorizable {
//     String name;
//     Set<Authorization> authorizations;
// 
//     public View(Application application, Set<Role> userRoles, boolean isAdmin) {
//       this.name = application.name;
//       if (isAdmin) {
//         this.authorizations = Authorization.ALL;
//       } else {
//         this.authorizations = application.permissions.getAuthorizations(userRoles);
//       }
//     }
//   }
// }
// 
// Path: fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/ProviderHealthTracker.java
// public class ProviderHealthTracker {
// 
//   /** Maximum age of stale data before this instance goes unhealthy. */
//   private final long maximumStalenessTimeMs;
// 
//   private AtomicLong lastSuccessfulUpdateTimeMs = new AtomicLong(-1);
// 
//   public ProviderHealthTracker(long maximumStalenessTimeMs) {
//     this.maximumStalenessTimeMs = maximumStalenessTimeMs;
//   }
// 
//   public void success() {
//     lastSuccessfulUpdateTimeMs.set(System.currentTimeMillis());
//   }
// 
//   public boolean isProviderHealthy() {
//     return lastSuccessfulUpdateTimeMs.get() != -1 && getStaleness() < maximumStalenessTimeMs;
//   }
// 
//   private long getStaleness() {
//     if (lastSuccessfulUpdateTimeMs.get() == -1) {
//       return -1;
//     }
//     return System.currentTimeMillis() - lastSuccessfulUpdateTimeMs.get();
//   }
// 
//   public HealthView getHealthView() {
//     return new HealthView();
//   }
// 
//   @Data
//   public class HealthView {
//     boolean providerHealthy = ProviderHealthTracker.this.isProviderHealthy();
//     long msSinceLastSuccess = ProviderHealthTracker.this.getStaleness();
//     long lastSuccessfulUpdateTime = ProviderHealthTracker.this.lastSuccessfulUpdateTimeMs.get();
//     long maximumStalenessTimeMs = ProviderHealthTracker.this.maximumStalenessTimeMs;
//   }
// }


import com.netflix.spinnaker.fiat.model.resources.Application;
import com.netflix.spinnaker.fiat.providers.ProviderHealthTracker;
/*
 * Copyright 2020 Netflix, Inc.
 *
 * Licensed 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 com.netflix.spinnaker.fiat.providers.internal;


public class ClouddriverApplicationLoader extends ClouddriverDataLoader<Application> {
  public ClouddriverApplicationLoader(
// Path: fiat-core/src/main/java/com/netflix/spinnaker/fiat/model/resources/Application.java
// @Component
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class Application extends BaseAccessControlled<Application> implements Viewable {
//   final ResourceType resourceType = ResourceType.APPLICATION;
// 
//   private String name;
//   private Permissions permissions = Permissions.EMPTY;
// 
//   private Map<String, Object> details = new HashMap<>();
// 
//   @JsonAnySetter
//   public void setDetails(String name, Object value) {
//     this.details.put(name, value);
//   }
// 
//   @JsonIgnore
//   public View getView(Set<Role> userRoles, boolean isAdmin) {
//     return new View(this, userRoles, isAdmin);
//   }
// 
//   @Data
//   @EqualsAndHashCode(callSuper = false)
//   @NoArgsConstructor
//   public static class View extends BaseView implements Authorizable {
//     String name;
//     Set<Authorization> authorizations;
// 
//     public View(Application application, Set<Role> userRoles, boolean isAdmin) {
//       this.name = application.name;
//       if (isAdmin) {
//         this.authorizations = Authorization.ALL;
//       } else {
//         this.authorizations = application.permissions.getAuthorizations(userRoles);
//       }
//     }
//   }
// }
// 
// Path: fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/ProviderHealthTracker.java
// public class ProviderHealthTracker {
// 
//   /** Maximum age of stale data before this instance goes unhealthy. */
//   private final long maximumStalenessTimeMs;
// 
//   private AtomicLong lastSuccessfulUpdateTimeMs = new AtomicLong(-1);
// 
//   public ProviderHealthTracker(long maximumStalenessTimeMs) {
//     this.maximumStalenessTimeMs = maximumStalenessTimeMs;
//   }
// 
//   public void success() {
//     lastSuccessfulUpdateTimeMs.set(System.currentTimeMillis());
//   }
// 
//   public boolean isProviderHealthy() {
//     return lastSuccessfulUpdateTimeMs.get() != -1 && getStaleness() < maximumStalenessTimeMs;
//   }
// 
//   private long getStaleness() {
//     if (lastSuccessfulUpdateTimeMs.get() == -1) {
//       return -1;
//     }
//     return System.currentTimeMillis() - lastSuccessfulUpdateTimeMs.get();
//   }
// 
//   public HealthView getHealthView() {
//     return new HealthView();
//   }
// 
//   @Data
//   public class HealthView {
//     boolean providerHealthy = ProviderHealthTracker.this.isProviderHealthy();
//     long msSinceLastSuccess = ProviderHealthTracker.this.getStaleness();
//     long lastSuccessfulUpdateTime = ProviderHealthTracker.this.lastSuccessfulUpdateTimeMs.get();
//     long maximumStalenessTimeMs = ProviderHealthTracker.this.maximumStalenessTimeMs;
//   }
// }


// Path: fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/ClouddriverApplicationLoader.java
import com.netflix.spinnaker.fiat.model.resources.Application;
import com.netflix.spinnaker.fiat.providers.ProviderHealthTracker;

/*
 * Copyright 2020 Netflix, Inc.
 *
 * Licensed 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 com.netflix.spinnaker.fiat.providers.internal;


public class ClouddriverApplicationLoader extends ClouddriverDataLoader<Application> {
  public ClouddriverApplicationLoader(
      ProviderHealthTracker healthTracker, ClouddriverApi clouddriverApi) {