/* tslint:disable */
import {
  AbacAttribute,
  AcceptAppInviteRequest,
  AcceptAppInviteResponse,
  AcceptInviteRequest,
  AcceptInviteResponse,
  AccountPartialPath,
  AccountPolicyAssignment,
  AccountResourceContext,
  AccountResourceContextV2,
  AccountWithRoles,
  ActionsFilter,
  AddStatementToPolicyRequest,
  AddStatementToPolicyResponse,
  AllResources,
  AllSitesForAccount,
  And,
  AppInvite,
  ApplicationError,
  AssignPoliciesRequest,
  AssignPoliciesResponse,
  AssignPoliciesToTeamMemberRequest,
  AssignPoliciesToTeamMemberResponse,
  AssignPolicyResponse,
  Assignment,
  AssignmentData,
  AssignmentUpdateField,
  AttributeUpdateResourceResult,
  AttributeUpdateWithOperatorResult,
  AttributeValue,
  AttributesOperator,
  AuthorizationEmptyResponse,
  AuthorizationRequest,
  AuthorizationResponse,
  AuthorizationSiteOwner,
  BackOfficeIsPermitted,
  BoolValue,
  BooleanLiteral,
  BulkActionMetadata,
  BulkBackOfficeIsPermittedRequest,
  BulkGetPermittedSubjectsCountRequest,
  BulkGetPermittedSubjectsCountResponse,
  BulkGetSubjectRolesRequest,
  BulkGetSubjectRolesResponse,
  BulkIsPermittedRequest,
  BulkIsPermittedResponse,
  BulkIsPolicyAssignedRequest,
  BulkIsPolicyAssignedResponse,
  BulkOverrideSubjectPoliciesRequest,
  BulkOverrideSubjectPoliciesResponse,
  BulkResourceAttributeUpdateRequest,
  BulkResourceAttributeUpdateResponse,
  BulkSubjectBackOfficeIsPermittedRequest,
  BulkSubjectIsPermittedResponse,
  BulkSubjectPoliciesResult,
  BulkUpdateResourcesWithAttributeRequest,
  BulkUpdateResourcesWithAttributeResponse,
  ByPermissions,
  ChangeInvitePoliciesRequest,
  ChangePolicyOwnerRequest,
  ChangePolicyOwnerResponse,
  ClearAssignedAppPoliciesRequest,
  ClearAssignedAppPoliciesResponse,
  ClearAssignedPoliciesRequest,
  ClearAssignedPoliciesResponse,
  ClearTeamMemberPoliciesRequest,
  ClearTeamMemberPoliciesResponse,
  ConditionAttributeType,
  ConditionOperator,
  ConditionType,
  ConditionUpdate,
  ConditionValue,
  ConsistencyLevel,
  Contributor,
  ContributorLimit,
  CreateAppInviteRequest,
  CreateAppInviteResponse,
  CreateInviteRequest,
  CreateInviteResponse,
  CreatePolicyRequest,
  CreatePolicyResponse,
  CustomResource,
  DeleteAccountInviteRequest,
  DeleteAccountInvitesRequest,
  DeleteAppInviteRequest,
  DeleteAppInviteResponse,
  DeleteAssignmentsRequest,
  DeleteAssignmentsResponse,
  DeleteAttributesByTenantRequest,
  DeleteInviteRequest,
  DeletePolicyRequest,
  DeletePolicyResponse,
  DeletePolicyStatementRequest,
  DeletePolicyStatementResponse,
  DeleteTeamMemberAssignmentsRequest,
  DeleteTeamMemberAssignmentsResponse,
  DependOnOperator,
  DevAssignPolicyRequest,
  DevEmptyResponse,
  DevPolicyPermissions,
  Effect,
  EnvironmentCondition,
  EqAttr,
  EqLiteral,
  EqualOperator,
  ExactMatch,
  ExperimentCondition,
  ExperimentOperator,
  Field,
  FieldMask,
  FilterPoliciesRequest,
  FilterPoliciesResponse,
  FixTeamMemberAssignmentsRequest,
  FoldExperimentRequest,
  FoldExperimentResponse,
  ForceDeleteAssignmentsRequest,
  ForceDeleteAssignmentsResponse,
  FullNameResource,
  GetAppInviteRequest,
  GetAppInviteResponse,
  GetAppInvitesRequest,
  GetAppInvitesResponse,
  GetAssignmentsRequest,
  GetAssignmentsResponse,
  GetAttributesRequest,
  GetAttributesResponse,
  GetBulkSubjectPoliciesBySubjectContextRequest,
  GetBulkSubjectPoliciesBySubjectContextResponse,
  GetContainedPoliciesRequest,
  GetContainedPoliciesResponse,
  GetCurrentSubjectContainedPoliciesRequest,
  GetCurrentSubjectContainedPoliciesResponse,
  GetCurrentSubjectPermissionsOnResourceRequest,
  GetCurrentSubjectPermissionsOnResourceResponse,
  GetCurrentSubjectPermissionsOnResourcesRequest,
  GetCurrentSubjectPermissionsOnResourcesResponse,
  GetInviteRequest,
  GetInviteResponse,
  GetInvitesByAccountRequest,
  GetInvitesByAccountResponse,
  GetPermissionsRequest,
  GetPermissionsResponse,
  GetPermittedSubjectsRolesRequest,
  GetPermittedSubjectsRolesResponse,
  GetPermittedSubjectsStatementsRequest,
  GetPermittedSubjectsStatementsResponse,
  GetPoliciesApplicableRestrictionsRequest,
  GetPoliciesApplicableRestrictionsResponse,
  GetPoliciesAssignedOnResourceFilter,
  GetPoliciesAssignedOnResourceRequest,
  GetPoliciesAssignedOnResourceResponse,
  GetPoliciesMissingSubPoliciesPermissionsRequest,
  GetPoliciesMissingSubPoliciesPermissionsResponse,
  GetPoliciesPermissionsRequest,
  GetPoliciesPermissionsResponse,
  GetPoliciesScopeDiffsRequest,
  GetPoliciesScopesDiffResponse,
  GetRestrictedSubjectsRequest,
  GetRestrictedSubjectsResponse,
  GetRestrictionsRequest,
  GetRestrictionsResponse,
  GetSubjectAssignedPoliciesRequest,
  GetSubjectAssignedPoliciesResponse,
  GetSubjectPermissionsOnResourceRequest,
  GetSubjectPermissionsOnResourceResponse,
  GetSubjectPermittedResourcesRequest,
  GetSubjectPermittedResourcesResponse,
  GetSubjectPermittingAssignmentsRequest,
  GetSubjectPermittingAssignmentsResponse,
  GetSubjectPoliciesBySubjectContextRequest,
  GetSubjectPoliciesBySubjectContextResponse,
  GetSubjectPoliciesOnCurrentAccountRequest,
  GetSubjectPoliciesOnCurrentAccountResponse,
  GetSubjectRolesRequest,
  GetSubjectRolesResponse,
  HardDeleteStatementRequest,
  HardDeleteStatementResponse,
  ImplicitIsPermittedRequest,
  Invite,
  InviteAccount,
  InviteAssignmentResource,
  InviteData,
  InviteFilter,
  InviteFullNameResource,
  InviteInviteAssignment,
  InviteInviteResourceAssignment,
  InviteReq,
  InviteSite,
  IsPermittedByAppInstanceRequest,
  IsPermittedRequest,
  IsPermittedResource,
  IsPermittedResponse,
  IsPolicyAssigned,
  ItemMetadata,
  JoinedCondition,
  JoinedConditionOperator,
  KindListValue,
  LegacyPermission,
  Like,
  LikeOperator,
  MailAndAccountId,
  ManagementAssignPolicyRequest,
  ManagementCondition,
  ManagementGetPoliciesRequest,
  ManagementGetPoliciesResponse,
  ManagementGetPolicyRequest,
  ManagementGetPolicyResponse,
  MigrateInviteRequest,
  MissingPermissions,
  ModelAttribute,
  NoCondition,
  NullValue,
  NumberValue,
  Or,
  OrganizationPartialPath,
  OrganizationResourceContext,
  Paging,
  PermissionPolicies,
  PermissionsFilter,
  PermissionsFilteredPolicies,
  PermittedResource,
  Policy,
  PolicyAssignment,
  PolicyCondition,
  PolicyData,
  PolicyMissingPermissions,
  PolicyRestrictions,
  PolicyStatement,
  PolicyType,
  QueryCondition,
  QueryGetPoliciesRequest,
  QueryGetPoliciesResponse,
  QueryGetPolicyRequest,
  QueryGetPolicyResponse,
  QueryPolicyPermissions,
  ReplaceAllAssignedPoliciesConditionRequest,
  ReplaceAllAssignedPoliciesConditionResponse,
  ReplaceAllAssignedPoliciesRequest,
  ReplaceAllAssignedPoliciesResponse,
  ReplaceAllTeamMemberPoliciesRequest,
  ReplaceAllTeamMemberPoliciesResponse,
  ReplaceTeamMemberPoliciesRequest,
  ReplaceTeamMemberPoliciesResponse,
  ResetAppInviteRequest,
  ResetAppInviteResponse,
  ResetInviteRequest,
  ResetInviteResponse,
  Resource,
  ResourceAssignment,
  ResourceAttributeUpdate,
  ResourceAttributeUpdateEvent,
  ResourceContext,
  ResourceContributorCount,
  ResourceEntity,
  ResourceFilter,
  ResourceIsPermitted,
  ResourcePermissions,
  ResourceResponse,
  ResourceType,
  ResourceUpdate,
  ResourceWithOwner,
  RestrictedResource,
  RestrictedSubject,
  RestrictedTeamMember,
  Role,
  RolesOnResource,
  RunSingleMigrationRequest,
  RunSingleMigrationResponse,
  ServiceEmptyResponse,
  ServiceInviteAssignment,
  ServiceInviteResourceAssignment,
  SetAttribute,
  SimpleCondition,
  SimpleConditionOperator,
  SimpleConditionValue,
  Site,
  SiteAccountsWithRoles,
  SitePartialPath,
  SitePolicyAssignment,
  SiteResourceContext,
  SiteRestrictedSubjects,
  SiteUsersWithRoles,
  StartsWith,
  Statement,
  StringLiteral,
  StringValue,
  StructListValue,
  StructValue,
  Subject,
  SubjectAssignment,
  SubjectAssignments,
  SubjectContext,
  SubjectContextType,
  SubjectIsPermitted,
  SubjectPolicies,
  SubjectRoles,
  SubjectType,
  SubjectTypesFilter,
  SubjectView,
  TriggerGdprDeleteUserDataRequest,
  TriggerGdprDeleteUserDataResponse,
  UnassignPolicyFromSubjectRequest,
  UnassignPolicyFromSubjectResponse,
  UnknownFieldSet,
  UnsetAttribute,
  UpdateAssignmentRequest,
  UpdateAssignmentResponse,
  UpdateAttribute,
  UpdateFailure,
  UpdateInviteAssignmentsRequest,
  UpdatePoliciesOnSiteTransferRequest,
  UpdatePoliciesOnSiteTransferResponse,
  UpdatePolicyAuthorizationDataRequest,
  UpdatePolicyMetadataRequest,
  UpdatePolicyResponse,
  UpdateResourcesWithAttributeMessage,
  UpdateResult,
  UpdateSiteContextAssignmentsRequest,
  UpdateSiteContextAssignmentsResponse,
  UpdateSuccess,
  UserWithRoles,
} from './types';

