Sha256: fd0c2b6e1c58528bb77649b7a5d0e7cc58fd4592e10e622c0b982b508b910b58

Contents?: true

Size: 953 Bytes

Versions: 3

Compression:

Stored size: 953 Bytes

Contents

\* infrastructure service /id/{type}(get)

procedure infrastructure_id_get( id_type ) {


infrastructure_id_get_start:

    \* any ids left?
    if ( Cardinality( v_ids[ id_type ] ) = 0 ) {

        \* response:  404 & Nil
        \* InfrastructureServiceReturn(  "/id/{type}(get)",  "status_404", Nil );
        InfrastructureServiceReturn(  "/id/{type}(get)",  "status_404", [ status_200 |-> [ id |-> Nil] , status_404 |-> [code |-> Nil, message |-> Nil ]]);
	
    }
    else {

    	\* remove generated id from set of free ids
        v_ids := [  v_ids EXCEPT ![id_type] = @ \ { Next_id( id_type ) } ] ;

	\* response: 200 && generated id
        \* InfrastructureServiceReturn( "/id/{type}(get)", "status_200", [ status_200 |-> Next_id( id_type ) ] );
        InfrastructureServiceReturn( "/id/{type}(get)", "status_200", [ status_200 |-> [ id |-> Next_id( id_type ) ], status_404 |-> [code |-> Nil, message |-> Nil ]  ] );
	
     };
    return;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tla-sbuilder-0.3.9 src/pet/infrastructure_id_get.tla
tla-sbuilder-0.3.8 src/pet/infrastructure_id_get.tla
tla-sbuilder-0.3.7 src/pet/infrastructure_id_get.tla