Test page builder

Sports & Entertainment
27 Oct 202212:13

Summary

TLDRThis video tutorial provides an introduction to Configurable Web Services (CWS) and basic actions within Page Builder. CWS is a server-side feature in Mocha that allows developers to expose commands as web services without writing new code. The video explains key concepts like actions, resources, and CRUD operations (Create, Read, Update, Delete), using XML files to configure them. It also covers how CWS manages data types, primary keys, and HTTP requests through action arguments, authorization settings, and web service configurations. Overall, the tutorial equips users to manage CWS and its configurations effectively.

Takeaways

  • πŸ”§ CWS (Configurable Web Services) is the server-side backend of the Page Builder tool, allowing users to expose Mocha commands as web services without writing new code.
  • πŸ“ CWS is configured through two fundamental elements: actions and resources, both represented as XML files located in a product’s data/WS directory.
  • πŸ”— Resources model real-world objects with a unique primary key or compound primary key, defining properties and actions to interact with these objects.
  • πŸ“œ Properties in a resource correspond to database columns and are essential for configuring Page Builder, defining namespaces for modifying data.
  • βš™οΈ Actions define specific tasks related to resources, such as adding, listing, editing, or deleting items. These actions are also defined in the XML configuration files.
  • 🌐 Each action includes an HTTP method and a URL endpoint, allowing external clients to trigger Mocha commands via web services.
  • πŸ—οΈ The command element within an action links the action to a specific Mocha command, which must be pre-defined and cannot be a freeform command.
  • πŸ”‘ Arguments can be passed to actions, specifying which data to use, with detailed configurations for each argument's name, type, and location (path, query, header, or body).
  • πŸ›‘οΈ Authorization for actions can be configured, with the highest level of security being 'mocha-admin' and lower permissions as needed.
  • πŸ”„ CRUD (Create, Read, Update, Delete) operations are core actions associated with resources, and these operations can be configured for primary or compound primary keys.

Q & A

  • What is CWS in the context of this tutorial?

    -CWS stands for Configurable Web Services and is the backend server-side portion of the Page Builder. It is a feature built into Mocha that allows developers and users to expose Mocha commands as web services without having to write and compile new code.

  • What are the two fundamental terms that are essential for configuring CWS?

    -The two fundamental terms essential for configuring CWS are 'action' and 'resource.' An action represents the work carried out by the user (similar to a web service), and a resource is an entity that models a real-world object, usually represented by a primary or compound primary key.

  • What file formats are used to configure CWS actions and resources?

    -CWS actions and resources are configured using XML files. These files are located in a product's data/WS directory and are scanned by the Mocha server during startup to build configurable web services.

  • What does CRUD stand for, and how is it related to CWS?

    -CRUD stands for Create, Read, Update, and Delete. It represents the basic actions that can be performed on a resource within CWS, allowing users to manage and manipulate data associated with that resource.

  • Why is the 'properties' element important in CWS configuration?

    -The 'properties' element is important because it serves as a container for the properties or fields that define the resource. These properties correspond to the columns returned by the Mocha commands used by the resource's actions. It also plays a crucial role in defining the namespaces used by Page Builder when configuring pages and modifying data.

  • What is the significance of the 'type' and 'ref' attributes in an action element?

    -The 'type' attribute specifies the type of action being performed (e.g., add, list, get, edit, delete), while the 'ref' attribute is a reference to the ID of the action that is being used for that resource. The 'ref' attribute is required for any action and must match the action's ID.

  • What is the role of the 'impl' element in CWS configuration?

    -The 'impl' element stands for 'implementation' and specifies the functionality of the action. It contains the core definition of a configurable web service action, including the Mocha command to be executed and any arguments that should be supplied to the action.

  • How are arguments defined in a CWS action, and what attributes are required?

    -Arguments are defined within the 'arguments' element of a CWS action. Each argument requires a 'name' (unique identifier), 'type' (e.g., date, integer, double, float, string), and 'required' (Boolean indicating whether the argument is mandatory). There is also an optional 'description' and 'location' (e.g., path, query, header, or body) to indicate where the argument will be placed in the HTTP request.

  • What is the default HTTP method for actions defined in CWS, and how is it specified?

    -The HTTP method for a CWS action is specified within the 'method' element of the action's configuration. It defines how the action will be called (e.g., GET, POST, PUT, DELETE). There is no default method, so it must be explicitly defined for each action.

  • How does the concept of primary actions work in CWS, and why is it important?

    -Primary actions in CWS indicate the main CRUD action for a particular resource type. There can only be one primary action of each type (e.g., add, edit, delete) per resource. These primary actions are essential as they are guaranteed to work when manipulating the resource, ensuring consistency and reliability.

