in UltraDNS, zones are scoped to an account.
487691
@Override
  public Iterator<Zone> iterator() {
    final Iterator<String> delegate = api.getZonesOfAccount(account.get()).iterator();
    return new Iterator<Zone>() {
      @Override
      public boolean hasNext() {
        return delegate.hasNext();
      }

      @Override
      public Zone next() {
        return fromSOA(delegate.next());
      }

      @Override
      public void remove() {
        throw new UnsupportedOperationException();
      }
    };
  }
868563
public void setAccounts(java.util.Collection<String> accounts) {
        if (accounts == null) {
            this.accounts = null;
            return;
        }

        this.accounts = new java.util.ArrayList<String>(accounts);
    }
219928
public void swapAccounts(Database other) {
        Account otherRoot = other.rootAccount;
        other.rootAccount = rootAccount;
        rootAccount = otherRoot;
        boolean otherDirty = other.dirty;
        other.dirty = dirty;
        dirty = otherDirty;
        HashMap<String, String> otherGlobalSettings = other.globalSettings;
        other.globalSettings = globalSettings;
        globalSettings = otherGlobalSettings;
    }
549758
function setAccountQuorum (commandOptions, { accountId, quorum }) {
  return command(
    commandOptions,
    txHelper.addCommand(
      txHelper.emptyTransaction(),
      'setAccountQuorum',
      {
        accountId,
        quorum
      }
    )
  )
}
1176973
private DomainGrouping computeDomainGrouping(Collection<CmsSite> sites, Collection<String> workplaceUrls) {

        DomainGrouping result = new DomainGrouping();
        if (LOG.isInfoEnabled()) {
            LOG.info("Computing domain grouping for sites...");
            List<String> servers = Lists.newArrayList();
            for (CmsSite site : sites) {
                servers.add(site.getUrl());
            }
            LOG.info("SITES = " + CmsStringUtil.listAsString(servers, ", "));
        }

        Mode mode = m_config.getMode();
        boolean addWp = false;
        boolean addSites = false;
        if ((mode == Mode.all) || (mode == Mode.sites)) {
            addSites = true;
        }
        if ((mode == Mode.all) || (mode == Mode.workplace)) {
            addWp = true;
        }

        if (addWp) {
            Set<String> workplaceDomains = Sets.newHashSet();
            for (String wpServer : workplaceUrls) {
                try {
                    URI uri = new URI(wpServer);
                    workplaceDomains.add(uri.getHost());
                } catch (Exception e) {
                    LOG.error(e.getLocalizedMessage(), e);
                }
            }
            result.addDomainSet(workplaceDomains);
        }

        if (addSites) {
            Multimap<String, SiteDomainInfo> infosByRootDomain = ArrayListMultimap.create();

            List<SiteDomainInfo> ungroupedSites = Lists.newArrayList();
            for (CmsSite site : sites) {
                SiteDomainInfo info = getDomainInfo(site);
                if (info.hasInvalidPort()) {
                    LOG.warn("Invalid port occuring in site definition: " + site);
                    continue;
                }
                String root = info.getCommonRootDomain();
                if ((root == null) || GROUPING_DISABLED) {
                    ungroupedSites.add(info);
                } else {
                    infosByRootDomain.put(root, info);
                }
            }
            List<String> keysToRemove = Lists.newArrayList();

            for (String key : infosByRootDomain.keySet()) {
                Collection<SiteDomainInfo> siteInfos = infosByRootDomain.get(key);
                Set<String> domains = getDomains(siteInfos);
                if (domains.size() > 100) {
                    LOG.info("Too many domains for root domain " + key + ", splitting them up by site instead.");
                    keysToRemove.add(key);
                    for (SiteDomainInfo info : siteInfos) {
                        ungroupedSites.add(info);
                    }
                }
            }
            for (String key : keysToRemove) {
                infosByRootDomain.removeAll(key);
            }
            for (SiteDomainInfo ungroupedSite : ungroupedSites) {
                Set<String> domains = getDomains(Collections.singletonList(ungroupedSite));
                result.addDomainSet(domains);
                LOG.info("DOMAINS (site config): " + domains);
            }
            for (String key : infosByRootDomain.keySet()) {
                Set<String> domains = getDomains(infosByRootDomain.get(key));
                result.addDomainSet(domains);
                LOG.info("DOMAINS (" + key + ")" + domains);
            }
        }
        return result;
    }