// robustly support requiring ambassador runtime from both private reg and scoped package
let requireAmbassadorRuntime = () => {
  let result;
  try {
    result = require('@wix/ambassador/runtime/rpc');
  } catch (err) {
    result = require('@wix/ambassador/runtime');
  }
  requireAmbassadorRuntime = () => result;
  return result;
};

type BigDecimal = number;
type Boolean = boolean;
type DateTime = string;
type Double = number;
type Float = number;
type GUID = string;
type Guid = string;
type Int = number;
type Integer = number;
type Long = number;
type Object = object;
type String = string;
type Struct = any;
type Timestamp = string;
type URL = string;
type UUID = string;
type Url = string;
type UserGUID = string;
type UserGuid = string;
type Value = any;
type bigdecimal = number;
type datetime = string;
type double = number;
type float = number;
type guid = string;
type int = number;
type integer = number;
type long = number;
type url = string;
type userguid = string;
type uuid = string;

export const AuthorizationServer = (overrideArtifactUrl?: string) => ({
  AbacAttributesService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AbacAttributesService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const bulkUpdateResourceAttribute = (request: BulkResourceAttributeUpdateRequest): Promise<BulkResourceAttributeUpdateResponse> =>
        getRpcClient()(_aspects).invoke('bulkUpdateResourceAttribute', request);
      const bulkUpdateResourcesWithAttribute = (request: BulkUpdateResourcesWithAttributeRequest): Promise<BulkUpdateResourcesWithAttributeResponse> =>
        getRpcClient()(_aspects).invoke('bulkUpdateResourcesWithAttribute', request);
      const deleteAttributesByTenant = (request: DeleteAttributesByTenantRequest): Promise<any> => getRpcClient()(_aspects).invoke('deleteAttributesByTenant', request);
      const getAttributes = (request: GetAttributesRequest): Promise<GetAttributesResponse> => getRpcClient()(_aspects).invoke('getAttributes', request);
      const updateResourceAttribute = (request: ResourceAttributeUpdate): Promise<any> => getRpcClient()(_aspects).invoke('updateResourceAttribute', request);
      const updateResourcesWithAttribute = (request: UpdateResourcesWithAttributeMessage): Promise<any> => getRpcClient()(_aspects).invoke('updateResourcesWithAttribute', request);
      return {
        bulkUpdateResourceAttribute: bulkUpdateResourceAttribute,
        bulkUpdateResourcesWithAttribute: bulkUpdateResourcesWithAttribute,
        deleteAttributesByTenant: deleteAttributesByTenant,
        getAttributes: getAttributes,
        updateResourceAttribute: updateResourceAttribute,
        updateResourcesWithAttribute: updateResourcesWithAttribute,
      };
    };
  },
  AbacAuthorizationDevService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AbacAuthorizationDevService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const assignPolicy = (request: DevAssignPolicyRequest): Promise<DevEmptyResponse> => getRpcClient()(_aspects).invoke('assignPolicy', request);
      const changePolicyOwner = (request: ChangePolicyOwnerRequest): Promise<ChangePolicyOwnerResponse> => getRpcClient()(_aspects).invoke('changePolicyOwner', request);
      const fixBrokenTeamMembersAssignments = (request: FixTeamMemberAssignmentsRequest): Promise<DevEmptyResponse> =>
        getRpcClient()(_aspects).invoke('fixBrokenTeamMembersAssignments', request);
      const forceDeleteAssignments = (request: ForceDeleteAssignmentsRequest): Promise<ForceDeleteAssignmentsResponse> =>
        getRpcClient()(_aspects).invoke('forceDeleteAssignments', request);
      const getPoliciesMissingSubPoliciesPermissions = (request: GetPoliciesMissingSubPoliciesPermissionsRequest): Promise<GetPoliciesMissingSubPoliciesPermissionsResponse> =>
        getRpcClient()(_aspects).invoke('getPoliciesMissingSubPoliciesPermissions', request);
      const getPoliciesScopesDiff = (request: GetPoliciesScopeDiffsRequest): Promise<GetPoliciesScopesDiffResponse> =>
        getRpcClient()(_aspects).invoke('getPoliciesScopesDiff', request);
      const hardDeleteStatement = (request: HardDeleteStatementRequest): Promise<HardDeleteStatementResponse> => getRpcClient()(_aspects).invoke('hardDeleteStatement', request);
      const updateSiteContextAssignments = (request: UpdateSiteContextAssignmentsRequest): Promise<UpdateSiteContextAssignmentsResponse> =>
        getRpcClient()(_aspects).invoke('updateSiteContextAssignments', request);
      return {
        assignPolicy: assignPolicy,
        changePolicyOwner: changePolicyOwner,
        fixBrokenTeamMembersAssignments: fixBrokenTeamMembersAssignments,
        forceDeleteAssignments: forceDeleteAssignments,
        getPoliciesMissingSubPoliciesPermissions: getPoliciesMissingSubPoliciesPermissions,
        getPoliciesScopesDiff: getPoliciesScopesDiff,
        hardDeleteStatement: hardDeleteStatement,
        updateSiteContextAssignments: updateSiteContextAssignments,
      };
    };
  },
  AbacAuthorizationService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AbacAuthorizationService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const bulkIsPermitted = (request: BulkIsPermittedRequest): Promise<BulkIsPermittedResponse> => getRpcClient()(_aspects).invoke('bulkIsPermitted', request);
      const getRestrictions = (request: GetRestrictionsRequest): Promise<GetRestrictionsResponse> => getRpcClient()(_aspects).invoke('getRestrictions', request);
      const implicitIsPermitted = (request: ImplicitIsPermittedRequest): Promise<IsPermittedResponse> => getRpcClient()(_aspects).invoke('implicitIsPermitted', request);
      const isPermitted = (request: IsPermittedRequest): Promise<IsPermittedResponse> => getRpcClient()(_aspects).invoke('isPermitted', request);
      return {
        bulkIsPermitted: bulkIsPermitted,
        getRestrictions: getRestrictions,
        implicitIsPermitted: implicitIsPermitted,
        isPermitted: isPermitted,
      };
    };
  },
  AbacManagementService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AbacManagementService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const addStatementToPolicy = (request: AddStatementToPolicyRequest): Promise<AddStatementToPolicyResponse> =>
        getRpcClient()(_aspects).invoke('addStatementToPolicy', request);
      const assignPolicy = (request: ManagementAssignPolicyRequest): Promise<AssignPolicyResponse> => getRpcClient()(_aspects).invoke('assignPolicy', request);
      const createPolicy = (request: CreatePolicyRequest): Promise<CreatePolicyResponse> => getRpcClient()(_aspects).invoke('createPolicy', request);
      const deleteAssignments = (request: DeleteAssignmentsRequest): Promise<DeleteAssignmentsResponse> => getRpcClient()(_aspects).invoke('deleteAssignments', request);
      const deletePolicy = (request: DeletePolicyRequest): Promise<DeletePolicyResponse> => getRpcClient()(_aspects).invoke('deletePolicy', request);
      const deletePolicyStatement = (request: DeletePolicyStatementRequest): Promise<DeletePolicyStatementResponse> =>
        getRpcClient()(_aspects).invoke('deletePolicyStatement', request);
      const foldExperiment = (request: FoldExperimentRequest): Promise<FoldExperimentResponse> => getRpcClient()(_aspects).invoke('foldExperiment', request);
      const getPolicies = (request: ManagementGetPoliciesRequest): Promise<ManagementGetPoliciesResponse> => getRpcClient()(_aspects).invoke('getPolicies', request);
      const getPolicy = (request: ManagementGetPolicyRequest): Promise<ManagementGetPolicyResponse> => getRpcClient()(_aspects).invoke('getPolicy', request);
      const unassignPolicyFromSubject = (request: UnassignPolicyFromSubjectRequest): Promise<UnassignPolicyFromSubjectResponse> =>
        getRpcClient()(_aspects).invoke('unassignPolicyFromSubject', request);
      const updateAssignment = (request: UpdateAssignmentRequest): Promise<UpdateAssignmentResponse> => getRpcClient()(_aspects).invoke('updateAssignment', request);
      const updatePolicyAuthorizationData = (request: UpdatePolicyAuthorizationDataRequest): Promise<UpdatePolicyResponse> =>
        getRpcClient()(_aspects).invoke('updatePolicyAuthorizationData', request);
      const updatePolicyMetadata = (request: UpdatePolicyMetadataRequest): Promise<UpdatePolicyResponse> => getRpcClient()(_aspects).invoke('updatePolicyMetadata', request);
      return {
        addStatementToPolicy: addStatementToPolicy,
        assignPolicy: assignPolicy,
        createPolicy: createPolicy,
        deleteAssignments: deleteAssignments,
        deletePolicy: deletePolicy,
        deletePolicyStatement: deletePolicyStatement,
        foldExperiment: foldExperiment,
        getPolicies: getPolicies,
        getPolicy: getPolicy,
        unassignPolicyFromSubject: unassignPolicyFromSubject,
        updateAssignment: updateAssignment,
        updatePolicyAuthorizationData: updatePolicyAuthorizationData,
        updatePolicyMetadata: updatePolicyMetadata,
      };
    };
  },
  AbacQueryService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AbacQueryService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const bulkIsPolicyAssigned = (request: BulkIsPolicyAssignedRequest): Promise<BulkIsPolicyAssignedResponse> =>
        getRpcClient()(_aspects).invoke('bulkIsPolicyAssigned', request);
      const filterPolicies = (request: FilterPoliciesRequest): Promise<FilterPoliciesResponse> => getRpcClient()(_aspects).invoke('filterPolicies', request);
      const getAssignments = (request: GetAssignmentsRequest): Promise<GetAssignmentsResponse> => getRpcClient()(_aspects).invoke('getAssignments', request);
      const getBulkSubjectPoliciesBySubjectContext = (request: GetBulkSubjectPoliciesBySubjectContextRequest): Promise<GetBulkSubjectPoliciesBySubjectContextResponse> =>
        getRpcClient()(_aspects).invoke('getBulkSubjectPoliciesBySubjectContext', request);
      const getContainedPolicies = (request: GetContainedPoliciesRequest): Promise<GetContainedPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('getContainedPolicies', request);
      const getCurrentSubjectPermissionsOnResource = (request: GetCurrentSubjectPermissionsOnResourceRequest): Promise<GetCurrentSubjectPermissionsOnResourceResponse> =>
        getRpcClient()(_aspects).invoke('getCurrentSubjectPermissionsOnResource', request);
      const getCurrentSubjectPermissionsOnResources = (request: GetCurrentSubjectPermissionsOnResourcesRequest): Promise<GetCurrentSubjectPermissionsOnResourcesResponse> =>
        getRpcClient()(_aspects).invoke('getCurrentSubjectPermissionsOnResources', request);
      const getPolicies = (request: QueryGetPoliciesRequest): Promise<QueryGetPoliciesResponse> => getRpcClient()(_aspects).invoke('getPolicies', request);
      const getPoliciesApplicableRestrictions = (request: GetPoliciesApplicableRestrictionsRequest): Promise<GetPoliciesApplicableRestrictionsResponse> =>
        getRpcClient()(_aspects).invoke('getPoliciesApplicableRestrictions', request);
      const getPoliciesAssignedOnResource = (request: GetPoliciesAssignedOnResourceRequest): Promise<GetPoliciesAssignedOnResourceResponse> =>
        getRpcClient()(_aspects).invoke('getPoliciesAssignedOnResource', request);
      const getPoliciesPermissions = (request: GetPoliciesPermissionsRequest): Promise<GetPoliciesPermissionsResponse> =>
        getRpcClient()(_aspects).invoke('getPoliciesPermissions', request);
      const getPolicy = (request: QueryGetPolicyRequest): Promise<QueryGetPolicyResponse> => getRpcClient()(_aspects).invoke('getPolicy', request);
      const getSubjectPermissionsOnResource = (request: GetSubjectPermissionsOnResourceRequest): Promise<GetSubjectPermissionsOnResourceResponse> =>
        getRpcClient()(_aspects).invoke('getSubjectPermissionsOnResource', request);
      const getSubjectPoliciesBySubjectContext = (request: GetSubjectPoliciesBySubjectContextRequest): Promise<GetSubjectPoliciesBySubjectContextResponse> =>
        getRpcClient()(_aspects).invoke('getSubjectPoliciesBySubjectContext', request);
      const getSubjectPoliciesOnCurrentAccount = (request: GetSubjectPoliciesOnCurrentAccountRequest): Promise<GetSubjectPoliciesOnCurrentAccountResponse> =>
        getRpcClient()(_aspects).invoke('getSubjectPoliciesOnCurrentAccount', request);
      return {
        bulkIsPolicyAssigned: bulkIsPolicyAssigned,
        filterPolicies: filterPolicies,
        getAssignments: getAssignments,
        getBulkSubjectPoliciesBySubjectContext: getBulkSubjectPoliciesBySubjectContext,
        getContainedPolicies: getContainedPolicies,
        getCurrentSubjectPermissionsOnResource: getCurrentSubjectPermissionsOnResource,
        getCurrentSubjectPermissionsOnResources: getCurrentSubjectPermissionsOnResources,
        getPolicies: getPolicies,
        getPoliciesApplicableRestrictions: getPoliciesApplicableRestrictions,
        getPoliciesAssignedOnResource: getPoliciesAssignedOnResource,
        getPoliciesPermissions: getPoliciesPermissions,
        getPolicy: getPolicy,
        getSubjectPermissionsOnResource: getSubjectPermissionsOnResource,
        getSubjectPoliciesBySubjectContext: getSubjectPoliciesBySubjectContext,
        getSubjectPoliciesOnCurrentAccount: getSubjectPoliciesOnCurrentAccount,
      };
    };
  },
  AccountInviteService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AccountInviteService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const acceptInvite = (request: AcceptInviteRequest): Promise<AcceptInviteResponse> => getRpcClient()(_aspects).invoke('acceptInvite', request);
      const changeInvitePolicies = (request: ChangeInvitePoliciesRequest): Promise<ServiceEmptyResponse> => getRpcClient()(_aspects).invoke('changeInvitePolicies', request);
      const createNewInvite = (request: CreateInviteRequest): Promise<CreateInviteResponse> => getRpcClient()(_aspects).invoke('createNewInvite', request);
      const deleteInvite = (request: DeleteInviteRequest): Promise<ServiceEmptyResponse> => getRpcClient()(_aspects).invoke('deleteInvite', request);
      const getInvite = (request: GetInviteRequest): Promise<GetInviteResponse> => getRpcClient()(_aspects).invoke('getInvite', request);
      const getInvitesByAccount = (request: GetInvitesByAccountRequest): Promise<GetInvitesByAccountResponse> => getRpcClient()(_aspects).invoke('getInvitesByAccount', request);
      const resetInvite = (request: ResetInviteRequest): Promise<ResetInviteResponse> => getRpcClient()(_aspects).invoke('resetInvite', request);
      const updateInviteAssignments = (request: UpdateInviteAssignmentsRequest): Promise<ServiceEmptyResponse> =>
        getRpcClient()(_aspects).invoke('updateInviteAssignments', request);
      return {
        acceptInvite: acceptInvite,
        changeInvitePolicies: changeInvitePolicies,
        createNewInvite: createNewInvite,
        deleteInvite: deleteInvite,
        getInvite: getInvite,
        getInvitesByAccount: getInvitesByAccount,
        resetInvite: resetInvite,
        updateInviteAssignments: updateInviteAssignments,
      };
    };
  },
  AccountPoliciesManagement: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AccountPoliciesManagement', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const assignPoliciesToTeamMember = (request: AssignPoliciesToTeamMemberRequest): Promise<AssignPoliciesToTeamMemberResponse> =>
        getRpcClient()(_aspects).invoke('assignPoliciesToTeamMember', request);
      const bulkOverrideSubjectPolicies = (request: BulkOverrideSubjectPoliciesRequest): Promise<BulkOverrideSubjectPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('bulkOverrideSubjectPolicies', request);
      const clearTeamMemberPolicies = (request: ClearTeamMemberPoliciesRequest): Promise<ClearTeamMemberPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('clearTeamMemberPolicies', request);
      const createPolicy = (request: CreatePolicyRequest): Promise<CreatePolicyResponse> => getRpcClient()(_aspects).invoke('createPolicy', request);
      const deletePolicy = (request: DeletePolicyRequest): Promise<DeletePolicyResponse> => getRpcClient()(_aspects).invoke('deletePolicy', request);
      const deleteTeamMemberAssignments = (request: DeleteTeamMemberAssignmentsRequest): Promise<DeleteTeamMemberAssignmentsResponse> =>
        getRpcClient()(_aspects).invoke('deleteTeamMemberAssignments', request);
      const replaceAllTeamMemberPolicies = (request: ReplaceAllTeamMemberPoliciesRequest): Promise<ReplaceAllTeamMemberPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('replaceAllTeamMemberPolicies', request);
      const replaceTeamMemberPolicies = (request: ReplaceTeamMemberPoliciesRequest): Promise<ReplaceTeamMemberPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('replaceTeamMemberPolicies', request);
      const updatePolicyAuthorizationData = (request: UpdatePolicyAuthorizationDataRequest): Promise<UpdatePolicyResponse> =>
        getRpcClient()(_aspects).invoke('updatePolicyAuthorizationData', request);
      const updatePolicyMetadata = (request: UpdatePolicyMetadataRequest): Promise<UpdatePolicyResponse> => getRpcClient()(_aspects).invoke('updatePolicyMetadata', request);
      return {
        assignPoliciesToTeamMember: assignPoliciesToTeamMember,
        bulkOverrideSubjectPolicies: bulkOverrideSubjectPolicies,
        clearTeamMemberPolicies: clearTeamMemberPolicies,
        createPolicy: createPolicy,
        deletePolicy: deletePolicy,
        deleteTeamMemberAssignments: deleteTeamMemberAssignments,
        replaceAllTeamMemberPolicies: replaceAllTeamMemberPolicies,
        replaceTeamMemberPolicies: replaceTeamMemberPolicies,
        updatePolicyAuthorizationData: updatePolicyAuthorizationData,
        updatePolicyMetadata: updatePolicyMetadata,
      };
    };
  },
  AppInviteService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AppInviteService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const acceptAppInvite = (request: AcceptAppInviteRequest): Promise<AcceptAppInviteResponse> => getRpcClient()(_aspects).invoke('acceptAppInvite', request);
      const createAppInvite = (request: CreateAppInviteRequest): Promise<CreateAppInviteResponse> => getRpcClient()(_aspects).invoke('createAppInvite', request);
      const deleteAppInvite = (request: DeleteAppInviteRequest): Promise<DeleteAppInviteResponse> => getRpcClient()(_aspects).invoke('deleteAppInvite', request);
      const getAppInvite = (request: GetAppInviteRequest): Promise<GetAppInviteResponse> => getRpcClient()(_aspects).invoke('getAppInvite', request);
      const getAppInvites = (request: GetAppInvitesRequest): Promise<GetAppInvitesResponse> => getRpcClient()(_aspects).invoke('getAppInvites', request);
      const resetAppInvite = (request: ResetAppInviteRequest): Promise<ResetAppInviteResponse> => getRpcClient()(_aspects).invoke('resetAppInvite', request);
      return {
        acceptAppInvite: acceptAppInvite,
        createAppInvite: createAppInvite,
        deleteAppInvite: deleteAppInvite,
        getAppInvite: getAppInvite,
        getAppInvites: getAppInvites,
        resetAppInvite: resetAppInvite,
      };
    };
  },
  AppPoliciesManagementService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AppPoliciesManagementService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const clearAssignedAppPolicies = (request: ClearAssignedAppPoliciesRequest): Promise<ClearAssignedAppPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('clearAssignedAppPolicies', request);
      return {
        clearAssignedAppPolicies: clearAssignedAppPolicies,
      };
    };
  },
  AuthorizationManagementService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AuthorizationManagementService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const addRole = (accountId: guid, metasiteId: guid, role: Role): Promise<any> => getRpcClient()(_aspects).invoke('addRole', accountId, metasiteId, role);
      const addRoles = (userId: UserGuid, metasiteId: guid, roles: Role[]): Promise<any> => getRpcClient()(_aspects).invoke('addRoles', userId, metasiteId, roles);
      const changeRole = (accountId: guid, resourceId: guid, role: Role, staffId?: guid): Promise<any> =>
        getRpcClient()(_aspects).invoke('changeRole', accountId, resourceId, role, staffId);
      const changeRole$default$4 = (): Promise<guid> => getRpcClient()(_aspects).invoke('changeRole$default$4');
      const changeRole$default$4$ = ($this: any): Promise<any> => getRpcClient()(_aspects).invoke('changeRole$default$4$', $this);
      const changeRoles = (userId: UserGuid, resourceId: guid, newRoles: Role[], staffId?: guid): Promise<any> =>
        getRpcClient()(_aspects).invoke('changeRoles', userId, resourceId, newRoles, staffId);
      const changeRoles$default$4 = (): Promise<guid> => getRpcClient()(_aspects).invoke('changeRoles$default$4');
      const changeRoles$default$4$ = ($this: any): Promise<any> => getRpcClient()(_aspects).invoke('changeRoles$default$4$', $this);
      const cleanRolesForSite = (resourceId: String): Promise<any> => getRpcClient()(_aspects).invoke('cleanRolesForSite', resourceId);
      const clearRole = (accountId: guid, resourceId: guid): Promise<any> => getRpcClient()(_aspects).invoke('clearRole', accountId, resourceId);
      const clearRoles = (userId: UserGuid, resourceId: guid): Promise<any> => getRpcClient()(_aspects).invoke('clearRoles', userId, resourceId);
      const fetchRoles = (userId: UserGuid, resourceId: guid): Promise<Role[]> => getRpcClient()(_aspects).invoke('fetchRoles', userId, resourceId);
      const fetchSiteAccountsInfo = (metasiteId: guid): Promise<any[]> => getRpcClient()(_aspects).invoke('fetchSiteAccountsInfo', metasiteId);
      const fetchSitesAccountsInfo = (metasiteIds: guid[]): Promise<SiteAccountsWithRoles[]> => getRpcClient()(_aspects).invoke('fetchSitesAccountsInfo', metasiteIds);
      const fetchSitesUsersInfo = (metasiteIds: guid[]): Promise<SiteUsersWithRoles[]> => getRpcClient()(_aspects).invoke('fetchSitesUsersInfo', metasiteIds);
      const fetchSiteUsersInfo = (metasiteId: guid): Promise<any[]> => getRpcClient()(_aspects).invoke('fetchSiteUsersInfo', metasiteId);
      const fetchUserSitesInfo = (userId: UserGuid): Promise<any[]> => getRpcClient()(_aspects).invoke('fetchUserSitesInfo', userId);
      return {
        addRole: addRole,
        addRoles: addRoles,
        changeRole: changeRole,
        changeRole$default$4: changeRole$default$4,
        changeRole$default$4$: changeRole$default$4$,
        changeRoles: changeRoles,
        changeRoles$default$4: changeRoles$default$4,
        changeRoles$default$4$: changeRoles$default$4$,
        cleanRolesForSite: cleanRolesForSite,
        clearRole: clearRole,
        clearRoles: clearRoles,
        fetchRoles: fetchRoles,
        fetchSiteAccountsInfo: fetchSiteAccountsInfo,
        fetchSitesAccountsInfo: fetchSitesAccountsInfo,
        fetchSitesUsersInfo: fetchSitesUsersInfo,
        fetchSiteUsersInfo: fetchSiteUsersInfo,
        fetchUserSitesInfo: fetchUserSitesInfo,
      };
    };
  },
  AuthorizationService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AuthorizationService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const fetchOwner = (resourceId: guid): Promise<AuthorizationSiteOwner> => getRpcClient()(_aspects).invoke('fetchOwner', resourceId);
      const fetchRoles = (userId: UserGuid, resourceId: guid): Promise<Role[]> => getRpcClient()(_aspects).invoke('fetchRoles', userId, resourceId);
      return {
        fetchOwner: fetchOwner,
        fetchRoles: fetchRoles,
      };
    };
  },
  AuthorizationServiceDevApi: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'AuthorizationServiceDevApi', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const deleteAccountInvite = (request: DeleteAccountInviteRequest): Promise<AuthorizationEmptyResponse> => getRpcClient()(_aspects).invoke('deleteAccountInvite', request);
      const deleteAccountInvites = (request: DeleteAccountInvitesRequest): Promise<AuthorizationEmptyResponse> => getRpcClient()(_aspects).invoke('deleteAccountInvites', request);
      const migrateInviteToAccount = (request: MigrateInviteRequest): Promise<AuthorizationEmptyResponse> => getRpcClient()(_aspects).invoke('migrateInviteToAccount', request);
      const triggerGdprDeleteUserData = (request: TriggerGdprDeleteUserDataRequest): Promise<TriggerGdprDeleteUserDataResponse> =>
        getRpcClient()(_aspects).invoke('triggerGdprDeleteUserData', request);
      return {
        deleteAccountInvite: deleteAccountInvite,
        deleteAccountInvites: deleteAccountInvites,
        migrateInviteToAccount: migrateInviteToAccount,
        triggerGdprDeleteUserData: triggerGdprDeleteUserData,
      };
    };
  },
  BackOfficeAuthorizationService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'BackOfficeAuthorizationService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const bulkIsPermitted = (request: BulkBackOfficeIsPermittedRequest): Promise<BulkIsPermittedResponse> => getRpcClient()(_aspects).invoke('bulkIsPermitted', request);
      const bulkSubjectIsPermitted = (request: BulkSubjectBackOfficeIsPermittedRequest): Promise<BulkSubjectIsPermittedResponse> =>
        getRpcClient()(_aspects).invoke('bulkSubjectIsPermitted', request);
      const isPermitted = (request: BackOfficeIsPermitted): Promise<IsPermittedResponse> => getRpcClient()(_aspects).invoke('isPermitted', request);
      const isPermittedByAppInstance = (request: IsPermittedByAppInstanceRequest): Promise<IsPermittedResponse> =>
        getRpcClient()(_aspects).invoke('isPermittedByAppInstance', request);
      return {
        bulkIsPermitted: bulkIsPermitted,
        bulkSubjectIsPermitted: bulkSubjectIsPermitted,
        isPermitted: isPermitted,
        isPermittedByAppInstance: isPermittedByAppInstance,
      };
    };
  },
  GlobalGroupsManagementService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'GlobalGroupsManagementService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const addRoleToGlobalGroup = (groupName: String, role: Role): Promise<any> => getRpcClient()(_aspects).invoke('addRoleToGlobalGroup', groupName, role);
      const addUserIdToGroup = (userId: UserGuid, groupName: String): Promise<any> => getRpcClient()(_aspects).invoke('addUserIdToGroup', userId, groupName);
      const addUserToGroup = (email: String, groupName: String): Promise<any> => getRpcClient()(_aspects).invoke('addUserToGroup', email, groupName);
      const allGlobalGroups = (): Promise<String[]> => getRpcClient()(_aspects).invoke('allGlobalGroups');
      const getUserGroups = (email: String): Promise<String[]> => getRpcClient()(_aspects).invoke('getUserGroups', email);
      const removeRoleFromGlobalGroup = (groupName: String, role: Role): Promise<any> => getRpcClient()(_aspects).invoke('removeRoleFromGlobalGroup', groupName, role);
      const removeUserFromGroup = (email: String, groupName: String): Promise<any> => getRpcClient()(_aspects).invoke('removeUserFromGroup', email, groupName);
      return {
        addRoleToGlobalGroup: addRoleToGlobalGroup,
        addUserIdToGroup: addUserIdToGroup,
        addUserToGroup: addUserToGroup,
        allGlobalGroups: allGlobalGroups,
        getUserGroups: getUserGroups,
        removeRoleFromGlobalGroup: removeRoleFromGlobalGroup,
        removeUserFromGroup: removeUserFromGroup,
      };
    };
  },
  GlobalGroupsService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'GlobalGroupsService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const getAllGroupsRoles = (): Promise<{ [key: string]: Role[] }> => getRpcClient()(_aspects).invoke('getAllGroupsRoles');
      const getAllUsersGroups = (): Promise<{ [key: string]: String[] }> => getRpcClient()(_aspects).invoke('getAllUsersGroups');
      const getUserGroups = (userId: UserGuid): Promise<String[]> => getRpcClient()(_aspects).invoke('getUserGroups', userId);
      return {
        getAllGroupsRoles: getAllGroupsRoles,
        getAllUsersGroups: getAllUsersGroups,
        getUserGroups: getUserGroups,
      };
    };
  },
  ImmigratorSingleMigrationService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'ImmigratorSingleMigrationService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const runMigration = (request: RunSingleMigrationRequest): Promise<RunSingleMigrationResponse> => getRpcClient()(_aspects).invoke('runMigration', request);
      return {
        runMigration: runMigration,
      };
    };
  },
  InvitesService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'InvitesService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const acceptInvite = (inviteId: guid, assignedUser: UserGuid): Promise<Invite> => getRpcClient()(_aspects).invoke('acceptInvite', inviteId, assignedUser);
      const changeInviteRole = (inviteId: guid, newRole: Role, staffId?: guid): Promise<any> => getRpcClient()(_aspects).invoke('changeInviteRole', inviteId, newRole, staffId);
      const changeInviteRole$default$3 = (): Promise<guid> => getRpcClient()(_aspects).invoke('changeInviteRole$default$3');
      const changeInviteRole$default$3$ = ($this: any): Promise<any> => getRpcClient()(_aspects).invoke('changeInviteRole$default$3$', $this);
      const changeInviteRoles = (inviteId: guid, policyIds: String[], locationIds: String[], staffId?: guid, locationRestrictions?: String[]): Promise<any> =>
        getRpcClient()(_aspects).invoke('changeInviteRoles', inviteId, policyIds, staffId, locationIds, locationRestrictions);
      const changeInviteRoles$default$3 = (): Promise<guid> => getRpcClient()(_aspects).invoke('changeInviteRoles$default$3');
      const changeInviteRoles$default$3$ = ($this: any): Promise<any> => getRpcClient()(_aspects).invoke('changeInviteRoles$default$3$', $this);
      const changeInviteRoles$default$4 = (): Promise<String[]> => getRpcClient()(_aspects).invoke('changeInviteRoles$default$4');
      const changeInviteRoles$default$4$ = ($this: any): Promise<any> => getRpcClient()(_aspects).invoke('changeInviteRoles$default$4$', $this);
      const changeInviteRoles$default$5 = (): Promise<String[]> => getRpcClient()(_aspects).invoke('changeInviteRoles$default$5');
      const changeInviteRoles$default$5$ = ($this: any): Promise<any> => getRpcClient()(_aspects).invoke('changeInviteRoles$default$5$', $this);
      const createInviteNew = (inviteReq: InviteReq): Promise<Invite> => getRpcClient()(_aspects).invoke('createInviteNew', inviteReq);
      const decline = (guid: guid): Promise<any> => getRpcClient()(_aspects).invoke('decline', guid);
      const __js_reserved_word_delete = (inviteId: guid): Promise<any> => getRpcClient()(_aspects).invoke('delete', inviteId);
      const getContributorLimit = (metaSiteId: String): Promise<ContributorLimit> => getRpcClient()(_aspects).invoke('getContributorLimit', metaSiteId);
      const getContributorsQuota = (metaSiteId: String): Promise<any> => getRpcClient()(_aspects).invoke('getContributorsQuota', metaSiteId);
      const getInvite = (id: guid): Promise<Invite> => getRpcClient()(_aspects).invoke('getInvite', id);
      const getInvitesByInvitedUserId = (invitedUserId: UserGuid): Promise<Invite[]> => getRpcClient()(_aspects).invoke('getInvitesByInvitedUserId', invitedUserId);
      const getValidSiteInvites = (metasiteId: guid): Promise<Invite[]> => getRpcClient()(_aspects).invoke('getValidSiteInvites', metasiteId);
      const querySiteInvites = (metasiteId: guid, filter: InviteFilter): Promise<Invite[]> => getRpcClient()(_aspects).invoke('querySiteInvites', metasiteId, filter);
      const resetInvite = (inviteId: guid): Promise<Invite> => getRpcClient()(_aspects).invoke('resetInvite', inviteId);
      const updateGivenToEmail = (inviteId: guid[], givenToEmail: String, dateUpdated: DateTime): Promise<any> =>
        getRpcClient()(_aspects).invoke('updateGivenToEmail', inviteId, givenToEmail, dateUpdated);
      return {
        acceptInvite: acceptInvite,
        changeInviteRole: changeInviteRole,
        changeInviteRole$default$3: changeInviteRole$default$3,
        changeInviteRole$default$3$: changeInviteRole$default$3$,
        changeInviteRoles: changeInviteRoles,
        changeInviteRoles$default$3: changeInviteRoles$default$3,
        changeInviteRoles$default$3$: changeInviteRoles$default$3$,
        changeInviteRoles$default$4: changeInviteRoles$default$4,
        changeInviteRoles$default$4$: changeInviteRoles$default$4$,
        changeInviteRoles$default$5: changeInviteRoles$default$5,
        changeInviteRoles$default$5$: changeInviteRoles$default$5$,
        createInviteNew: createInviteNew,
        decline: decline,
        delete: __js_reserved_word_delete,
        getContributorLimit: getContributorLimit,
        getContributorsQuota: getContributorsQuota,
        getInvite: getInvite,
        getInvitesByInvitedUserId: getInvitesByInvitedUserId,
        getValidSiteInvites: getValidSiteInvites,
        querySiteInvites: querySiteInvites,
        resetInvite: resetInvite,
        updateGivenToEmail: updateGivenToEmail,
      };
    };
  },
  LegacyAuthorizationService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'LegacyAuthorizationService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const getPermissions = (request: GetPermissionsRequest): Promise<GetPermissionsResponse> => getRpcClient()(_aspects).invoke('getPermissions', request);
      return {
        getPermissions: getPermissions,
      };
    };
  },
  LegacyMembersWithRoleApi: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'LegacyMembersWithRoleApi', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const authorize = (request: AuthorizationRequest): Promise<AuthorizationResponse> => getRpcClient()(_aspects).invoke('authorize', request);
      return {
        authorize: authorize,
      };
    };
  },
  MetaSiteRestrictedSubjectsFacade: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'MetaSiteRestrictedSubjectsFacade', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const getRestrictedSubjects = (request: GetRestrictedSubjectsRequest): Promise<GetRestrictedSubjectsResponse> =>
        getRpcClient()(_aspects).invoke('getRestrictedSubjects', request);
      return {
        getRestrictedSubjects: getRestrictedSubjects,
      };
    };
  },
  SitePoliciesManagement: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'SitePoliciesManagement', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const assignPolicies = (request: AssignPoliciesRequest): Promise<AssignPoliciesResponse> => getRpcClient()(_aspects).invoke('assignPolicies', request);
      const clearAssignedPolicies = (request: ClearAssignedPoliciesRequest): Promise<ClearAssignedPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('clearAssignedPolicies', request);
      const replaceAllAssignedPolicies = (request: ReplaceAllAssignedPoliciesRequest): Promise<ReplaceAllAssignedPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('replaceAllAssignedPolicies', request);
      const replaceAllAssignedPoliciesCondition = (request: ReplaceAllAssignedPoliciesConditionRequest): Promise<ReplaceAllAssignedPoliciesConditionResponse> =>
        getRpcClient()(_aspects).invoke('replaceAllAssignedPoliciesCondition', request);
      const updatePoliciesOnSiteTransfer = (request: UpdatePoliciesOnSiteTransferRequest): Promise<UpdatePoliciesOnSiteTransferResponse> =>
        getRpcClient()(_aspects).invoke('updatePoliciesOnSiteTransfer', request);
      return {
        assignPolicies: assignPolicies,
        clearAssignedPolicies: clearAssignedPolicies,
        replaceAllAssignedPolicies: replaceAllAssignedPolicies,
        replaceAllAssignedPoliciesCondition: replaceAllAssignedPoliciesCondition,
        updatePoliciesOnSiteTransfer: updatePoliciesOnSiteTransfer,
      };
    };
  },
  SubjectsQueryService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'SubjectsQueryService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const bulkGetSubjectRoles = (request: BulkGetSubjectRolesRequest): Promise<BulkGetSubjectRolesResponse> => getRpcClient()(_aspects).invoke('bulkGetSubjectRoles', request);
      const getCurrentSubjectContainedPolicies = (request: GetCurrentSubjectContainedPoliciesRequest): Promise<GetCurrentSubjectContainedPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('getCurrentSubjectContainedPolicies', request);
      const getSubjectAssignedPolicies = (request: GetSubjectAssignedPoliciesRequest): Promise<GetSubjectAssignedPoliciesResponse> =>
        getRpcClient()(_aspects).invoke('getSubjectAssignedPolicies', request);
      const getSubjectPermittedResources = (request: GetSubjectPermittedResourcesRequest): Promise<GetSubjectPermittedResourcesResponse> =>
        getRpcClient()(_aspects).invoke('getSubjectPermittedResources', request);
      const getSubjectPermittingAssignments = (request: GetSubjectPermittingAssignmentsRequest): Promise<GetSubjectPermittingAssignmentsResponse> =>
        getRpcClient()(_aspects).invoke('getSubjectPermittingAssignments', request);
      const getSubjectRoles = (request: GetSubjectRolesRequest): Promise<GetSubjectRolesResponse> => getRpcClient()(_aspects).invoke('getSubjectRoles', request);
      return {
        bulkGetSubjectRoles: bulkGetSubjectRoles,
        getCurrentSubjectContainedPolicies: getCurrentSubjectContainedPolicies,
        getSubjectAssignedPolicies: getSubjectAssignedPolicies,
        getSubjectPermittedResources: getSubjectPermittedResources,
        getSubjectPermittingAssignments: getSubjectPermittingAssignments,
        getSubjectRoles: getSubjectRoles,
      };
    };
  },
  UsersAuthorizationQueryService: (overrideRpcFactory?, _rpcOptions: { timeout?: number } = {}) => {
    // lazily create the rpc client only upon first invocation, to prevent premature error throwing
    let _rpcClient;
    const getRpcClient = () => {
      if (!_rpcClient) {
        const rpcFactory =
          overrideRpcFactory || requireAmbassadorRuntime().getRpcFactory({ ambassadorArtifactName: 'AuthorizationServer', packageConfig: { transport: 'json-rpc' } });
        const artifactUrl = overrideArtifactUrl || requireAmbassadorRuntime().getArtifactUrl('AuthorizationServer');
        _rpcClient = rpcFactory.clientFactory(artifactUrl, 'UsersAuthorizationQueryService', _rpcOptions).client;
      }
      return _rpcClient;
    };
    return (_aspects) => {
      const bulkGetPermittedSubjectsCount = (request: BulkGetPermittedSubjectsCountRequest): Promise<BulkGetPermittedSubjectsCountResponse> =>
        getRpcClient()(_aspects).invoke('bulkGetPermittedSubjectsCount', request);
      const getPermittedSubjectsRoles = (request: GetPermittedSubjectsRolesRequest): Promise<GetPermittedSubjectsRolesResponse> =>
        getRpcClient()(_aspects).invoke('getPermittedSubjectsRoles', request);
      const getPermittedSubjectsStatements = (request: GetPermittedSubjectsStatementsRequest): Promise<GetPermittedSubjectsStatementsResponse> =>
        getRpcClient()(_aspects).invoke('getPermittedSubjectsStatements', request);
      return {
        bulkGetPermittedSubjectsCount: bulkGetPermittedSubjectsCount,
        getPermittedSubjectsRoles: getPermittedSubjectsRoles,
        getPermittedSubjectsStatements: getPermittedSubjectsStatements,
      };
    };
  },
});
(AuthorizationServer as any).__artifactName = 'AuthorizationServer';
(AuthorizationServer as any).__transport = 'json-rpc';

export * from './types';
