GitHub CI Visibility 상태 업데이트
https://api.datadoghq.com/api/v2/ci/github/accountshttps://api.us3.datadoghq.com/api/v2/ci/github/accountshttps://api.us5.datadoghq.com/api/v2/ci/github/accountshttps://api.datadoghq.eu/api/v2/ci/github/accountshttps://api.ap1.datadoghq.com/api/v2/ci/github/accountshttps://api.ap2.datadoghq.com/api/v2/ci/github/accountshttps://api.uk1.datadoghq.com/api/v2/ci/github/accountshttps://api.ddog-gov.com/api/v2/ci/github/accountshttps://api.us2.ddog-gov.com/api/v2/ci/github/accounts개요
GitHub 계정, 해당 리포지토리 중 하나 또는 둘 다에 대해 동일한 요청으로 CI Visibility를 활성화하거나 비활성화합니다.
계정(및 선택적으로 리포지토리)은 이름으로 식별됩니다. 계정 수준 및 리포지토리 수준의
변경 사항은 독립적이며 동일한 요청에서 둘 다 제공될 수 있습니다. enabled 또는
repository.enabled 중 하나 이상이 제공되어야 합니다. 계정 이름이 둘 이상의 호스트에 있는 설치와 일치하는 경우
구분을 위해 host를 제공해야 하며, 그렇지 않으면 409가 반환됩니다. CI Visibility GitHub 통합이
이 조직에 대해 활성화되지 않았거나 지정된 계정 또는 리포지토리를 이름으로 찾을 수 없는 경우
404를 반환합니다.
OAuth apps require the ci_provider_settings_write authorization scope to access this endpoint.
요청
Body Data (required)
data [required]GitHub 계정의 CI Visibility 옵트인 상태를 업데이트하기 위한 요청 객체입니다.
attributes [required]Attributes for updating a GitHub account's CI Visibility opt-in status.
At least one of enabled or repository.enabled must be provided.
account [required]The GitHub account (organization or user) name to update, identified by name.
enabledWhether to enable or disable CI Visibility at the account level.
hostThe GitHub host (github.com or a GHES hostname) the account belongs to. Required to disambiguate
when the same account name exists on more than one host.
repositoryRepository-level opt-in change to apply, identified by name.
enabled [required]Whether to enable or disable CI Visibility for this repository.
name [required]The repository name to update.
type [required]JSON:API type for the GitHub account resource.
The value must always be ci_github_account.
ci_github_account{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}응답
OK
Response object containing a single GitHub account's CI Visibility opt-in status.
data [required]Data object for a GitHub account.
attributes [required]Attributes describing a GitHub account's CI Visibility opt-in status.
accountThe GitHub account (organization or user) name.
enabledWhether CI Visibility is enabled at the account level.
hostThe GitHub host (github.com or a GitHub Enterprise Server (GHES) hostname) this account belongs to.
repo_countThe number of repositories known for this account.
repositoriesThe repositories belonging to this account, with their individual opt-in status.
enabledWhether CI Visibility is enabled for this repository.
nameThe repository name.
id [required]The account's unique identifier, in the form <host>/<account name>
(for example github.com/datadog).
type [required]JSON:API type for the GitHub account resource.
The value must always be ci_github_account.
ci_github_account{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repo_count": 12,
"repositories": [
{
"enabled": true,
"name": "shopist"
}
]
},
"id": "github.com/datadog",
"type": "ci_github_account"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Authorized
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Found
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Conflict
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}코드 예시
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"account": "datadog",
"enabled": true,
"host": "github.com",
"repository": {
"enabled": true,
"name": "shopist"
}
},
"type": "ci_github_account"
}
}
EOF// Update GitHub CI Visibility status returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.CIAppGitHubAccountUpdateRequest{
Data: datadogV2.CIAppGitHubAccountUpdateRequestData{
Attributes: datadogV2.CIAppGitHubAccountUpdateRequestAttributes{
Account: "datadog",
Enabled: datadog.PtrBool(true),
Host: datadog.PtrString("github.com"),
Repository: &datadogV2.CIAppGitHubAccountUpdateRequestRepository{
Enabled: true,
Name: "shopist",
},
},
Type: datadogV2.CIAPPGITHUBACCOUNTTYPE_CI_GITHUB_ACCOUNT,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewCIVisibilityGitHubAccountsApi(apiClient)
resp, r, err := api.UpdateCIAppGitHubAccount(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CIVisibilityGitHubAccountsApi.UpdateCIAppGitHubAccount`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `CIVisibilityGitHubAccountsApi.UpdateCIAppGitHubAccount`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Update GitHub CI Visibility status returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.CiVisibilityGitHubAccountsApi;
import com.datadog.api.client.v2.model.CIAppGitHubAccountResponse;
import com.datadog.api.client.v2.model.CIAppGitHubAccountType;
import com.datadog.api.client.v2.model.CIAppGitHubAccountUpdateRequest;
import com.datadog.api.client.v2.model.CIAppGitHubAccountUpdateRequestAttributes;
import com.datadog.api.client.v2.model.CIAppGitHubAccountUpdateRequestData;
import com.datadog.api.client.v2.model.CIAppGitHubAccountUpdateRequestRepository;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
CiVisibilityGitHubAccountsApi apiInstance = new CiVisibilityGitHubAccountsApi(defaultClient);
CIAppGitHubAccountUpdateRequest body =
new CIAppGitHubAccountUpdateRequest()
.data(
new CIAppGitHubAccountUpdateRequestData()
.attributes(
new CIAppGitHubAccountUpdateRequestAttributes()
.account("datadog")
.enabled(true)
.host("github.com")
.repository(
new CIAppGitHubAccountUpdateRequestRepository()
.enabled(true)
.name("shopist")))
.type(CIAppGitHubAccountType.CI_GITHUB_ACCOUNT));
try {
CIAppGitHubAccountResponse result = apiInstance.updateCIAppGitHubAccount(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling CiVisibilityGitHubAccountsApi#updateCIAppGitHubAccount");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Update GitHub CI Visibility status returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.ci_visibility_git_hub_accounts_api import CIVisibilityGitHubAccountsApi
from datadog_api_client.v2.model.ci_app_git_hub_account_type import CIAppGitHubAccountType
from datadog_api_client.v2.model.ci_app_git_hub_account_update_request import CIAppGitHubAccountUpdateRequest
from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_attributes import (
CIAppGitHubAccountUpdateRequestAttributes,
)
from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_data import CIAppGitHubAccountUpdateRequestData
from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_repository import (
CIAppGitHubAccountUpdateRequestRepository,
)
body = CIAppGitHubAccountUpdateRequest(
data=CIAppGitHubAccountUpdateRequestData(
attributes=CIAppGitHubAccountUpdateRequestAttributes(
account="datadog",
enabled=True,
host="github.com",
repository=CIAppGitHubAccountUpdateRequestRepository(
enabled=True,
name="shopist",
),
),
type=CIAppGitHubAccountType.CI_GITHUB_ACCOUNT,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = CIVisibilityGitHubAccountsApi(api_client)
response = api_instance.update_ci_app_git_hub_account(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Update GitHub CI Visibility status returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::CIVisibilityGitHubAccountsAPI.new
body = DatadogAPIClient::V2::CIAppGitHubAccountUpdateRequest.new({
data: DatadogAPIClient::V2::CIAppGitHubAccountUpdateRequestData.new({
attributes: DatadogAPIClient::V2::CIAppGitHubAccountUpdateRequestAttributes.new({
account: "datadog",
enabled: true,
host: "github.com",
repository: DatadogAPIClient::V2::CIAppGitHubAccountUpdateRequestRepository.new({
enabled: true,
name: "shopist",
}),
}),
type: DatadogAPIClient::V2::CIAppGitHubAccountType::CI_GITHUB_ACCOUNT,
}),
})
p api_instance.update_ci_app_git_hub_account(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Update GitHub CI Visibility status returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_ci_visibility_git_hub_accounts::CIVisibilityGitHubAccountsAPI;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountType;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountUpdateRequest;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountUpdateRequestAttributes;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountUpdateRequestData;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountUpdateRequestRepository;
#[tokio::main]
async fn main() {
let body = CIAppGitHubAccountUpdateRequest::new(CIAppGitHubAccountUpdateRequestData::new(
CIAppGitHubAccountUpdateRequestAttributes::new("datadog".to_string())
.enabled(true)
.host("github.com".to_string())
.repository(CIAppGitHubAccountUpdateRequestRepository::new(
true,
"shopist".to_string(),
)),
CIAppGitHubAccountType::CI_GITHUB_ACCOUNT,
));
let configuration = datadog::Configuration::new();
let api = CIVisibilityGitHubAccountsAPI::with_config(configuration);
let resp = api.update_ci_app_git_hub_account(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Update GitHub CI Visibility status returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.CIVisibilityGitHubAccountsApi(configuration);
const params: v2.CIVisibilityGitHubAccountsApiUpdateCIAppGitHubAccountRequest =
{
body: {
data: {
attributes: {
account: "datadog",
enabled: true,
host: "github.com",
repository: {
enabled: true,
name: "shopist",
},
},
type: "ci_github_account",
},
},
};
apiInstance
.updateCIAppGitHubAccount(params)
.then((data: v2.CIAppGitHubAccountResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"