740797
private Account prepareAccountForUpdate(final Account account,
            final MultivaluedMap<String, String> data,
            UserIdentityContext userIdentityContext) {
        Account.Builder accBuilder = Account.builder();
        //copy full incoming account, and let override happen
        //in a separate instance later
        accBuilder.copy(account);


        if (data.containsKey("Status")) {
            Account.Status newStatus = Account.Status.getValueOf(data.getFirst("Status").toLowerCase());
            accBuilder.setStatus(newStatus);
        }
        if (data.containsKey("FriendlyName")) {
            accBuilder.setFriendlyName(data.getFirst("FriendlyName"));
        }
        if (data.containsKey("Password")) {
            // if this is a reset-password operation, we also need to set the account status to active
            if (account.getStatus() == Account.Status.UNINITIALIZED) {
                accBuilder.setStatus(Account.Status.ACTIVE);
            }

            String password = data.getFirst("Password");
            PasswordValidator validator = PasswordValidatorFactory.createDefault();
            if (!validator.isStrongEnough(password)) {
                CustomReasonPhraseType stat = new CustomReasonPhraseType(Response.Status.BAD_REQUEST, "Password too weak");
                throw new WebApplicationException(status(stat).build());
            }
            final String hash = new Md5Hash(data.getFirst("Password")).toString();
            accBuilder.setAuthToken(hash);
        }

        if (data.containsKey("Role")) {
            // Only allow role change for administrators. Multitenancy checks will take care of restricting the modification scope to sub-accounts.
            if (userIdentityContext.getEffectiveAccountRoles().contains(permissionEvaluator.getAdministratorRole())) {
                accBuilder.setRole(data.getFirst("Role"));
            } else {
                CustomReasonPhraseType stat = new CustomReasonPhraseType(Response.Status.FORBIDDEN, "Only Administrator allowed");
                throw new WebApplicationException(status(stat).build());
            }
        }

        return accBuilder.build();
    }
217292
public Optional<PartnerAccount> create(long partnerId, PartnerAccount account)
    {
        return HTTP.POST(String.format("/v2/partners/%d/accounts", partnerId), account, PARTNER_ACCOUNT);
    }
1206486
private static void createSubAccountBySettingClient() {
    try {
      SubaccountCreateResponse subaccount = Subaccount.creator("Test 2")
        .enabled(true)
        .client(client)
        .create();
      System.out.println(subaccount);
    } catch (PlivoRestException | IOException e) {
      e.printStackTrace();
    }
  }
1034089
public void setAccountIds(java.util.Collection<String> accountIds) {
        if (accountIds == null) {
            this.accountIds = null;
            return;
        }

        this.accountIds = new java.util.ArrayList<String>(accountIds);
    }
354920
def newaccount(ctx, accountname, account, password):
    
    pprint(
        ctx.peerplays.create_account(accountname, registrar=account, password=password)
    )
392266
function listZones() {
    return self.cloudflareClient.findZones({page: 1, per_page: self.perPage})
      .then(function (response) {
        let promises = [Promise.resolve(response)];
        for (let i = 2; i <= response.data['result_info']['total_pages']; i++) {
          promises.push(self.cloudflareClient.findZones({page: i, per_page: self.perPage}));
        }
        return Promise.all(promises);
      })
      .then(function (responses) {
        let rows = [];
        _.each(responses, function (response) {
          _.each(response.data.result, function (item) {
            rows.push(_.extend(
              item,
              {
                planName: item.plan.name,
                accountName: item.account.name
              }
            ));
          })
        });
        return new Result(rows);
      });
  }