Outlines

00:00

πŸ“š Introduction to CWS and Page Builder Basics

The video begins with an introduction to CWS (Configurable Web Services) as the server-side component of the page builder in Mocha. CWS allows developers and users to expose Mocha commands as web services without writing new code. It highlights two key elements: **Actions** (web service operations) and **Resources** (entities that model real-world objects with a primary key). The discussion emphasizes that actions and resources are configured via XML files in the product's data/WS directory, which are scanned during server startup. These configurations are critical in defining how CWS operates within Mocha.

05:01

πŸ“ Understanding Resources and Properties

This section focuses on the definition of **Resources** and their properties within CWS. A resource is identified by a unique ID, which is mandatory, while other fields like **Name** and **Description** are recommended but optional. The resource's properties must correspond to the columns returned by Mocha commands, and they play a crucial role in CWS configurations when working with Page Builder. It is emphasized that each property has a **Name**, and can include attributes like **Alias**, **Primary Key (PK)**, and **Type**, which defines its data type (string, integer, etc.). Proper configuration of these properties is essential for ensuring smooth interactions with web services.

10:03

πŸ”§ Configuring Actions and Web Services in CWS

The focus shifts to configuring **Actions** for resources in CWS. Each action is defined by an ID and is mapped to a specific resource using the **Ref** attribute. Actions include various types like **Add**, **List**, **Get**, **Edit**, and **Delete**, each representing different CRUD operations. The configuration also involves specifying an HTTP method and endpoint for the action. Additionally, the **Impl** (Implementation) section is explained, detailing how actions are linked to Mocha commands in the form of **Arguments**, with a clear explanation of how these arguments are named, typed, and positioned in the HTTP request. This section introduces essential action elements for editing order data.

πŸš€ Advanced Configuration of Action Arguments and Security

This section elaborates on the **Action** and **Argument** configurations, explaining in detail how each argument must have a unique name and data type (such as string, integer, etc.). It also touches on the **Required** flag for arguments and explains how these are passed in the HTTP request using different locations such as **Path**, **Query**, **Header**, or **Body**. The **Authorization (Auth)** element is introduced, ensuring secure access to actions, typically defaulting to high-level permissions like **Mocha Admin**. The section concludes by discussing the **Primary** flag for actions, which ensures certain CRUD actions have guaranteed functionality for manipulating resources.

πŸ”— Path, Query, Header, and Body: Specifying Argument Locations

This part explains the different ways to specify argument locations within the HTTP request, including **Path**, **Query**, **Header**, and **Body**. It demonstrates how primary keys and compound keys are arranged and passed in the URL path and query strings. Compound keys are separated by special characters like `*` and `!` and are ordered alphabetically by argument name. The section highlights best practices for specifying these keys and discusses using JSON format for **Header** and **Body** locations when working with HTTP methods like **POST** and **PUT**.

Mindmap

Keywords

πŸ’‘CWS (Configurable Web Services)

CWS refers to the server-side component of the Page Builder tool used in Mocha, enabling developers to expose Mocha commands as web services without writing new code. This feature simplifies integration by offering pre-defined services, which are configured through action and resource files. It is foundational to the video as the tutorial explains its usage and configuration in creating CRUD operations for web resources.

πŸ’‘Mocha

Mocha is the platform where CWS is implemented, serving as the backend server that processes commands and resources. Within the video, Mocha is mentioned as the system where web services are built and deployed through the use of predefined actions and resources. Understanding Mocha’s role is key to understanding how CWS operates in a real-world application.

πŸ’‘Action

An action in CWS defines the work or task a web service performs, such as creating, reading, updating, or deleting a resource. In the script, it is associated with CRUD operations, mapping to a resource to perform specific functions. Actions are represented as XML files and must be referenced correctly within the resource configuration to execute tasks properly.

πŸ’‘Resource

A resource in CWS is an entity that models a real-world object, defined by a unique identifier (primary key) and associated with actions. It typically holds a list of properties and serves as the data model for the actions to work upon. In the video, resources are used in CRUD actions, and their properties are defined in XML format, dictating how data is managed.

πŸ’‘CRUD (Create, Read, Update, Delete)

CRUD refers to the four basic operations performed on resources through web services: create, read, update, and delete. These operations are fundamental to managing data within CWS. The script focuses on configuring these actions, showing how resources are manipulated through CRUD operations and discussing the primary actions associated with each type.

πŸ’‘Primary Key

