メインコンテンツへスキップ
PATCH
https://{tenantDomain}/api/v2
/
rules
/
{id}
Go
package example

import (
    context "context"

    management "github.com/auth0/go-auth0/management/management"
    client "github.com/auth0/go-auth0/management/management/client"
    option "github.com/auth0/go-auth0/management/management/option"
)

func do() {
    client := client.NewClient(
        option.WithToken(
            "<token>",
        ),
    )
    request := &management.UpdateRuleRequestContent{}
    client.Rules.Update(
        context.TODO(),
        "id",
        request,
    )
}
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.rules.update("id", {});
}
main();
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.rules.update("id", {});
}
main();
curl --request PATCH \
--url https://{tenantDomain}/api/v2/rules/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"script": "function (user, context, callback) {\n callback(null, user, context);\n}",
"name": "my-rule",
"order": 2,
"enabled": true
}
'
import requests

url = "https://{tenantDomain}/api/v2/rules/{id}"

payload = {
"script": "function (user, context, callback) {
callback(null, user, context);
}",
"name": "my-rule",
"order": 2,
"enabled": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenantDomain}/api/v2/rules/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'script' => 'function (user, context, callback) {
callback(null, user, context);
}',
'name' => 'my-rule',
'order' => 2,
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.patch("https://{tenantDomain}/api/v2/rules/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"script\": \"function (user, context, callback) {\\n callback(null, user, context);\\n}\",\n \"name\": \"my-rule\",\n \"order\": 2,\n \"enabled\": true\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{tenantDomain}/api/v2/rules/{id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"script\": \"function (user, context, callback) {\\n callback(null, user, context);\\n}\",\n \"name\": \"my-rule\",\n \"order\": 2,\n \"enabled\": true\n}"

response = http.request(request)
puts response.read_body
{
  "name": "rule_1",
  "id": "con_0000000000000001",
  "enabled": true,
  "script": "function (user, context, callback) {\n  callback(null, user, context);\n}",
  "order": 1,
  "stage": "login_success"
}

承認

Authorization
string
header
必須

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

パスパラメータ

id
string
必須

ID of the rule to retrieve.

ボディ

script
string
デフォルト:function (user, context, callback) { callback(null, user, context); }

Code to be executed when this rule runs.

Minimum string length: 1
name
string
デフォルト:my-rule

Name of this rule.

Pattern: ^[a-zA-Z0-9]([ \-a-zA-Z0-9]*[a-zA-Z0-9])?$
order
number
デフォルト:2

Order that this rule should execute in relative to other rules. Lower-valued rules execute first.

必須範囲: x >= 0
enabled
boolean
デフォルト:true

Whether the rule is enabled (true), or disabled (false).

レスポンス

Rule successfully updated.

name
string
デフォルト:rule_1

Name of this rule.

id
string
デフォルト:con_0000000000000001

ID of this rule.

enabled
boolean
デフォルト:true

Whether the rule is enabled (true), or disabled (false).

script
string
デフォルト:function (user, context, callback) { callback(null, user, context); }

Code to be executed when this rule runs.

order
number
デフォルト:1

Order that this rule should execute in relative to other rules. Lower-valued rules execute first.

stage
string
デフォルト:login_success

Execution stage of this rule. Can be login_success, login_failure, or pre_authorize.