본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

조직

원문 보기 위키 갱신

GraphQL API로 Buildkite 조직을 다루는 일반적인 작업 모음이에요.

Buildkite GraphQL 콘솔로 Buildkite GraphQL API를 시험해 볼 수 있어요. Documentation 탭의 내장 문서도 포함돼요.

조직 ID 조회부터 멤버·SSO·보안 정책 관리, 감사 이벤트 조회까지 살펴봐요.

출처: 문서

본문

GraphQL API로 Buildkite 조직을 다루는 일반적인 작업 모음이에요.

Buildkite GraphQL 콘솔로 Buildkite GraphQL API를 시험해 볼 수 있어요. Documentation 탭의 내장 문서도 포함돼요.

조직 ID 조회하기

Buildkite 조직의 ID를 아는 것은 다른 많은 GraphQL 쿼리를 실행하기 위한 전제 조건이에요. 이 쿼리로 조직의 슬러그 기반 조직 ID를 얻으세요.

query getOrganizationID {
  organization(slug:"organization-slug") {
    id
  }
}

조직 멤버 나열하기

조직의 처음 100명 멤버를 나열해요.

query getOrgMembers {
  organization(slug: "organization-slug") {
    members(first: 100) {
      edges {
        node {
          role
          user {
            name
            email
            id
          }
        }
      }
    }
  }
}

조직 멤버 수 조회하기

조직 멤버의 총수를 가져와요. 쿼리에서 members에 어떤 값을 넣든, 쿼리의 출력은 조직의 실제 멤버 수를 제공해요.

query getOrgMembersCount {
  organization(slug: "org-slug") {
    members(first:1) {
      count
    }
  }
}

활성 사용자 수 조회하기

조직의 현재 사용 요약 기간의 월평균 활성 사용자를 가져와요. 조직의 Usage > Platform 페이지에 표시되는 수와 일치해요.

query getOrgActiveUsersCount {
  organization(slug: "organization-slug") {
    activeUsersCount
  }
}
{
  "data": {
    "organization": {
      "activeUsersCount": 42
    }
  }
}

이 필드는 권한 있는 조직 멤버에게만 제공되고, 그 외에는 또는 사용 데이터가 없을 때 null을 반환해요. 예를 들어 조직에 대한 SSO 권한 부여를 완료하지 않았다면 이 필드는 null을 반환해요. API 접근 토큰이 조직 접근을 허용하지 않는다면 organization 쿼리가 대신 null을 반환해요.

청구 부모 조직의 경우, 이 카운트는 연결된 청구 자식 조직의 활동을 포함하고, 둘 이상의 연결 조직에서 활동한 사용자는 월별로 한 번만 셉니다.

조직 멤버 검색하기

이메일 주소로 조직 멤버를 조회해요.

query getOrgMember {
  organization(slug: "organization-slug") {
    members(first: 1, search: "user-email") {
      edges {
        node {
          role
          user {
            name
            email
            id
          }
        }
      }
    }
  }
}

비활성 조직 멤버 찾기

특정 날짜 이후 활동하지 않은 조직 멤버를 나열해요.

query getInactiveOrgMembers {
  organization(slug: "organization-slug") {
    members(first: 100, inactiveSince: "2025-01-01") {
      count
      edges {
        node {
          id
          lastSeenAt
          user {
            name
            email
          }
        }
      }
    }
  }
}

모든 사용자의 가장 최근 SSO 로그인 조회하기

조직에서 SSO가 활성화되어 있다면, 이 쿼리로 조직 사용자들의 마지막 로그인 날짜를 얻을 수 있어요.

query getRecentSignOn {
  organization(slug: "organization-slug") {
    members(first: 100) {
      edges {
        node {
          user {
            name
            email
          }
          sso {
            authorizations(first: 1) {
              edges {
                node {
                  createdAt
                  expiredAt
                }
              }
            }
          }
        }
      }
    }
  }
}

기본 SSO 공급자 세션 기간 업데이트하기

사용자가 SSO로 재인증하기 전까지 세션이 얼마나 유지될 수 있는지 제어할 수 있어요. 기본값은 무기한이지만, 몇 시간이나 몇 일까지 줄일 수 있어요.