A primary key (PK) is a unique identifier for a resource, essential for distinguishing between different instances of that resource. In CWS, PKs are required for creating, updating, or deleting specific resources, and they must be correctly defined in the resource configuration. The video highlights the importance of specifying primary keys, especially in compound keys where multiple elements are used.

πŸ’‘XML

XML (Extensible Markup Language) is the format used to define both resources and actions in CWS. It allows for the structured representation of data models and configurations. The video frequently references XML files, showing how resource and action elements are organized and how Mocha uses these files to configure web services upon server startup.

πŸ’‘HTTP Method

The HTTP method specifies the type of operation a web service performs, such as GET, POST, PUT, or DELETE. In the context of the video, HTTP methods are used to call web services, with each action specifying which method to use (e.g., POST for creating data or GET for retrieving data). These methods are part of the web service configuration in CWS.

πŸ’‘Command

A command in CWS refers to the actual functionality that a web service performs, as defined in Mocha. The command is linked to an action and specified in the configuration using a concrete Mocha command. Commands are the core logic behind web services, and in the video, they are tied to the resource actions, allowing CRUD operations to be executed.

πŸ’‘Arguments

Arguments in CWS are the parameters passed to an action to execute a specific command. These can include primary keys, resource properties, or other required data, and they are defined in the XML configuration of an action. The video explains how arguments are critical for CRUD actions, specifying how they should be passed in the HTTP request and where (e.g., query, header, body).

Highlights

CWS (Configurable Web Services) allows developers to expose Mocha commands as web services without the need for new code compilation.

CWS is the backend, server-side portion of the Page Builder feature in Mocha.

CWS uses two main file types: action and resource files, both in XML format, for configuration.

Resources represent real-world entities with properties and actions, often using a primary key to identify them.

Actions are defined as the work that users perform and are synonymous with web services.

A one-to-many mapping typically exists between resources and actions, which are defined in XML files.

Resource and action configurations are scanned on server startup to build configurable web services for each product.

CRUD actions (Create, Read, Update, Delete) are frequently used with resources in CWS.

Each resource property must have a unique name and can be defined as a primary key or not.

Actions for resources can be of different types such as add, list, get, edit, or delete.

HTTP methods like GET, POST, PUT, and DELETE are associated with specific action configurations.

Arguments for actions need to be defined with names, types, and whether they are required.

Authorization settings for actions default to the highest level (Mocha Admin) unless specified otherwise.

Primary CRUD actions are guaranteed to manipulate the resource properly when performing operations.

For actions involving multiple primary keys, the keys are passed in alphabetical order as part of the HTTP request path.

Transcripts

play00:00

and welcome to the first section of the

play00:01

page builder and CWS video tutorial in

play00:04

this section we'll be covering an

play00:05

introduction to CWS and basic quote

play00:07

actions

play00:09

what is CWS

play00:11

CWS is the backend server-side portion

play00:13

of page builder called configurable web

play00:15

services

play00:16

this is a feature built into mocha that

play00:19

allows for developers and users of the

play00:20

product to expose mocha commands as web

play00:23

services without having to write and

play00:25

compile new code

play00:27

in order to understand basic CWS one

play00:30

needs to know the two fundamental terms

play00:32

that are used to configure it there are

play00:34

also two main file types used to

play00:35

configure CWS

play00:38

first element action represents the work

play00:41

that is carried out by the user and is

play00:43

synonymous with web service actions are

play00:46

tied to resources

play00:47

for resource it's an entity that models

play00:50

a real world object represented with a

play00:52

primary key or compound primary key

play00:55

a resource will usually maintain a list

play00:57

of properties and actions which enables

play00:59

a user to work with that type of

play01:01

resource now normally what we'll see is

play01:03

a one-to-many mapping of the resource to

play01:05

actions which we'll see in our example

play01:10

now both actions and resources are

play01:13

represented as files in an XML format

play01:16

that exists in a product's data slash WS

play01:20

directory I'm server startup the mocha

play01:23

server scans this directory for each

play01:25

product defined in its registry

play01:27

configuration server dot product dears

play01:30

build configurable web services from the

play01:32

action and resource files present in

play01:35

those directory directories those would

play01:37

be dot action and Dot resources

play01:39

now I do however recommend that you work

play01:43

in the laser or EMD directory for this

play01:46

tutorial if you're following along

play01:50

let's take a look at the resource that

play01:52

we have defined for this example

play01:54

so this is a resource that we're going

play01:56

to be using for crud actions and credit

play01:58

stands for create read update and delete

play02:03

so the first element ID is the unique

play02:05

identified as a resource it must be

