Codota Logo
AccountLink
Code IndexAdd Codota to your IDE (free)

How to use
AccountLink
in
io.cattle.platform.core.model

Best Java code snippets using io.cattle.platform.core.model.AccountLink (Showing top 18 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: rancher/cattle

/**
 * {@inheritDoc}
 */
@Override
public void from(io.cattle.platform.core.model.AccountLink from) {
  setId(from.getId());
  setName(from.getName());
  setAccountId(from.getAccountId());
  setKind(from.getKind());
  setUuid(from.getUuid());
  setDescription(from.getDescription());
  setState(from.getState());
  setCreated(from.getCreated());
  setRemoved(from.getRemoved());
  setRemoveTime(from.getRemoveTime());
  setData(from.getData());
  setLinkedAccountId(from.getLinkedAccountId());
  setLinkedAccount(from.getLinkedAccount());
  setLinkedRegionId(from.getLinkedRegionId());
  setLinkedRegion(from.getLinkedRegion());
  setExternal(from.getExternal());
}
origin: rancher/cattle

/**
 * {@inheritDoc}
 */
@Override
public <E extends io.cattle.platform.core.model.AccountLink> E into(E into) {
  into.from(this);
  return into;
}
origin: rancher/cattle

private void getLinkedEnvironments(long accountId, Map<String, Long> links, Map<Long, Region> regionsIds,
    Map<String, ExternalProject> externalProjects) {
  List<AccountLink> accountLinks = objectManager.find(AccountLink.class, ACCOUNT_LINK.ACCOUNT_ID,
      accountId, ACCOUNT_LINK.REMOVED, null, ACCOUNT_LINK.LINKED_REGION_ID, new Condition(ConditionType.NOTNULL));
  for (AccountLink link : accountLinks) {
      if (link.getState().equalsIgnoreCase(CommonStatesConstants.REMOVING)) {
        continue;
      }
      if(link.getState().equalsIgnoreCase(CommonStatesConstants.REMOVED)) {
        continue;
      }
    Region targetRegion = regionsIds.get(link.getLinkedRegionId());
    if (targetRegion == null) {
      continue;
    }
    String UUID = getUUID(targetRegion.getName(), link.getLinkedAccount());
    if (!externalProjects.containsKey(UUID)) {
      links.put(UUID, targetRegion.getId());
    }
  }
}
origin: rancher/cattle

    new Condition(ConditionType.NOTNULL));