mutation UpdateSessionDuration {
  ssoProviderUpdate(input: { id: "ID", sessionDurationInHours: 2 }) {
    ssoProvider {
      sessionDurationInHours
    }
  }
}

비활성 API 토큰 폐기 업데이트하기

Enterprise 플랜에서는 비활성 API 토큰이 언제 폐기되는지 제어할 수 있어요. 기본값은 폐기하지 않는 것(NEVER)이지만, 토큰 폐기를 30, 60, 90, 180, 365일 중 하나로 설정할 수 있어요.

mutation UpdateRevokeInactiveTokenPeriod {
  organizationRevokeInactiveTokensAfterUpdate(input: {
    organizationId: "organization-id",
    revokeInactiveTokensAfter: DAYS_30
  }) {
    organization {
      revokeInactiveTokensAfter
    }
  }
}

SSO 세션을 IP 주소에 고정하기

다음 호출로 사용자의 IP 주소가 바뀔 때 SSO 공급자로 재인증하도록 요구할 수 있어요. ID는 SSO 공급자의 GraphQL ID로 바꾸세요:

mutation UpdateSessionIPAddressPinning {
  ssoProviderUpdate(input: { id: "ID", pinSessionToIpAddress: true }) {
    ssoProvider {
      pinSessionToIpAddress
    }
  }
}

조직에 2단계 인증(2FA) 강제하기

사용자가 조직의 Buildkite 대시보드에 접근하기 전에 2단계 인증이 활성화되어 있어야 하도록 요구해요.

mutation EnableEnforced2FA {
  organizationEnforceTwoFactorAuthenticationForMembersUpdate(
    input: {
      organizationId: "organization-id",
      membersRequireTwoFactorAuthentication: true
    }
  ) {
    organization {
      id
      membersRequireTwoFactorAuthentication
      uuid
    }
  }
}

사용자 만들기, 팀에 추가하기, 사용자 권한 설정하기

새 사용자를 조직에 초대하고, 팀에 추가하고, 역할을 설정해요.

먼저 조직과 팀 ID를 얻어요:

query getOrganizationAndTeamId {
  organization(slug: "organization-slug") {
    id
    teams(first:500) {
      edges {
        node {
          id
          slug
        }
      }
    }
  }
}

그다음 사용자를 초대해 팀에 추가하며, 역할을 'maintainer'로 설정해요:

mutation CreateUser {
  organizationInvitationCreate(input: {
    organizationID: "organization-id",
    emails: ["user-email"],
    role: MEMBER,
    teams: [
      {
        id: "team-id",
        role: MAINTAINER
      }
    ]
  }) {
    invitationEdges {
      node {
        email
        createdAt
      }
    }
  }
}

조직 멤버의 생성 타임스탬프 조회하기

사용자가 언제 조직에 추가됐는지 찾는 데 사용해요.

query getOrganizationMemberCreation {
  organization(slug: "organization-slug") {
    id
    members(search: "organization-member-name", first: 10) {
      edges {
        node {
          id
          createdAt
          user {
            id
            name
            email
          }
        }
      }
    }
  }
}

조직 멤버의 역할 업데이트하기

조직 멤버의 역할을 USER나 ADMIN으로 업데이트해요.

먼저 이메일 주소로 조직 멤버의 ID(organization-member-id)를 찾으세요. 이 ID 값은 사용자의 ID(user-id)와 같지 않다는 점에 유의하세요.

query getOrgMemberID{
  organization(slug: "organization-slug") {
    members(first: 1, search: "user-email") {
      edges {
        node {
          role
          user {
            name
            email
            id
          }
        }
      }
    }
  }
}

그다음 이 organization-member-id 값(위 쿼리에서 얻은)을 사용해 조직 멤버의 역할을 업데이트해요.

mutation UpdateOrgMemberRole {
  organizationMemberUpdate (input:
    {id:"organization-member-id", role:ADMIN}) {
    organizationMember {
      id
      role
      user {
        name
      }
    }
  }
}

조직 멤버 삭제하기