397953
def main(role, ou, assume, profile, output, regions, active):
    

    session = get_session(assume, 'c7n-org', profile)
    client = session.client('organizations')
    accounts = []
    for path in ou:
        ou = get_ou_from_path(client, path)
        accounts.extend(get_accounts_for_ou(client, ou, active))

    results = []
    for a in accounts:
        tags = []
        path_parts = a['Path'].strip('/').split('/')
        for idx, _ in enumerate(path_parts):
            tags.append("path:/%s" % "/".join(path_parts[:idx + 1]))

        ainfo = {
            'account_id': a['Id'],
            'email': a['Email'],
            'name': a['Name'],
            'tags': tags,
            'role': role.format(**a)}
        if regions:
            ainfo['regions'] = regions
        results.append(ainfo)

    print(
        yaml.safe_dump(
            {'accounts': results},
            default_flow_style=False),
        file=output)
250745
@Beta
  public GoogleCredential createScoped(Collection<String> scopes) {
    if (serviceAccountPrivateKey == null) {
      return this;
    }
    return toBuilder()
        .setServiceAccountScopes(scopes)
        .build();
  }
763880
public int countUsersWithGlobalPermissionExcludingUser(DbSession dbSession, String organizationUuid,
    String permission, int excludedUserId) {
    return mapper(dbSession).countUsersWithGlobalPermissionExcludingUser(organizationUuid, permission, excludedUserId);
  }
779990
def run(config, use, output_dir, accounts, tags, region,
        policy, policy_tags, cache_period, cache_path, metrics,
        dryrun, debug, verbose, metrics_uri):
    """"""
    accounts_config, custodian_config, executor = init(
        config, use, debug, verbose, accounts, tags, policy, policy_tags=policy_tags)
    policy_counts = Counter()
    success = True

    if metrics_uri:
        metrics = metrics_uri

    if not cache_path:
        cache_path = os.path.expanduser("~/.cache/c7n-org")
        if not os.path.exists(cache_path):
            os.makedirs(cache_path)

    with executor(max_workers=WORKER_COUNT) as w:
        futures = {}
        for a in accounts_config['accounts']:
            for r in resolve_regions(region or a.get('regions', ())):
                futures[w.submit(
                    run_account,
                    a, r,
                    custodian_config,
                    output_dir,
                    cache_period,
                    cache_path,
                    metrics,
                    dryrun,
                    debug)] = (a, r)

        for f in as_completed(futures):
            a, r = futures[f]
            if f.exception():
                if debug:
                    raise
                log.warning(
                    "Error running policy in %s @ %s exception: %s",
                    a['name'], r, f.exception())

            account_region_pcounts, account_region_success = f.result()
            for p in account_region_pcounts:
                policy_counts[p] += account_region_pcounts[p]

            if not account_region_success:
                success = False

    log.info("Policy resource counts %s" % policy_counts)

    if not success:
        sys.exit(1)
272086
private void groupFieldtoDoc(UNode                parentNode,
                                 FieldDefinition      groupFieldDef,
                                 Set<FieldDefinition> deferredFields) {
        // Prerequisities:
        assert parentNode != null;
        assert groupFieldDef != null && groupFieldDef.isGroupField();
        assert deferredFields != null && deferredFields.size() > 0;
        
        UNode groupNode = parentNode.addMapNode(groupFieldDef.getName(), "field");
        for (FieldDefinition nestedFieldDef : groupFieldDef.getNestedFields()) {
            if (!deferredFields.contains(nestedFieldDef)) {
                continue;
            }
            if (nestedFieldDef.isGroupField()) {
                groupFieldtoDoc(groupNode, nestedFieldDef, deferredFields);
            } else {
                leafFieldtoDoc(groupNode, nestedFieldDef.getName());
            }
        }
    }
419413
@Override
    protected void logIncrementalStatsByAccount(String account, RunStats stats) {
        log.info("Session stats by account (incremental): account={} tasksAdded={}",
                 account, ((BitIntegrityRunStats) stats).getAdded());

    }