play02:08

unique and is required for any

play02:09

configuration

play02:11

name and description

play02:14

are self-explanatory they aren't

play02:16

required Fields but it's uh recommended

play02:19

that you fill them out if you're working

play02:20

with other people

play02:22

properties is a container for the

play02:25

properties or fields that Define the

play02:26

resource it should correspond to the

play02:28

columns that are returned by the mocha

play02:30

commands this resources actions are

play02:32

using

play02:34

so the properties element

play02:37

um

play02:38

in the CWS sign it's more of

play02:41

documentation but it's critical that you

play02:43

fill this out if you're using CWS as

play02:45

page builder because this actually

play02:47

defines what namespaces paid filter is

play02:50

going to be using uh when configuring uh

play02:53

pages and modifying data and so on and

play02:57

so forth so the first element of

play02:59

property is name each property has a

play03:02

name which is required for that property

play03:04

and must be unique for the given

play03:06

resource an alieness is an alternative

play03:08

name for the resource it's not required

play03:10

PK is a Boolean value that indicates

play03:13

whether this property is a primary key

play03:15

of the resource

play03:16

if you do specify that it's a primary

play03:18

key of the resource you will have to use

play03:21

that if you're getting an individual

play03:24

element editing editing it or deleting

play03:28

data

play03:30

and type is the data type of the

play03:32

property it can be a string integer

play03:34

Boolean double date object or array

play03:37

value it will default to string if you

play03:40

leave it undefined description again is

play03:43

self-explanatory not required

play03:45

so those are the properties

play03:47

um values that configure are configured

play03:51

and the next element is the actions

play03:54

element so this defines the actions that

play03:57

are associated with this resource so for

play04:00

each individual action element you're

play04:01

going to see a type and a ref the type

play04:04

is required for any action and it must

play04:07

be one of the following values add which

play04:10

creates an element list which returns a

play04:12

list of elements get which returns a

play04:15

signal element edit which edits data the

play04:18

links which removes it match which we'll

play04:21

cover later and action which performs

play04:24

some alternative action so in this case

play04:26

we don't have it defined but it could be

play04:28

something like ship order that doesn't

play04:30

necessarily create the updated delete

play04:33

data but does something with it

play04:35

and then you'll see the rest which is a

play04:38

reference to a

play04:40

an action

play04:42

uh it's required for any action and this

play04:44

must match the ID of the action that

play04:48

you're going to use for that resource

play04:51

so let's jump into actions and how those

play04:53

are configured

play04:54

uh this is the action we'll be using to

play04:56

edit order data

play04:58

so here

play05:01

um you'll see the ID which is the first

play05:03

element this is the unique identifier

play05:05

for the action it is required and again

play05:07

I'm going to specify for a stress that

play05:10

you need to match the ref tag in the

play05:12

resource with the idea of the action

play05:15

that you're using for that resource name

play05:18

and description it's the same for me as

play05:20

resource

play05:21

not necessary but

play05:23

um encouraging fill it out

play05:26

and type this relates to the type

play05:28

element referenced in the resource

play05:30

action configuration so here if it isn't

play05:33

defined and will always default to

play05:35

action

play05:36

and you can see here it's added

play05:39

WMS this is a web service config this is

play05:42

a web service definition of the action

play05:44

and is acquainted to define the elements

play05:46

within it method this will be the HTTP

play05:51

method that is used to call this web

play05:53

service and ahref this is the URL

play05:56

endpoint that HTTP clients will call to

play05:58

execute the multi command

play06:01

okay now let's move on to inpl stands

play06:04

for the functionality implementation of

play06:06

the faction it is important for any

play06:08

action

play06:09

and you'll see command

play06:11

this is the core of a configurable web

play06:14

service

play06:15

at least we're in action it is reported

play06:18

and needs to be a concrete multi command

play06:20

that is defined in a DOT ncmd file and

play06:23

it can't be freeform local syntax just a

play06:26

one-off command so it can't be uh for

play06:29

example a raw simple block or a groovy

play06:32

script or anything like that it has to

play06:33

be just a concrete vocal command

play06:36

and arguments here's what we can figure

play06:39

uh which arguments if any should be

play06:42

supplied to the action

play06:45

so here you see we have three arguments

play06:48

Each of which are primary key for this

play06:51

resource

play06:53

and in the argument element

play06:56

the skills that we require are named

play06:59

and type so name is just a unique

play07:02

identifier Let's uh the value that's

play07:06

going to be passed to the resource

play07:08

and then type which is required can be a

play07:11

date integer double float

play07:14

uh string beam array or object