for(AccountLink link : accountLinks) {
  if (invalidStates.contains(link.getState())) {
    continue;
  Region targetRegion = regionMap.get(link.getLinkedRegionId());
  if(targetRegion == null) {
    objectProcessManager.executeStandardProcess(StandardProcess.REMOVE, link, null);
    String externalProjectKey = String.format("%s:%s", targetRegion.getName(), link.getLinkedAccount());
    if(externalProjectMap.containsKey(externalProjectKey)) {
      externalProjectResponse = externalProjectMap.get(externalProjectKey);
    } else {
      externalProjectResponse = RegionUtil.getTargetProjectByName(targetRegion, link.getLinkedAccount(), jsonMapper);
      externalProjectMap.put(externalProjectKey, externalProjectResponse);
    if(link.getExternal()) {
        Account localAccount = objectManager.loadResource(Account.class, link.getAccountId());
        ExternalAccountLink accLink = RegionUtil.getAccountLinkForExternal(targetRegion, externalProject, localAccount, jsonMapper);
        if(accLink == null || removedStates.contains(accLink.getState())){
    log.warn(String.format("Failed to monitor account link for %s - %s", link.getId(), ex));
    existingLinks.add(String.format("%s:%s", link.getLinkedRegion(), link.getLinkedAccount()));
    continue;
origin: rancher/cattle

@Override
public boolean deleteExternalAccountLink(AccountLink link) {
  if (link.getExternal()) {
    return true;
    Region targetRegion = objectManager.loadResource(Region.class, link.getLinkedRegionId());
    if(targetRegion == null) {
      return true;
    ExternalProjectResponse externalProjectResponse = RegionUtil.getTargetProjectByName(targetRegion, link.getLinkedAccount(), jsonMapper);
    ExternalProject targetResourceAccount = externalProjectResponse.externalProject;
    if (targetResourceAccount == null) {
    Account localAccount = objectManager.loadResource(Account.class, link.getAccountId());
    ExternalAccountLink externalLink = RegionUtil.getExternalAccountLink(targetRegion, targetResourceAccount,
        localAccount, jsonMapper);
    return true;
  } catch (Exception ex) {
      log.error(String.format("Failed to delete external account link for accountLink [%d]", link.getId()), ex);
      return false;
origin: rancher/cattle

@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
  AccountLink accountLink = (AccountLink) state.getResource();
  if (accountLink.getLinkedAccountId() == null) {
    regionSvc.createExternalAccountLink(accountLink);
  } else {
    List<? extends Service> services = objectManager.find(Service.class, SERVICE.ACCOUNT_ID,
        accountLink.getAccountId(), SERVICE.SELECTOR_LINK, new Condition(ConditionType.NOTNULL),
        SERVICE.REMOVED, null);
    for (Service service : services) {
      sdSvc.registerServiceLinks(service);
    }
  }
  return null;
}
origin: rancher/cattle

protected void deleteOldAccountLinks(Account account, List<? extends Long> newAccountIds) {
  List<? extends AccountLink> allLinks = objectManager.find(AccountLink.class,
      ACCOUNT_LINK.ACCOUNT_ID, account.getId(),
      ACCOUNT_LINK.REMOVED, null);
  for (AccountLink link : allLinks) {
    if (!newAccountIds.contains(link.getLinkedAccountId())) {
      objectProcessManager.scheduleStandardProcessAsync(StandardProcess.REMOVE, link, null);
    }
  }
}
origin: rancher/cattle

Set<String> existingLinksKeys = new HashSet<>();
for (AccountLink existingLink : existingLinks) {
  existingLinksKeys.add(getUUID(existingLink.getLinkedRegion(), existingLink.getLinkedAccount()));
  if (!toAdd.contains(getUUID(link.getLinkedRegion(), link.getLinkedAccount()))) {
    toRemove.add(link);
  } else {
origin: rancher/cattle

  private void cleanupExternalLinks(Region region) {
    for (AccountLink link : objectManager.find(AccountLink.class, ACCOUNT_LINK.REMOVED, null, ACCOUNT_LINK.LINKED_REGION_ID, region.getId())) {
      if (!link.getState().equalsIgnoreCase(CommonStatesConstants.REMOVING)) {
        objectProcessManager.executeStandardProcess(StandardProcess.REMOVE, link, null);
      }
    }
  }
}
origin: rancher/cattle

private void registerAsTargetService(Service targetService) {
  List<Long> accountIds = new ArrayList<>();
  accountIds.add(targetService.getAccountId());
  List<? extends AccountLink> linkedToAccounts = objectManager.find(AccountLink.class,
      ACCOUNT_LINK.LINKED_ACCOUNT_ID, targetService.getAccountId(),
      ACCOUNT_LINK.REMOVED, null);
  // add all accounts that are linked to service's account
  for (AccountLink linkedToAccount : linkedToAccounts) {
    accountIds.add(linkedToAccount.getAccountId());
  }
  List<Service> services = new ArrayList<>();
  for (Long accountId : accountIds) {
    services.addAll(objectManager.find(Service.class, SERVICE.ACCOUNT_ID, accountId,
        SERVICE.REMOVED, null));
  }
  for (Service service : services) {
    // skip itself
    if (targetService.getId().equals(service.getId())) {
      continue;
    }
    if (isSelectorLinkMatch(service.getSelectorLink(), targetService)) {
      addServiceLink(service, targetService);
    }
  }
}
origin: rancher/cattle

if (link.getExternal()) {
  return;
  Region targetRegion = objectManager.loadResource(Region.class, link.getLinkedRegionId());
  Region localRegion = objectManager.findAny(Region.class, REGION.LOCAL, true, REGION.REMOVED, null);
  if(localRegion == null) {
        localRegion.getName(), targetRegion.getName()));
  ExternalProjectResponse externalProjectResponse = RegionUtil.getTargetProjectByName(targetRegion, link.getLinkedAccount(), jsonMapper);
  ExternalProject targetResourceAccount = externalProjectResponse.externalProject;
  if (targetResourceAccount == null) {
    throw new RuntimeException(String.format("Failed to find target environment by name [%s] in region [%s]",
        link.getLinkedAccount(), localRegion.getName()));
  Account localAccount = objectManager.loadResource(Account.class, link.getAccountId());
  ExternalAccountLink externalLink = RegionUtil.getExternalAccountLink(targetRegion,
      targetResourceAccount, localAccount, jsonMapper);
  externalLink = RegionUtil.createExternalAccountLink(targetRegion, data, jsonMapper);
} catch (Exception ex) {
  throw new RuntimeException(String.format("Failed to create external account link for accountLink [%d]", link.getId()), ex);
origin: rancher/cattle

@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
  AccountLink accountLink = (AccountLink) state.getResource();
  if (accountLink.getLinkedAccountId() == null) {
   regionSvc.deleteExternalAccountLink(accountLink);
  } else {
    updateServices(accountLink);
    Account account = objectManager.loadResource(Account.class, accountLink.getAccountId());
    if (account == null) {
      return null;
    }
    regenerateAccountLinks(account);
  }
  return null;
}
origin: rancher/cattle

  @Override
  public void doWithLockNoResult() {
    List<? extends AccountLink> allLinks = objectManager.find(AccountLink.class,
        ACCOUNT_LINK.ACCOUNT_ID, account.getId(),
        ACCOUNT_LINK.REMOVED, null, ACCOUNT_LINK.STATE, new Condition(ConditionType.NE,
            CommonStatesConstants.REMOVING));
    List<Long> newLinks = new ArrayList<>();
    for (AccountLink aLink : allLinks) {
      newLinks.add(aLink.getLinkedAccountId());
    }
    
    List<Long> existingLinks = DataAccessor.fieldLongList(account,
        AccountConstants.FIELD_ACCOUNT_LINKS);
    if (existingLinks.containsAll(newLinks) && newLinks.containsAll(existingLinks)) {
      return;
    }
    objectManager.setFields(account, AccountConstants.FIELD_ACCOUNT_LINKS, newLinks);
    ObjectUtils.publishChanged(eventService, objectManager, account);
  }
});
origin: rancher/cattle

private void reconcileAccountLinks(long accountId, Map<String, Region> regionsMap, List<AccountLink> toRemove, List<AccountLink> toUpdate,
    Set<String> toCreate) {
  for (AccountLink item : toRemove) {
    if (!item.getState().equalsIgnoreCase(CommonStatesConstants.REMOVING)) {
      objectProcessManager.scheduleStandardProcess(StandardProcess.REMOVE, item, null);
    if (item.getState().equalsIgnoreCase(CommonStatesConstants.REQUESTED)) {
      objectProcessManager.scheduleStandardProcessAsync(StandardProcess.CREATE, item, null);
origin: rancher/cattle

@SuppressWarnings("unchecked")
private void updateServices(AccountLink accountLink) {
  List<? extends ServiceConsumeMap> consumeMaps = objectManager.find(ServiceConsumeMap.class,
      SERVICE_CONSUME_MAP.ACCOUNT_ID,
      accountLink.getAccountId(), SERVICE_CONSUME_MAP.REMOVED, null);
  List<? extends Service> services = objectManager.find(Service.class, SERVICE.ACCOUNT_ID,
      accountLink.getLinkedAccountId(), SERVICE.REMOVED, null);
  List<Long> serviceIds = (List<Long>) CollectionUtils.collect(services,
      TransformerUtils.invokerTransformer("getId"));
  for (ServiceConsumeMap consumeMap : consumeMaps) {
    if (serviceIds.contains(consumeMap.getConsumedServiceId())) {
      objectProcessManager.scheduleStandardProcessAsync(StandardProcess.REMOVE, consumeMap, null);
    }
  }
}
origin: rancher/cattle

private void registerTargetServices(Service service) {
  List<Long> targetAccountIds = new ArrayList<>();
  targetAccountIds.add(service.getAccountId());
  // add all accounts that are linked to service's account
  List<? extends AccountLink> linkedAccounts = objectManager.find(AccountLink.class,
      ACCOUNT_LINK.ACCOUNT_ID, service.getAccountId(),
      ACCOUNT_LINK.REMOVED, null, ACCOUNT_LINK.LINKED_ACCOUNT_ID, new Condition(ConditionType.NOTNULL));
  for (AccountLink linkedAccount : linkedAccounts) {
    targetAccountIds.add(linkedAccount.getLinkedAccountId());
  }
  List<Service> targetServices = new ArrayList<>();
  for (Long accountId : targetAccountIds) {
    targetServices.addAll(objectManager.find(Service.class, SERVICE.ACCOUNT_ID, accountId,
        SERVICE.REMOVED, null));
  }
  for (Service targetService : targetServices) {
    // skip itself
    if (targetService.getId().equals(service.getId())) {
      continue;
    }
    if (isSelectorLinkMatch(service.getSelectorLink(), targetService)) {
      addServiceLink(service, targetService);
    }
  }
}
origin: rancher/cattle

protected void createNewAccountLinks(Account account, List<? extends Long> newAccountIds) {
  for (Long accountId : newAccountIds) {
    AccountLink link = objectManager.findAny(AccountLink.class, ACCOUNT_LINK.ACCOUNT_ID,
        account.getId(),
        ACCOUNT_LINK.LINKED_ACCOUNT_ID, accountId,
        ACCOUNT_LINK.REMOVED, null);
    if (link == null) {
      link = objectManager.create(AccountLink.class, ACCOUNT_LINK.ACCOUNT_ID,
          account.getId(), ACCOUNT_LINK.LINKED_ACCOUNT_ID, accountId);
    }
    if (link.getState().equalsIgnoreCase(CommonStatesConstants.REQUESTED)) {
      objectProcessManager.executeStandardProcess(StandardProcess.CREATE, link, null);
    }
  }
}
origin: rancher/cattle

    account.getId(), ACCOUNT_LINK.REMOVED, null, ACCOUNT_LINK.LINKED_ACCOUNT_ID, new Condition(ConditionType.NOTNULL));
for (AccountLink accountLink : accountLinks) {
  Long accountId = accountLink.getLinkedAccountId();
  accounts.put(accountId, allAccountsMap.get(accountId));
    account.getId(), ACCOUNT_LINK.REMOVED, null);
for (AccountLink accountLink : accountLinks) {
  Long accountId = accountLink.getAccountId();
  accounts.put(accountId, allAccountsMap.get(accountId));
io.cattle.platform.core.modelAccountLink

Javadoc

This class is generated by jOOQ.

Most used methods

  • getAccountId
    Getter for cattle.account_link.account_id.
  • getLinkedAccountId
    Getter for cattle.account_link.linked_account_id.
  • getExternal
    Getter for cattle.account_link.external.
  • getId
    Getter for cattle.account_link.id.
  • getLinkedAccount
    Getter for cattle.account_link.linked_account.
  • getLinkedRegion
    Getter for cattle.account_link.linked_region.
  • getLinkedRegionId
    Getter for cattle.account_link.linked_region_id.
  • getState
    Getter for cattle.account_link.state.
  • from
    Load data from another generated Record/POJO implementing the common interface AccountLink
  • getCreated
    Getter for cattle.account_link.created.
  • getData
    Getter for cattle.account_link.data.
  • getDescription
    Getter for cattle.account_link.description.
  • getData,
  • getDescription,
  • getKind,
  • getName,
  • getRemoveTime,
  • getRemoved,
  • getUuid

Popular in Java

  • Finding current android device location
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • Menu (java.awt)
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • JLabel (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now