# NEWT IRIS

We use a subest of a language called graphql to generate these queries.

You will need to call a function with a specified parameter, and describe the fields you would like returned.

## Syntax

```
function_name(param: value) {
    field1, 
    field2,
    field3 {
        nestedfield1,
        nestedfield2
    }    
}
```

returns

```
{
  "data": {
    "newt": {
      "function_name": // json {} or [] 
    }
  }
}
```

## Valid Calls:

1. Please call with ONE of the parameters specified
2. Please include the fields you want returned
3. To pass this into NEWT please double escape any quotes (`\\\"`) and trim newlines


### User Info
Call with either UID or username. Returns user information along with basic account information for each system
```
user(uid: Int, username: String): {
    uid,
    name,
    firstname,
    lastname,
    middlename,
    ldapUsers {
        shell,
        hostname,
        loginType,
        status,
        homedir,
        gid,
        gname,
    }
    organization,
    workphone,
    otherPhones,
    email
}
```


eg.
```
data = "user(username: \\\"myusername\\\") {uid, name, firstname, lastname, middlename, ldapUsers {shell, hostname, loginType, status, homedir, gid, gname, } organization, workphone, otherPhones, email }"

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})



```

### Project Info
Returns Project Information
```
project(projectId: Int, repoName: String) {
  projectId,
  label,
  description,
  repoName,
  imageId,
  imageType,
  imageUrl,
  scicat,
  program,
  office,
  allocationType,
  allocationPool,
  organization {
    organizationId,
    label,
    description,
  }
}
```

eg.
```
data="project(repoName: \\\"m12345\\\"){projectId, label, description, repoName, imageId, imageType, imageUrl, scicat, program, office, allocationType, allocationPool, organization {organizationId,label,description}}"

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})

```

### Allocation Information for User
Returns per repo usage for the user 
```
accounts(uid: Int, username: String) {
  projectId,
  repoName,
  repoType,
  currentAlloc,
  usedAlloc,
  users {
    uid,
    name,
    firstname,
    lastname,
    middlename,
    userAlloc,
    userAllocPct,
    usedAlloc
  }
}
```


eg.
```
data = "accounts(username: \\\"myusername\\\") {projectId, repoName, repoType, currentAlloc, usedAlloc, users {uid, name, firstname, lastname, middlename, userAlloc, userAllocPct, usedAlloc } }"

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})
```


### Allocation Information for Project
Returns repo usage for all users in a repo
```
accounts(projectId: Int, repoName: String) {
  projectId,
  repoName,
  repoType,
  currentAlloc,
  usedAlloc,
  users {
    uid,
    name,
    firstname,
    lastname,
    middlename,
    userAlloc,
    userAllocPct,
    usedAlloc
  }
}

```

eg.
```
data = "accounts(repoName: \\\"myreponame\\\") {projectId, repoName, repoType, currentAlloc, usedAlloc, users {uid, name, firstname, lastname, middlename, userAlloc, userAllocPct, usedAlloc } }"

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})

```

### HPSS Usage Information for User
Returns HPSS storage used across repos for a given user
```
hpss(uid: Int, username: String) {
  projectId,
  repoName,
  currentAlloc,
  users {
    uid,
    name,
    userAllocPct,
    pctChargedToProject,
    bytesUsed,
    fileCount
  }
}
```

eg.
```
data = "hpss(username: \\\"myusername\\\") {projectId, repoName, currentAlloc, users {uid, name, userAllocPct, pctChargedToProject, bytesUsed, fileCount } } "

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})

```

### HPSS Usage Information for Project
Returns HPSS storage used for all users in a given repo
```
hpss(projectId: Int, repoName: String) {
  projectId,
  repoName,
  currentAlloc,
  users {
    uid,
    name,
    userAllocPct,
    pctChargedToProject,
    bytesUsed,
    fileCount
  }
}
```

eg.
```
data = "hpss(repoName: \\\"myreponame\\\") {projectId, repoName, currentAlloc, users {uid, name, userAllocPct, pctChargedToProject, bytesUsed, fileCount } } "

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})

```

### Project Role Information
Returns list of project roles per user
```
roles(uid: Int, username: String) {
  uid,
  name,
  firstname,
  lastname,
  middlename,
  projectId,
  repoName,
  role
}
```
eg.
```
data = "roles(username: \\\"myusername\\\") {uid, name, firstname, lastname, middlename, projectId, repoName, role }"

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})

```

### User Role Information
Returns list of user roles per project
```
roles(projectId: Int, repoName: String) {
  uid,
  name,
  firstname,
  lastname,
  middlename,
  projectId,
  repoName,
  role
}
```

eg.
```
data = "roles(repoName: \\\"myrepo\\\") {uid, name, firstname, lastname, middlename, projectId, repoName, role }"

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})

```

### User Group Information
Returns list of groups for the user
```
groups(uid: Int, username: String) {
  gid,
  name,
  projectId,
  repoName
} 
```

eg.
```
data = "groups(username: \\\"myusername\\\") {gid, name, projectId, repoName}"

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})

```

### Project Group Information
Returns list of groups for the project

```
groups(projectId: Int, repoName: String) {
  gid,
  name,
  projectId,
  repoName
} 
```


eg.
```
data = "groups(repoName: \\\"myreponame\\\") {gid, name, projectId, repoName}"

$.newt_ajax({
    url: "/account/iris",
    type: "POST",
    data: data,
    success: function(output) {
        console.log(output.data)
    }
})

```