Skip to content

Commit

Permalink
update readme with attr example instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
alkalescent committed May 10, 2024
1 parent 5cef7fa commit abdbeeb
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,30 @@ This will clone the platform repo and generate Typescript code in `lib/src/platf
### Import Typescript code

```
import { GetAttributeRequest } from './lib/src/platform/policy/attributes/attributes_pb';
const request = new GetAttributeRequest(<request data>);
import { Attribute, AttributeRuleTypeEnum } from './lib/src/platform/policy/objects_pb';
const attrData = {
name: "my-attr",
rule: AttributeRuleTypeEnum.ALL_OF,
namespace: {name: 'my-namespace'},
values: [{value: 'my-value'}],
active: true,
extraField: 'this will be ignored' // only proto defined fields are respected
}
const attr = new Attribute(attrData);
console.log(attr.toJson());
// {
// namespace: { name: 'my-namespace' },
// name: 'my-attr',
// rule: 'ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF',
// values: [ { value: 'my-value' } ],
// active: true
// }
const req = new GetAttributeRequest({id: 'uuid-here'});
```

This is an example to import a `GetAttributeRequest` to request attribute information.
Expand Down

0 comments on commit abdbeeb

Please sign in to comment.