Créer une règle d’accès API
Vous pouvez créer une règle pour autoriser l’accès à l’API à partir de votre compte.
Créer une règle d’accès API avec Cockpit v2
-
Dans le coin supérieur droit, cliquez sur l’icône .
Un menu déroulant apparaît. -
Cliquez sur Règles d’accès API.
La liste de vos règles d’accès API apparaît. -
Cliquez sur Créer une règle d’accès API.
La boîte de dialogue CRÉER UNE RÈGLE D’ACCÈS API apparaît. -
(optionnel) Dans le champ Description, tapez une description pour la règle d’accès API.
-
Dans le champ Plage d’IP, tapez une plage d’IP pour la règle d’accès API, en notation CIDR.
Si le bouton Mon IP ne fonctionne pas, vérifiez si une extension de navigateur bloque des scripts sur la page.
-
Cliquez sur Créer.
La règle d’accès API est créée.
Créer une règle d’accès API avec OSC CLI
À ce jour, cette section est disponible en anglais uniquement. |
The CreateApiAccessRule command creates a rule to allow access to the API from your account.
You need to specify at least the CaIds
or the IpRanges
parameter.
By default, your account has a set of rules allowing global access, that you can delete. For more information, see About API Access Rules. |
$ osc-cli api CreateApiAccessRule --profile "default" \
--IpRanges '["192.0.2.0", "198.51.100.0/24"]' \
--Description "Basic API Access Rule with IPs"
$ osc-cli api CreateApiAccessRule --profile "default" \
--IpRanges '["192.0.2.0", "198.51.100.0/24"]' \
--CaIds '["ca-fedcba0987654321fedcba0987654321"]' \
--Description "API Access Rule with IPs and CA"
$ osc-cli api CreateApiAccessRule --profile "default" --authentication-method "password" --login "$OSC_EMAIL" --password "$OSC_PASSWORD" \
--IpRanges '["192.0.2.0", "198.51.100.0/24"]' \
--CaIds '["ca-fedcba0987654321fedcba0987654321"]' \
--Description "API Access Rule with IPs and CA"
This command contains the following attributes that you need to specify:
-
CaIds
: (optional) One or more IDs of Client Certificate Authorities (CAs). -
Cns
: (optional) One or more Client Certificate Common Names (CNs). If this parameter is specified, you must also specify theCaIds
parameter. -
Description
: (optional) A description for the API access rule. -
DryRun
: (optional) If true, checks whether you have the required permissions to perform the action. -
IpRanges
: (optional) One or more IPs or CIDR blocks (for example,192.0.2.0/16
).
The CreateApiAccessRule command returns the following elements:
-
ApiAccessRule
: Information about the API access rule.-
ApiAccessRuleId
: The ID of the API access rule. -
CaIds
: One or more IDs of Client Certificate Authorities (CAs) used for the API access rule. -
Cns
: One or more Client Certificate Common Names (CNs). -
Description
: The description of the API access rule. -
IpRanges
: One or more IP ranges used for the API access rule, in CIDR notation (for example,192.0.2.0/16
).
-
-
ResponseContext
: Information about the context of the response.-
RequestId
: The ID of the request.
-
{
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
},
"ApiAccessRule": {
"IpRanges": [
"192.0.2.0",
"198.51.100.0/24"
],
"ApiAccessRuleId": "aar-fedcba0987654321fedcba0987654321",
"CaIds": [],
"Cns": [],
"Description": "Basic API Access Rule with IPs"
}
}
{
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
},
"ApiAccessRule": {
"IpRanges": [
"192.0.2.0",
"198.51.100.0/24"
],
"ApiAccessRuleId": "aar-fedcba0987654321fedcba0987654321",
"CaIds": [
"ca-fedcba0987654321fedcba0987654321"
],
"Cns": [],
"Description": "API Access Rule with IPs and CA"
}
}
Créer une règle d’accès API avec oapi-cli
À ce jour, cette section est disponible en anglais uniquement. |
The CreateApiAccessRule command creates a rule to allow access to the API from your account.
You need to specify at least the CaIds
or the IpRanges
parameter.
By default, your account has a set of rules allowing global access, that you can delete. For more information, see About API Access Rules. |
$ oapi-cli --profile "default" CreateApiAccessRule \
--IpRanges '["192.0.2.0", "198.51.100.0/24"]' \
--Description "Basic API Access Rule with IPs"
$ oapi-cli --profile "default" CreateApiAccessRule \
--IpRanges '["192.0.2.0", "198.51.100.0/24"]' \
--CaIds '["ca-fedcba0987654321fedcba0987654321"]' \
--Description "API Access Rule with IPs and CA"
$ oapi-cli --profile "default" --login "$OSC_EMAIL" --password "$OSC_PASSWORD" CreateApiAccessRule \
--IpRanges '["192.0.2.0", "198.51.100.0/24"]' \
--CaIds '["ca-fedcba0987654321fedcba0987654321"]' \
--Description "API Access Rule with IPs and CA"
This command contains the following attributes that you need to specify:
-
CaIds
: (optional) One or more IDs of Client Certificate Authorities (CAs). -
Cns
: (optional) One or more Client Certificate Common Names (CNs). If this parameter is specified, you must also specify theCaIds
parameter. -
Description
: (optional) A description for the API access rule. -
DryRun
: (optional) If true, checks whether you have the required permissions to perform the action. -
IpRanges
: (optional) One or more IPs or CIDR blocks (for example,192.0.2.0/16
).
The CreateApiAccessRule command returns the following elements:
-
ApiAccessRule
: Information about the API access rule.-
ApiAccessRuleId
: The ID of the API access rule. -
CaIds
: One or more IDs of Client Certificate Authorities (CAs) used for the API access rule. -
Cns
: One or more Client Certificate Common Names (CNs). -
Description
: The description of the API access rule. -
IpRanges
: One or more IP ranges used for the API access rule, in CIDR notation (for example,192.0.2.0/16
).
-
-
ResponseContext
: Information about the context of the response.-
RequestId
: The ID of the request.
-
{
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
},
"ApiAccessRule": {
"IpRanges": [
"192.0.2.0",
"198.51.100.0/24"
],
"ApiAccessRuleId": "aar-fedcba0987654321fedcba0987654321",
"CaIds": [],
"Cns": [],
"Description": "Basic API Access Rule with IPs"
}
}
{
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
},
"ApiAccessRule": {
"IpRanges": [
"192.0.2.0",
"198.51.100.0/24"
],
"ApiAccessRuleId": "aar-fedcba0987654321fedcba0987654321",
"CaIds": [
"ca-fedcba0987654321fedcba0987654321"
],
"Cns": [],
"Description": "API Access Rule with IPs and CA"
}
}
Pages connexes
Méthode API correspondante