조직에서 멤버를 삭제해요. 이 동작은 그 멤버의 Buildkite 사용자 계정을 삭제하지 않아요.

먼저 이메일 주소로 조직 멤버의 ID(organization-member-id)를 찾으세요. 이 ID 값은 사용자의 ID(user-id)와 같지 않다는 점에 유의하세요.

query getOrgMemberID{
  organization(slug: "organization-slug") {
    members(first: 1, search: "user-email") {
      edges {
        node {
          id
          role
          user {
            name
            email
          }
        }
      }
    }
  }
}

그다음 이 organization-member-id 값(위 쿼리에서 얻은)을 사용해 조직에서 사용자를 삭제해요.

mutation deleteOrgMember {
  organizationMemberDelete(input: { id: "organization-member-id" }){
    organization{
      name
    }
    deletedOrganizationMemberID
    user{
      name
    }
  }
}

조직 감사 이벤트 조회하기

Buildkite 조직의 감사 이벤트를 쿼리해요. 감사 이벤트는 Enterprise 플랜 고객에게만 제공돼요.

query getOrganizationAuditEvents {
  organization(slug:"organization-slug"){
    auditEvents(first: 500){
      edges{
        node{
          type
          occurredAt
          actor{
            name
          }
          subject{
            name
            type
          }
        }
      }
    }
  }
}

주어진 기간의 모든 감사 이벤트를 얻으려면 다음 쿼리처럼 occurredAtFrom과 occurredAtTo 필터를 사용해요:

query getTimeScopedOrganizationAuditEvents {
  organization(slug:"organization-slug"){
    auditEvents(first: 500, occurredAtFrom: "2023-01-01T12:00:00.000", occurredAtTo: "2023-01-01T13:00:00.000"){
      edges{
        node{
          type
          occurredAt
          actor{
            name
          }
          subject{
            name
            type
          }
        }
      }
    }
  }
}

특정 사용자의 조직 감사 이벤트 조회하기

Buildkite 조직 안에서 특정 사용자의 감사 이벤트를 쿼리해요. 감사 이벤트는 Enterprise 플랜 고객에게만 제공돼요.

query getActorRefinedOrganizationAuditEvents {
  organization(slug:"organization-slug"){
    auditEvents(first: 500, actor: "user-id"){
      edges{
        node{
          type
          occurredAt
          actor{
            name
          }
          subject{
            name
            type
          }
        }
      }
    }
  }
}

위 쿼리의 actor user-id를 찾으려면 다음 쿼리를 실행할 수 있어요. search 항목을 사용자의 이름/이메일로 바꾸세요:

query getActorID {
  organization(slug:"organization-slug"){
    members(first:50, search: "search term"){
      edges{
        node{
          user{
            name
            email
            id
          }
        }
      }
    }
  }
}

시스템 배너 만들고 삭제하기

organizationBannerUpsert와 organizationBannerDelete mutation으로 시스템 배너를 만들고 삭제해요. 이 기능들은 Enterprise 플랜 고객에게만 제공돼요.

배너를 만들려면 조직의 GraphQL ID와 메시지로 organizationBannerUpsert를 호출해요.

mutation OrganizationBannerUpsert {
  organizationBannerUpsert(input: {
    organizationId: "organization-id",
    message: "**Change to 2FA**: On October 1st ECommerce Inc will require 2FA to be set to access all Pipelines. \r\n\r\n---\r\n\r\nIf you have not set already setup 2FA please go to: [https://buildkite.com/user/two-factor](https://buildkite.com/user/two-factor) and setup 2FA now. ",
  }) {
    clientMutationId
    banner {
      id
      message
      uuid
    }
  }
}

배너를 제거하려면 조직의 GraphQL ID로 organizationBannerDelete를 호출해요.

mutation OrganizationBannerDelete {
  organizationBannerDelete(input: {
    organizationId: "organization-id"
  }) {
    deletedBannerId
  }
}

더 알아보기 (Learn more)

조직 cookbook은 멤버 관리, SSO·보안 정책, 감사 이벤트를 GraphQL로 자동화하는 실전 쿼리 모음이에요. 조직 ID를 먼저 확보하는 패턴이 대부분의 흐름에 반복돼요.