Azure Entra IDのエンタープライズアプリケーションを取得する

Application.Read.Allが必要。

cf. アプリケーションを取得する - Microsoft Graph v1.0 | Microsoft Learn

#!/usr/bin/env python
# pip install azure-identity msgraph-sdk
import asyncio
import pprint
from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient

client_id = "..."
tenant_id = "..."
client_secret = "..."

credentials = ClientSecretCredential(
    tenant_id=tenant_id, client_id=client_id, client_secret=client_secret
)
scopes = ["https://graph.microsoft.com/.default"]
client = GraphServiceClient(credentials=credentials, scopes=scopes)


async def print_app():
    apps = await client.applications.get()
    for app in apps.value:
        pprint.pprint(app.display_name)


asyncio.run(print_app())

GitHub GraphQL APIでApproveとCheckのステータスを取得する

クエリ

{
  search(type: ISSUE, last: 100, query: "is:open is:pr author:@me org:qubole") {
    nodes {
      ... on PullRequest {
        title
        url
        reviewDecision
        commits(last: 1) {
          nodes {
            commit {
              statusCheckRollup {
                state
              }
            }
          }
        }
      }
    }
  }
}

結果

{
  "data": {
    "search": {
      "nodes": [
        {
          "title": "Fix or skip deepsource check in commands.py",
          "url": "https://github.com/qubole/qds-sdk-py/pull/341",
          "reviewDecision": "REVIEW_REQUIRED",
          "commits": {
            "nodes": [
              {
                "commit": {
                  "statusCheckRollup": {
                    "state": "SUCCESS"
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

cf.

SwiftのCLIでGitHub APIをたたく

GitHub - winebarrel/swift-octokit-cli-example

// let package = Package(
//     name: "octokit-cli",
//     platforms: [
//         .macOS(.v14),
//     ],

import Foundation
import OctoKit

let env = ProcessInfo.processInfo.environment
let token = env["GITHUB_TOKEN"]!
let config = TokenConfiguration(token)

let octokit = Octokit(config)
let user = try! await octokit.me()
print(user.name!)

// async未対応の場合
let ns = try! await withCheckedThrowingContinuation { continuation in
    octokit.myNotifications { response in
        switch response {
        case let .success(notifications):
            continuation.resume(returning: notifications)
        case let .failure(error):
            continuation.resume(throwing: error)
        }
    }
}

for n in ns {
    print(n.subject.title!)
}