// Path: fiat-core/src/main/java/com/netflix/spinnaker/fiat/model/resources/Account.java
// @Component
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class Account extends BaseAccessControlled<Account> implements Viewable {
//   final ResourceType resourceType = ResourceType.ACCOUNT;
// 
//   private String name;
//   private String cloudProvider;
//   private Permissions permissions = Permissions.EMPTY;
// 
//   @JsonIgnore
//   @Override
//   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(Account account, Set<Role> userRoles, boolean isAdmin) {
//       this.name = account.name;
//       if (isAdmin) {
//         this.authorizations = Authorization.ALL;
//       } else {
//         this.authorizations = account.permissions.getAuthorizations(userRoles);
//       }
//     }
//   }
// }
// 
// Path: fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/ClouddriverService.java
// public class ClouddriverService {
//   private final ClouddriverApplicationLoader clouddriverApplicationLoader;
//   private final ClouddriverAccountLoader clouddriverAccountLoader;
// 
//   public ClouddriverService(
//       ClouddriverApplicationLoader clouddriverApplicationLoader,
//       ClouddriverAccountLoader clouddriverAccountLoader) {
//     this.clouddriverApplicationLoader = clouddriverApplicationLoader;
//     this.clouddriverAccountLoader = clouddriverAccountLoader;
//   }
// 
//   public List<Account> getAccounts() {
//     return clouddriverAccountLoader.getData();
//   }
// 
//   public List<Application> getApplications() {
//     return clouddriverApplicationLoader.getData();
//   }
// }


import com.google.common.collect.ImmutableSet;
import com.netflix.spinnaker.fiat.model.resources.Account;
import com.netflix.spinnaker.fiat.providers.internal.ClouddriverService;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/*
 * Copyright 2016 Google, 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;


@Component
public class DefaultAccountResourceProvider extends BaseResourceProvider<Account>
    implements ResourceProvider<Account> {

  private final ClouddriverService clouddriverService;
  private final ResourcePermissionProvider<Account> permissionProvider;

  @Autowired
  public DefaultAccountResourceProvider(
      ClouddriverService clouddriverService,
      ResourcePermissionProvider<Account> permissionProvider) {
    this.clouddriverService = clouddriverService;
    this.permissionProvider = permissionProvider;
  }

  @Override
// Path: fiat-core/src/main/java/com/netflix/spinnaker/fiat/model/resources/Account.java
// @Component
// @Data
// @EqualsAndHashCode(callSuper = false)
// public class Account extends BaseAccessControlled<Account> implements Viewable {
//   final ResourceType resourceType = ResourceType.ACCOUNT;
// 
//   private String name;
//   private String cloudProvider;
//   private Permissions permissions = Permissions.EMPTY;
// 
//   @JsonIgnore
//   @Override
//   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(Account account, Set<Role> userRoles, boolean isAdmin) {
//       this.name = account.name;
//       if (isAdmin) {
//         this.authorizations = Authorization.ALL;
//       } else {
//         this.authorizations = account.permissions.getAuthorizations(userRoles);
//       }
//     }
//   }
// }
// 
// Path: fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/ClouddriverService.java
// public class ClouddriverService {
//   private final ClouddriverApplicationLoader clouddriverApplicationLoader;
//   private final ClouddriverAccountLoader clouddriverAccountLoader;
// 
//   public ClouddriverService(
//       ClouddriverApplicationLoader clouddriverApplicationLoader,
//       ClouddriverAccountLoader clouddriverAccountLoader) {
//     this.clouddriverApplicationLoader = clouddriverApplicationLoader;
//     this.clouddriverAccountLoader = clouddriverAccountLoader;
//   }
// 
//   public List<Account> getAccounts() {
//     return clouddriverAccountLoader.getData();
//   }
// 
//   public List<Application> getApplications() {
//     return clouddriverApplicationLoader.getData();
//   }
// }


// Path: fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/DefaultAccountResourceProvider.java
import com.google.common.collect.ImmutableSet;
import com.netflix.spinnaker.fiat.model.resources.Account;
import com.netflix.spinnaker.fiat.providers.internal.ClouddriverService;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/*
 * Copyright 2016 Google, 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;


@Component
public class DefaultAccountResourceProvider extends BaseResourceProvider<Account>
    implements ResourceProvider<Account> {

  private final ClouddriverService clouddriverService;
  private final ResourcePermissionProvider<Account> permissionProvider;

  @Autowired
  public DefaultAccountResourceProvider(
      ClouddriverService clouddriverService,
      ResourcePermissionProvider<Account> permissionProvider) {
    this.clouddriverService = clouddriverService;
    this.permissionProvider = permissionProvider;
  }

  @Override
  protected Set<Account> loadAll() throws ProviderException {