Create Firewall Group Rule
Mike.robski (Talk | contribs) |
|||
Line 1: | Line 1: | ||
This operation will create a new firewall group rule. | This operation will create a new firewall group rule. | ||
− | + | ='''POST''' /os-security-group-rules= | |
+ | This operation will create a new firewall group rule. | ||
− | + | == Request == | |
− | + | === JSON === | |
<nowiki> | <nowiki> | ||
{ | { | ||
Line 16: | Line 17: | ||
}</nowiki> | }</nowiki> | ||
− | + | ====security_group_rule==== | |
; from_port - ''int'' | ; from_port - ''int'' | ||
: Start port number. | : Start port number. | ||
Line 32: | Line 33: | ||
: Parent group identifier for this rule. | : Parent group identifier for this rule. | ||
− | + | == Response == | |
− | + | === JSON === | |
<nowiki> | <nowiki> | ||
{ | { | ||
Line 68: | Line 69: | ||
</nowiki> | </nowiki> | ||
− | + | ====security_group_rule==== | |
; from_port - ''int'' | ; from_port - ''int'' | ||
: Start port number. | : Start port number. | ||
Line 93: | Line 94: | ||
: Firewall group rule unique identifier. | : Firewall group rule unique identifier. | ||
− | + | == Response Codes == | |
; Success | ; Success | ||
: ''HTTP/1.1 201 Created'' | : ''HTTP/1.1 201 Created'' | ||
Line 101: | Line 102: | ||
: ''HTTP/1.1 401 Unauthorized'' : This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required. | : ''HTTP/1.1 401 Unauthorized'' : This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required. | ||
− | + | == Examples == | |
'''Successfully create a new firewall group rule''' | '''Successfully create a new firewall group rule''' | ||
:'''POST''' http(s)://{api_server}//os-security-group-rules | :'''POST''' http(s)://{api_server}//os-security-group-rules | ||
Line 242: | Line 243: | ||
"message": "Invalid", | "message": "Invalid", | ||
"code": 400, | "code": 400, | ||
− | "details": "" | + | "details": "", |
+ | "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf" | ||
} | } | ||
}</nowiki> | }</nowiki> | ||
Line 274: | Line 276: | ||
"message": "FirewallRuleError", | "message": "FirewallRuleError", | ||
"code": 400, | "code": 400, | ||
− | "details": "Invalid ports" | + | "details": "Invalid ports", |
+ | "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf" | ||
} | } | ||
}</nowiki> | }</nowiki> | ||
Line 306: | Line 309: | ||
"message": "Invalid", | "message": "Invalid", | ||
"code": 400, | "code": 400, | ||
− | "details": "" | + | "details": "", |
+ | "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf" | ||
} | } | ||
}</nowiki> | }</nowiki> | ||
Line 338: | Line 342: | ||
"message": "FirewallRuleError", | "message": "FirewallRuleError", | ||
"code": 400, | "code": 400, | ||
− | "details": "Source IP address is invalid" | + | "details": "Source IP address is invalid", |
+ | "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf" | ||
} | } | ||
}</nowiki> | }</nowiki> | ||
Line 359: | Line 364: | ||
wrong credentials (e.g., bad password), or your browser | wrong credentials (e.g., bad password), or your browser | ||
does not understand how to supply the credentials required. | does not understand how to supply the credentials required. | ||
− | |||
[[Category:Hostway API]] | [[Category:Hostway API]] | ||
[[Category:FlexCloud Server API]] | [[Category:FlexCloud Server API]] | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 07:21, 20 May 2013
This operation will create a new firewall group rule.
Contents |
POST /os-security-group-rules
This operation will create a new firewall group rule.
Request
JSON
{ "security_group_rule" : { "from_port": {start_port}, "to_port": {end_port}, "ip_protocol": "{ip_protocol}", "cidr": "127.0.0.1/24", "parent_group_id": "{parent_group_id}" } }
security_group_rule
- from_port - int
- Start port number.
- to_port - int
- End port number.
- ip_protocol - string
- IP protocol used.
- cidr - string
- CIDR notation IP address.
- parent_group_id - string
- Parent group identifier for this rule.
Response
JSON
{ "security_group_rule" : { "from_port": {start_port}, "group": { "display_name": "{firewall_group_display_name}", "name": "{firewall_group_name}", "links": [ { "href": "http://{api_server}/os-security-groups/{firewall_group_name}/", "rel": "self" } ], "description": "{firewall_group_description}", "account_number": "{user_account_number}", "servers": [] }, "ip_protocol": "{ip_protocol}", "links": [ { "href": "http://{api_server}/os-security-group-rules/{firewall_group_rule_id}/", "rel": "self" } ], "to_port": {end_port}, "parent_group_id": "{parent_firewall_group_name}", "ip_range": { "cidr": "127.0.0.1/24" }, "id": {firewall_group_rule_id} } }
security_group_rule
- from_port - int
- Start port number.
- group - dictionary
- Firewall group information.
- ip_protocol - string
- IP protocol used.
- links - list
- Hypermedia for this resource.
- to_port - int
- End port number.
- parent_group_id - string
- Parent group identifier for this rule.
- ip_range - dictionary
- IP range in CIDR notation.
- id - string
- Firewall group rule unique identifier.
Response Codes
- Success
- HTTP/1.1 201 Created
- Failure
- HTTP/1.1 400 Bad Request
- HTTP/1.1 401 Unauthorized : This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.
Examples
Successfully create a new firewall group rule
- POST http(s)://{api_server}//os-security-group-rules
Request Headers:
Content-Type:application/json Charset=UTF-8 Authorization:Base64-encoded username & password string
Request Body:
{ "security_group_rule" : { "from_port": 80, "to_port": 80, "ip_protocol": "tcp", "cidr": "127.0.0.1/24", "parent_group_id": "group2012May11_NpCpS3995" } }
Response Code:
HTTP/1.1 201 Created
Response Body:
{ "security_group_rule" : { "from_port": 80, "group": { "display_name": "Rules Test Group", "name": "group2012May11_NpCpS3995", "links": [ { "href": "http://{api_server}/os-security-groups/group2012May11_NpCpS3995/", "rel": "self" } ], "description": "A firewall group created from test", "account_number": "test_account_718912", "servers": [] }, "ip_protocol": "tcp", "links": [ { "href": "http://{api_server}/os-security-group-rules/214/", "rel": "self" } ], "to_port": 80, "parent_group_id": "group2012May11_NpCpS3995", "ip_range": { "cidr": "127.0.0.1/24" }, "id": 214 } }
Successfully create a new firewall group rule with an IP without a netmask
- POST http(s)://{api_server}//os-security-group-rules
Request Headers:
Content-Type:application/json Charset=UTF-8 Authorization:Base64-encoded username & password string
Request Body:
{ "security_group_rule" : { "from_port": 80, "to_port": 80, "ip_protocol": "tcp", "cidr": "127.0.0.1", "parent_group_id": "group2012May11_NpCpS3995" } }
Response Code:
HTTP/1.1 201 Created
Response Body:
{ "security_group_rule" : { "from_port": 80, "group": { "display_name": "Rules Test Group", "name": "group2012May11_NpCpS3995", "links": [ { "href": "http://{api_server}/os-security-groups/group2012May11_NpCpS3995/", "rel": "self" } ], "description": "A firewall group created from test", "account_number": "test_account_718912", "servers": [] }, "ip_protocol": "tcp", "links": [ { "href": "http://{api_server}/os-security-group-rules/215/", "rel": "self" } ], "to_port": 80, "parent_group_id": "group2012May11_NpCpS3995", "ip_range": { "cidr": "127.0.0.1/32" }, "id": 215 } }
Failure while trying to create a new firewall group rule with invalid data
- POST http(s)://{api_server}/os-security-group-rules
Request Headers:
Content-Type:application/json Charset=UTF-8 Authorization:Base64-encoded username & password string
Request Body:
{
Empty
}
Response Code:
HTTP/1.1 400 Bad Request
Response Body:
{ "badRequest" : { "message": "Invalid", "code": 400, "details": "", "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf" } }
Failure while trying to create a new rule with invalid from and to ports
- POST http(s)://{api_server}/os-security-group-rules
Request Headers:
Content-Type:application/json Charset=UTF-8 Authorization:Base64-encoded username & password string
Request Body:
{ "security_group_rule" : { "from_port": 81, "to_port": 80, "ip_protocol": "tcp", "cidr": "127.0.0.1/24", "parent_group_id": "group2012May11_NpCpS3995" } }
Response Code:
HTTP/1.1 400 Bad Request
Response Body:
{ "badRequest" : { "message": "FirewallRuleError", "code": 400, "details": "Invalid ports", "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf" } }
Failure while trying to create a new rule rule with an invalid protocol
- POST http(s)://{api_server}/os-security-group-rules
Request Headers:
Content-Type:application/json Charset=UTF-8 Authorization:Base64-encoded username & password string
Request Body:
{
"security_group_rule" : {
"from_port": 80,
"to_port": 80,
"ip_protocol": "proto",
"cidr": "127.0.0.1/24",
"parent_group_id": "group2012May11_NpCpS3995"
}
}
Response Code:
HTTP/1.1 400 Bad Request
Response Body:
{ "badRequest" : { "message": "Invalid", "code": 400, "details": "", "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf" } }
Failure while trying to create a new firewall rule with an invalid IP address
- POST http(s)://{api_server}/os-security-group-rules
Request Headers:
Content-Type:application/json Charset=UTF-8 Authorization:Base64-encoded username & password string
Request Body:
{
"security_group_rule" : {
"from_port": 80,
"to_port": 80,
"ip_protocol": "tcp",
"cidr": "ip_address",
"parent_group_id": "group2012May11_NpCpS3995"
}
}
Response Code:
HTTP/1.1 400 Bad Request
Response Body:
{ "badRequest" : { "message": "FirewallRuleError", "code": 400, "details": "Source IP address is invalid", "errorid": "59e0b3dd-2173-432a-8ff5-60efe16e83bf" } }
Failure while trying to make unauthorized access
- POST http(s)://{api_server}/os-security-groups
Request Headers:
Content-Type:application/json
Charset=UTF-8
Authorization:Base64-encoded fake_authentication_string
Response Code:
HTTP/1.1 401 Unauthorized
Response Body:
401 Unauthorized This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.