play07:18

and there's a required

play07:21

um setting which is a Boolean play for

play07:23

whether or not this is required

play07:26

description it's just a description of

play07:29

the argument and location of the

play07:31

argument

play07:32

uh some location

play07:34

[Music]

play07:35

um

play07:36

defines where the argument will be put

play07:38

in the HTTP request so it can be passed

play07:42

query header or body

play07:45

so query is going to be the default here

play07:47

and as you can see I specify it for all

play07:51

of these primary keys to from your

play07:52

location via the path

play07:54

and when you go over to actually

play07:56

performing our credit actions I'll show

play07:59

you how you can with primary compound

play08:02

keys in the past

play08:05

so the next element is off

play08:08

you know this is the authorization

play08:10

configuration and it will default to

play08:12

move that to opt mocha admin which is

play08:16

the highest level security that we have

play08:19

and up is the low permission required to

play08:22

call the web service and if you uh

play08:25

Define it believe it's blank it'll

play08:28

default.open

play08:30

and then the next element is primary and

play08:32

this indicates whether or not this is a

play08:34

primary crud action that is the only one

play08:38

primary action of that type per resource

play08:40

primary actions are guaranteed to work

play08:43

when using them to manipulate these

play08:44

particular resources

play08:46

firstly some resources may have

play08:48

unrelated credit actions on them which

play08:51

are actually working with different

play08:53

resource types and those are not quite

play08:55

accents for the parent resource and

play08:57

missile defaults are false

play08:59

so there are other Market Advanced

play09:01

configuration options but let's stick

play09:03

with these for now is we only need to

play09:05

perform our basic Corrections

play09:08

so let's cover action argument locations

play09:11

since this can be fairly confusing what

play09:14

I mean by this is the actual location

play09:16

setting on the argument Peg

play09:19

and this can either be path query header

play09:22

or body

play09:23

the path you're going to see an hrf

play09:25

looking something like this with orders

play09:27

and then the identifier of the required

play09:30

and additional arguments specified in

play09:34

this curly braces

play09:35

so this can technically be anything

play09:37

that's recommended that for common

play09:38

problem primary keys or regular primary

play09:41

because you just specify it as PK as

play09:45

you'll notice in the following demos I

play09:47

learned some of my actions with ordnum

play09:51

specified in the curly braces well

play09:53

technically not incorrect this is

play09:55

considered bad practice so keep in mind

play09:57

that when you do create your own actions

play09:59

if you're using compound primary keys to

play10:02

specify this as PK

play10:06

now when we look at the URL for

play10:09

something like this if we're using a

play10:10

single primary key

play10:12

this is going to be off of the endpoint

play10:14

specified in the ahref followed by the

play10:16

primary key for a compound primary case

play10:19

a little bit different

play10:20

so you're going to have the elements of

play10:23

the compound primary key each one

play10:25

separated by a star and an exclamation

play10:28

point

play10:30

the way that the order of these of these

play10:33

primary Keys is part of the compound

play10:34

primary key

play10:36

or also known as the resource ID

play10:39

is going to be in the alphabetical order

play10:42

of the argument name

play10:45

so when you specify this since client ID

play10:49

comes before order number an order

play10:51

number comes before Warehouse ID that's

play10:53

the order that we would specify here

play10:55

when I talk about arranging these

play10:57

arguments alphabetically I don't I'm not

play10:59

talking about the actual content in the

play11:02

path of the URL so for example if this

play11:04

was a it would still be in the same

play11:07

location because the argument name

play11:09

Warehouse ID comes last alphabetically

play11:13

for query the idea prep is going to just

play11:17

um be an end point and then we're going

play11:19

to be specifying the arguments in an

play11:20

HTTP query

play11:23

so that would look something like this

play11:25

where you'd have a question mark and

play11:28

then ID equals something it's just

play11:31

arbitrary data if you have additional

play11:32

arguments you would separate them by an

play11:34

ampersand and then follow suit with the

play11:38

argument equals something or something

play11:40

like that

play11:42

and then for header and body specified

play11:44

argument locations

play11:47

typically used for post and put HTTP

play11:50

methods you would specify that in a Json

play11:54

as Json data and the header or body of

play11:57

the request

play11:58

and Postman and other HTTP clients

play12:00

actually have utilities of making this a

play12:03

little bit more usable just keep in mind

play12:05

to specify this in a Json format since

play12:08

that's the agreed upon 4.4 of CWS

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
CWS tutorialMocha integrationCRUD actionsweb servicesresource managementbackend setupserver-side configAPI configurationdeveloper guideXML files