Xojo Plugin AWS IAM: Create Group

Back to Index

Creates a new group.

Documentation: https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateGroup.html

CURL Command

curl -X GET https://iam.amazonaws.com/ \
  -d "Action=CreateGroup" \
  -d "GroupName=Consultants" \
  -d "Version=2010-05-08"

Xojo Plugin Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

Dim authAws As New Chilkat.AuthAws
authAws.AccessKey = "AWS_ACCESS_KEY"
authAws.SecretKey = "AWS_SECRET_KEY"
authAws.Region = "us-east-1"
authAws.ServiceName = "iam"
rest.SetAuthAws(authAws)

//  URL: https://iam.amazonaws.com/
Dim bTls As Boolean
bTls = True
Dim port As Int32
port = 443
Dim bAutoReconnect As Boolean
bAutoReconnect = True
success = rest.Connect("iam.amazonaws.com",port,bTls,bAutoReconnect)
If (success <> True) Then
    System.DebugLog("ConnectFailReason: " + Str(rest.ConnectFailReason))
    System.DebugLog(rest.LastErrorText)
    Return
End If

rest.AddQueryParam("Action","CreateGroup")
rest.AddQueryParam("GroupName","Consultants")
rest.AddQueryParam("Version","2010-05-08")

Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestNoBodySb("GET","/",sbResponseBody)
If (success <> True) Then
    System.DebugLog(rest.LastErrorText)
    Return
End If

Dim respStatusCode As Int32
respStatusCode = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
    System.DebugLog("Response Status Code = " + Str(respStatusCode))
    System.DebugLog("Response Header:")
    System.DebugLog(rest.ResponseHeader)
    System.DebugLog("Response Body:")
    System.DebugLog(sbResponseBody.GetAsString())
    Return
End If

Dim xmlResponse As New Chilkat.Xml
xmlResponse.LoadSb(sbResponseBody,True)

Dim CreateGroupResponse_xmlns As String
Dim tagPath As String
Dim Path As String
Dim GroupName As String
Dim Arn As String
Dim GroupId As String
Dim CreateDate As String
Dim RequestId As String

CreateGroupResponse_xmlns = xmlResponse.GetAttrValue("xmlns")
Path = xmlResponse.GetChildContent("CreateGroupResult|Group|Path")
GroupName = xmlResponse.GetChildContent("CreateGroupResult|Group|GroupName")
Arn = xmlResponse.GetChildContent("CreateGroupResult|Group|Arn")
GroupId = xmlResponse.GetChildContent("CreateGroupResult|Group|GroupId")
CreateDate = xmlResponse.GetChildContent("CreateGroupResult|Group|CreateDate")
RequestId = xmlResponse.GetChildContent("ResponseMetadata|RequestId")

Sample XML Response Body

<?xml version="1.0" encoding="utf-8" ?>
<CreateGroupResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
    <CreateGroupResult>
        <Group>
            <Path>/</Path>
            <GroupName>Consultants</GroupName>
            <Arn>arn:aws:iam::954491834127:group/Consultants</Arn>
            <GroupId>AGPAJNGBO5CWC6OJKSWHQ</GroupId>
            <CreateDate>2018-05-19T21:38:34.185Z</CreateDate>
        </Group>
    </CreateGroupResult>
    <ResponseMetadata>
        <RequestId>fb31888b-5bac-11e8-963f-6d117c496f53</RequestId>
    </ResponseMetadata>
</CreateGroupResponse>